Skip to content

Conversation

@duncanmmacleod
Copy link
Contributor

@duncanmmacleod duncanmmacleod commented May 5, 2021

This PR adds a new CMake option EXTERNAL_GTEST (default OFF) which allows disabling the build of the vendored gtest for the test suite.

I also added -DBUILD_UNITTESTS:BOOL=TRUE -DEXTERNAL_GTEST:BOOL=TRUE and a %check section to the rpm build to run the tests there. EDIT: this was dropped because EPEL7's gtest is too old, and adding a bunch of %if macros in the spec file seemed like a lot of work...

Fixed #46.

to allow disabling building the vendored copy of gtest, it's available on most platforms
@duncanmmacleod duncanmmacleod force-pushed the external-gtest branch 2 times, most recently from a037c96 to 563b39b Compare May 5, 2021 14:21
Copy link
Contributor

@djw8605 djw8605 left a comment

Choose a reason for hiding this comment

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

I presume you tested all of this? Otherwise, it looks good.

@duncanmmacleod
Copy link
Contributor Author

@djw8605, here's the log of a build that uses the EXTERNAL_GTEST option. Notice that gtest isn't built on-the-fly, but the tests run fine.

$ bash -ex build.sh
+ rm -rf _build
+ mkdir _build
+ cd _build
+ pwd
+ cmake .. -DCMAKE_INSTALL_PREFIX=/home/duncan/git/scitokens-cpp-fork/_build/_inst -DBUILD_UNITTESTS:BOOL=TRUE -DEXTERNAL_GTEST:BOOL=TRUE
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /home/duncan/opt/miniconda3/envs/py39/bin/x86_64-conda-linux-gnu-cc
-- Check for working C compiler: /home/duncan/opt/miniconda3/envs/py39/bin/x86_64-conda-linux-gnu-cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/duncan/opt/miniconda3/envs/py39/bin/x86_64-conda-linux-gnu-c++
-- Check for working CXX compiler: /home/duncan/opt/miniconda3/envs/py39/bin/x86_64-conda-linux-gnu-c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found CURL: /home/duncan/opt/miniconda3/envs/py39/lib/libcurl.so (found version "7.76.1")
-- Looking for uuid_generate
-- Looking for uuid_generate - not found
-- Found UUID : /home/duncan/opt/miniconda3/envs/py39/lib/libuuid.so
-- Found PkgConfig: /home/duncan/opt/miniconda3/envs/py39/bin/pkg-config (found version "0.29.2")
-- Checking for module 'libcrypto'
--   Found libcrypto, version 1.1.1k
-- Checking for module 'openssl'
--   Found openssl, version 1.1.1k
-- Checking for module 'sqlite3'
--   Found sqlite3, version 3.35.5
-- Configuring done
CMake Warning (dev) at test/CMakeLists.txt:3 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "gtest" of target "scitokens-gtest" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /home/duncan/git/scitokens-cpp-fork/_build
+ cmake --build .
Scanning dependencies of target SciTokens
[  6%] Building CXX object CMakeFiles/SciTokens.dir/src/scitokens.cpp.o
[ 12%] Building CXX object CMakeFiles/SciTokens.dir/src/scitokens_internal.cpp.o
[ 18%] Building CXX object CMakeFiles/SciTokens.dir/src/scitokens_cache.cpp.o
[ 25%] Linking CXX shared library libSciTokens.so
[ 25%] Built target SciTokens
Scanning dependencies of target scitokens-test
[ 31%] Building CXX object CMakeFiles/scitokens-test.dir/src/test.cpp.o
[ 37%] Linking CXX executable scitokens-test
[ 37%] Built target scitokens-test
Scanning dependencies of target scitokens-create
[ 43%] Building CXX object CMakeFiles/scitokens-create.dir/src/create.cpp.o
[ 50%] Linking CXX executable scitokens-create
[ 50%] Built target scitokens-create
Scanning dependencies of target scitokens-list-access
[ 56%] Building CXX object CMakeFiles/scitokens-list-access.dir/src/list_access.cpp.o
[ 62%] Linking CXX executable scitokens-list-access
[ 62%] Built target scitokens-list-access
Scanning dependencies of target scitokens-verify
[ 68%] Building CXX object CMakeFiles/scitokens-verify.dir/src/verify.cpp.o
[ 75%] Linking CXX executable scitokens-verify
[ 75%] Built target scitokens-verify
Scanning dependencies of target scitokens-test-access
[ 81%] Building CXX object CMakeFiles/scitokens-test-access.dir/src/test_access.cpp.o
[ 87%] Linking CXX executable scitokens-test-access
[ 87%] Built target scitokens-test-access
Scanning dependencies of target scitokens-gtest
[ 93%] Building CXX object test/CMakeFiles/scitokens-gtest.dir/main.cpp.o
[100%] Linking CXX executable scitokens-gtest
[100%] Built target scitokens-gtest
+ ctest -V
UpdateCTestConfiguration  from :/home/duncan/git/scitokens-cpp-fork/_build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/duncan/git/scitokens-cpp-fork/_build/DartConfiguration.tcl
Test project /home/duncan/git/scitokens-cpp-fork/_build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: unit

1: Test command: /home/duncan/git/scitokens-cpp-fork/_build/test/scitokens-gtest
1: Test timeout computed to be: 10000000
1: [==========] Running 6 tests from 2 test suites.
1: [----------] Global test environment set-up.
1: [----------] 2 tests from SciTokenTest
1: [ RUN      ] SciTokenTest.CreateToken
1: [       OK ] SciTokenTest.CreateToken (0 ms)
1: [ RUN      ] SciTokenTest.SignToken
1: [       OK ] SciTokenTest.SignToken (1 ms)
1: [----------] 2 tests from SciTokenTest (1 ms total)
1:
1: [----------] 4 tests from SerializeTest
1: [ RUN      ] SerializeTest.VerifyTest
1: [       OK ] SerializeTest.VerifyTest (17 ms)
1: [ RUN      ] SerializeTest.TestStringList
1: [       OK ] SerializeTest.TestStringList (5 ms)
1: [ RUN      ] SerializeTest.VerifyWLCGTest
1: [       OK ] SerializeTest.VerifyWLCGTest (5 ms)
1: [ RUN      ] SerializeTest.FailVerifyToken
1: [       OK ] SerializeTest.FailVerifyToken (5 ms)
1: [----------] 4 tests from SerializeTest (32 ms total)
1:
1: [----------] Global test environment tear-down
1: [==========] 6 tests from 2 test suites ran. (33 ms total)
1: [  PASSED  ] 6 tests.
1/1 Test #1: unit .............................   Passed    0.04 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.04 sec
+ cmake --build . --target install
[ 25%] Built target SciTokens
[ 37%] Built target scitokens-test
[ 50%] Built target scitokens-create
[ 62%] Built target scitokens-list-access
[ 75%] Built target scitokens-verify
[ 87%] Built target scitokens-test-access
[100%] Built target scitokens-gtest
Install the project...
-- Install configuration: ""
-- Installing: /home/duncan/git/scitokens-cpp-fork/_build/_inst/lib/libSciTokens.so.0.0.2
-- Installing: /home/duncan/git/scitokens-cpp-fork/_build/_inst/lib/libSciTokens.so.0
-- Installing: /home/duncan/git/scitokens-cpp-fork/_build/_inst/lib/libSciTokens.so
-- Installing: /home/duncan/git/scitokens-cpp-fork/_build/_inst/include/scitokens/scitokens.h

@djw8605
Copy link
Contributor

djw8605 commented May 6, 2021

Neat! Sounds great!

@djw8605 djw8605 merged commit 10ba981 into scitokens:master May 6, 2021
@duncanmmacleod duncanmmacleod deleted the external-gtest branch May 6, 2021 15:10
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.

Add option to use external gtest

2 participants