GithubHelp home page GithubHelp logo

conan-gtest-example's Introduction

Conan GTest Example

Build Status Build status License

Getting Started

  • Download conan client from Conan.io.

  • Run the following command.

conan create . user/channel

The above command will export, build and test a conan package for a custom encryption library.

Synopsis

Conan.io example for gtest project.

The project is using OpenSSL to build an encryption library, and using Google test to ensure that the library is built correctly. The Google test library is required in the test_package/conanfile.py.

A different approach would be running the test at the end of the build() method in the root conanfile.py and require gtest library as a build_require, so it would be only downloaded when the encryption library has to be built from sources.

With that approach, the test_package project could just run an example using/linking with the encryption library.

License

LICENSE

conan-gtest-example's People

Contributors

lasote avatar uilianries avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

conan-gtest-example's Issues

ERROR: Unable to find 'gtest/1.7.0@lasote/stable' in remotes.

conan create . whateveruser/whateverchannel                                                                                  
Exporting package recipe
conan-gtest-example/0.1.0@whateveruser/whateverchannel: A new conanfile.py version was exported
conan-gtest-example/0.1.0@whateveruser/whateverchannel: Folder: /home/leonard/.conan/data/conan-gtest-example/0.1.0/whateveruser/whateverchannel/export
conan-gtest-example/0.1.0@whateveruser/whateverchannel: Package recipe modified in export, forcing source folder removal
conan-gtest-example/0.1.0@whateveruser/whateverchannel: Use the --keep-source, -k option to skip it
conan-gtest-example/0.1.0@whateveruser/whateverchannel: Removing 'source' folder, this can take a while for big packages
gtest/1.7.0@lasote/stable: Not found in local cache, looking in remotes...
gtest/1.7.0@lasote/stable: Trying with 'conan-center'...
ERROR: Failed requirement 'gtest/1.7.0@lasote/stable' from 'PROJECT'
ERROR: Unable to find 'gtest/1.7.0@lasote/stable' in remotes
conan test test_package conan-gtest-example/0.1.0@whateveruser/whateverchannel
gtest/1.7.0@lasote/stable: Not found in local cache, looking in remotes...
gtest/1.7.0@lasote/stable: Trying with 'conan-center'...
ERROR: Failed requirement 'gtest/1.7.0@lasote/stable' from 'PROJECT'
ERROR: Unable to find 'gtest/1.7.0@lasote/stable' in remotes

Clion support

Hello,

when I run the command
conan install . -s build_type=Debug --install-folder=cmake-build-debug --build outdated
the test code is still not available in CLion. Can you please add an example of how to integrate the GTest in CLion via conan as well?

Thank you

Test failed.

Using the instructions from README.md.

Versions:

# cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# python --version
Python 2.7.13
# pip --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
# conan --version
Conan version 0.27.0

Unable to download dependencies:

root@68ab7d08eed5:/workspace/3rdparty/conan-gtest-example-master# conan test_package
ERROR: Please specify user and channel
root@68ab7d08eed5:/workspace/3rdparty/conan-gtest-example-master# conan export lasote
ERROR: Invalid parameter 'lasote', specify the full reference or user/channel
root@68ab7d08eed5:/workspace/3rdparty/conan-gtest-example-master#  conan install conan-gtest-example/0.1.0@lasote/testing --build conan-gtest-example
WARN: Remotes registry file missing, creating default one in /root/.conan/registry.txt
conan-gtest-example/0.1.0@lasote/testing: Not found in local cache, looking in remotes...
conan-gtest-example/0.1.0@lasote/testing: Trying with 'conan-center'...
conan-gtest-example/0.1.0@lasote/testing: Trying with 'conan-transit'...
ERROR: Unable to find 'conan-gtest-example/0.1.0@lasote/testing' in remotes

However, we can use CMake to build project directly.

# find /workspace/3rdparty/conan-gtest-example-master/build/lib
/workspace/3rdparty/conan-gtest-example-master/build/lib
/workspace/3rdparty/conan-gtest-example-master/build/lib/libencrypter.a

Unable to run test project and validate the project package:

root@68ab7d08eed5:/workspace/3rdparty/conan-gtest-example-master/test_package/build# cmake --build .
[ 50%] Building CXX object CMakeFiles/encryption-test.dir/encryption_test.cpp.o
/workspace/3rdparty/conan-gtest-example-master/test_package/encryption_test.cpp:3:25: fatal error: gtest/gtest.h: No such file or directory
 #include <gtest/gtest.h>
                         ^
compilation terminated.
CMakeFiles/encryption-test.dir/build.make:62: recipe for target 'CMakeFiles/encryption-test.dir/encryption_test.cpp.o' failed
make[2]: *** [CMakeFiles/encryption-test.dir/encryption_test.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/encryption-test.dir/all' failed
make[1]: *** [CMakeFiles/encryption-test.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
root@68ab7d08eed5:/workspace/3rdparty/conan-gtest-example-master/test_package/build# cmake --build . --target test
Running tests...
Test project /workspace/3rdparty/conan-gtest-example-master/test_package/build
    Start 1: encryption
Could not find executable /workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/encryption-test
Looked in the following places:
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Release/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Release/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Debug/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Debug/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/MinSizeRel/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/MinSizeRel/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/RelWithDebInfo/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/RelWithDebInfo/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Deployment/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Deployment/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Development/encryption-test
/workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Development/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Release/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Release/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Debug/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Debug/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/MinSizeRel/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/MinSizeRel/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/RelWithDebInfo/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/RelWithDebInfo/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Deployment/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Deployment/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Development/encryption-test
workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/Development/encryption-test
Unable to find executable: /workspace/3rdparty/conan-gtest-example-master/test_package/build/bin/encryption-test
1/1 Test #1: encryption .......................***Not Run   0.00 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.02 sec

The following tests FAILED:
	  1 - encryption (Not Run)
Errors while running CTest
Makefile:83: recipe for target 'test' failed
make: *** [test] Error 8
root@68ab7d08eed5:/workspace/3rdparty/conan-gtest-example-master/test_package/build#

conan create: error: the following arguments are required: reference

The README.md contains outdated command.

conan create whateveruser/whateverchannel 
usage: conan create [-h] [-j JSON] [-k] [-kb] [-ne] [-tbf TEST_BUILD_FOLDER]
                    [-tf TEST_FOLDER] [-m [MANIFESTS]]
                    [-mi [MANIFESTS_INTERACTIVE]] [-v [VERIFY]] [-b [BUILD]]
                    [-e ENV] [-o OPTIONS] [-pr PROFILE] [-r REMOTE]
                    [-s SETTINGS] [-u]
                    path reference
conan create: error: the following arguments are required: reference
ERROR: Exiting with code: 2

Example doesn't work

Step by step instructions fail at first step:

┌─[adam][hapkido][±][master ✓][~/conan-gtest-example]
└─▪ conan export lasote
ERROR: Invalid parameter 'lasote', specify the full reference or user/channel

Dynamic libraries aren't found at runtime

Building this example works great on my system (OS X 10.11.3, make 3.4.3), but running the resulting builds fail with the following error:
$ ./bin/encryption_test dyld: Library not loaded: libssl.1.0.0.dylib Referenced from: [redacted]./bin/encryption_test Reason: image not found Trace/BPT trap: 5

Switching to static libraries works :)

WARNING!!! Do not pass 'self' to configure()

conan-gtest-example/0.1.0@lasote/testing test package: Running test()
conan-gtest-example/0.1.0@lasote/testing test package: WARN:
*******************************   WARNING!!! ************************************

Do not pass 'self' to configure() nor build() methods, it is deprecated and will be removed.

Instance CMake with the conanfile instance instead:

    cmake = CMake(self)
    cmake.configure() # Optional args, defs, source_dir and build_dir parameters
    cmake.build() # Optional args, build_dir and target


**********************************************************************************

undefined reference to `testing::internal::GetBoolAssertionFailureMessage`

I'm new to conan. This project is mentioned as an example for using Google Test with conan. I try to use EXPECT_FALSE, but if I add EXPECT_FALSE(false); in line 46 of encryption_test.cpp I get an unexpected error:

/path/to/conan-gtest-example/test/encryption_test.cpp:46: undefined reference to `testing::internal::GetBoolAssertionFailureMessage[abi:cxx11](testing::AssertionResult const&, char const*, char const*, char const*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I installed dependencies like this

conan install -s compiler=clang -s compiler.version=3.8 -s compiler.libcxx=libstdc++ --build=missing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.