Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GTest example #17

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Jun 11, 2019

An user from Stack Overflow is following https://github.com/lasote/conan-gtest-example. Since it's an example, I've moved it to here.

New documentation for GTest: conan-io/docs#1668

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@jgsogo
Copy link
Contributor

jgsogo commented Feb 12, 2020

Do we talk about it in our docs? IMO every example here should have a reason: it is in our docs or it demonstrates some feature; otherwise CI times will grow and maintenance could be a problem

@danimtb
Copy link
Member

danimtb commented Feb 12, 2020

@uilianries
Copy link
Member Author

I just rebased it now, let's see the result

@jgsogo
Copy link
Contributor

jgsogo commented Feb 13, 2020

This example in the docs is about the appveyor.yml file (which we are not copying here, neither using it). Maybe it requires a standalone repo like this one https://github.com/conan-io/hello

@uilianries
Copy link
Member Author

I don't like the idea separating all examples again. Rarely are the users which know about hello repo.

@jgsogo
Copy link
Contributor

jgsogo commented Feb 24, 2020

I totally agree that we shouldn't separate the examples, but for this one we need to run the actual appveyor.yml file, otherwise we are just testing the gtest package which is something we are already doing in c3i.

And, I've just realized we have a bug in the example file, it says cmmd instead of cmd 😮

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@danimtb
Copy link
Member

danimtb commented Apr 23, 2020

mac build failed but the error is not known to me

@uilianries
Copy link
Member Author

I tried to reproduce on MacInCloud and did happen. I'll try one more test to validate. My guess is a runtime error related to dynamic library.

uilianries and others added 12 commits April 27, 2020 15:26
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
This reverts commit 7ba41b6.
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. This is moving the sourcces from https://github.com/lasote/conan-gtest-example to this repo :+1

Nevertheless I think we should run the same commands in the appveyor.yml file provided in the docs and here. I don't know if the intention is to change the lines in the appveyor.yml file too.

About the Mac error. Really worried about it. Does it mean we are not detecting the apple-clang version properly? I see compiler.version=10.0 in the output, but the version in 10.13.

From Conan sources:

def _clang_compiler(output, compiler_exe="clang"):
    try:
        ret, out = detect_runner('%s --version' % compiler_exe)
        if ret != 0:
            return None
        if "Apple" in out:
            compiler = "apple-clang"
        elif "clang version" in out:
            compiler = "clang"
        installed_version = re.search("([0-9]+\.[0-9])", out).group()
        if installed_version:
            output.success("Found %s %s" % (compiler, installed_version))
            return compiler, installed_version
    except Exception:
        return None

and the regex will catch only the first figure of the minor version of the compiler 😱 I'll double-check it and open issue/PR in Conan if needed.

@jgsogo
Copy link
Contributor

jgsogo commented Apr 28, 2020

The problem is not detecting the compiler, according to this list here (https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_11.x_(since_Free_On-Device_Development)) there is no apple-clang 10.13. It refers to the macOS version...

Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uilianries

MacOS is failing because of the shared, it cannot find dylib. Check the full output here:

----Running------
> cmake --build '/Users/jgsogo/dev/conan/examples/libraries/gtest/encryption/test_package/build/8b8e3c6c4c013ae5cdfb03a30f473e07a61b45b2' '--target' 'test' '--' '-j12'
-----------------
Running tests...
Test project /Users/jgsogo/dev/conan/examples/libraries/gtest/encryption/test_package/build/8b8e3c6c4c013ae5cdfb03a30f473e07a61b45b2
    Start 1: encryption
1/1 Test #1: encryption .......................Child aborted***Exception:   0.11 sec
dyld: Library not loaded: libgmock_maind.dylib
  Referenced from: /Users/jgsogo/dev/conan/examples/libraries/gtest/encryption/test_package/build/8b8e3c6c4c013ae5cdfb03a30f473e07a61b45b2/bin/encryption-test
  Reason: image not found


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.11 sec

The following tests FAILED:
	  1 - encryption (Child aborted)
Errors while running CTest
make: *** [test] Error 8

This is something to investigate, probably related to the issue that the DYLD_LIBRARY... should be set in the same call as the command itself, and cmake.test is not doing that.

Quick solution: use gtest static

@jgsogo
Copy link
Contributor

jgsogo commented Apr 28, 2020

Just as a reference, I've been trying the example locally and using DYLD_... && cmake --build XXXX --target test doesn't work, you need to add that variable to the environment for the given target in CMake:

set_property(TEST encryption PROPERTY ENVIRONMENT "DYLD_LIBRARY_PATH=${GTest_LIB_DIRS}")

@uilianries
Copy link
Member Author

@jgsogo Thanks a lot! You and @SSE4 are helping a lot, without you supports it wouldn't be possible!

@jgsogo
Copy link
Contributor

jgsogo commented May 12, 2020

Did you manage to fix this issue? We can try to finish this PR

@EstebanDugueperoux2
Copy link

Hello,

I'm interested by a conan 2.0 example project using some tests written with GTest outside of test_package as described in "A different approach " of https://github.com/lasote/conan-gtest-example#synopsis.
The ideal would be to have a simple invocation of conan as "conan create . ...".
With CMakeToolchain which seems the new way to use conan with CMake.
Currently I have error of https://stackoverflow.com/questions/42162014/gtest-installed-with-conan-undefined-reference and proposed answer doesn't works.

Regards.

@memsharded
Copy link
Member

@EstebanDugueperoux2 you want to refer to the examples repo for Conan 2.0: https://github.com/conan-io/examples2

@EstebanDugueperoux2
Copy link

@EstebanDugueperoux2 you want to refer to the examples repo for Conan 2.0: https://github.com/conan-io/examples2

Yes, I'll try to submit a little example through a pull request showing my issue.
Otherwise, is it normal to have a 404 Not Found when clicking on "Edit on GitHub" (top right corner) in https://docs.conan.io/en/2.0-alpha/tutorial/consuming_packages/build_simple_cmake_project.html?

Regards.

@memsharded
Copy link
Member

Yes, that link is broken for 2.0 docs, we would need to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants