Skip to content

Commit

Permalink
Merge pull request #1738 from bennibbelink/gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke committed Apr 21, 2024
2 parents d22a356 + 7e009dd commit 26f5438
Show file tree
Hide file tree
Showing 22 changed files with 33 additions and 32,553 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Since last release
* Changed dependency versions in README.rst, INSTALL.rst, and DEPENDENCIES.rst (#1703, #1735)
* Updated minor documentation about updating CHANGELOG.rst, fix formatting for rendering
hyperlinks, and change branch name in README instructions on forking for development (#1715)
* Updated GTest suite to be fetched from GitHub during the build process (#1738)

**Removed:**

Expand Down
4 changes: 2 additions & 2 deletions agents/k_facility_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static int cyclus_agent_tests_connected = ConnectAgentTests();
#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
#endif // CYCLUS_AGENT_TESTS_CONNECTED

INSTANTIATE_TEST_CASE_P(KFac, FacilityTests,
INSTANTIATE_TEST_SUITE_P(KFac, FacilityTests,
::testing::Values(&KFacilityConstructor));

INSTANTIATE_TEST_CASE_P(KFac, AgentTests,
INSTANTIATE_TEST_SUITE_P(KFac, AgentTests,
::testing::Values(&KFacilityConstructor));
4 changes: 2 additions & 2 deletions agents/null_inst_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int cyclus_agent_tests_connected = ConnectAgentTests();
#endif // CYCLUS_AGENT_TESTS_CONNECTED

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INSTANTIATE_TEST_CASE_P(NullInst, InstitutionTests,
INSTANTIATE_TEST_SUITE_P(NullInst, InstitutionTests,
::testing::Values(&NullInstConstructor));
INSTANTIATE_TEST_CASE_P(NullInst, AgentTests,
INSTANTIATE_TEST_SUITE_P(NullInst, AgentTests,
::testing::Values(&NullInstConstructor));
4 changes: 2 additions & 2 deletions agents/null_region_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int cyclus_agent_tests_connected = ConnectAgentTests();
#endif // CYCLUS_AGENT_TESTS_CONNECTED

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INSTANTIATE_TEST_CASE_P(NullRegion, RegionTests,
INSTANTIATE_TEST_SUITE_P(NullRegion, RegionTests,
::testing::Values(&NullRegionConstructor));
INSTANTIATE_TEST_CASE_P(NullRegion, AgentTests,
INSTANTIATE_TEST_SUITE_P(NullRegion, AgentTests,
::testing::Values(&NullRegionConstructor));
4 changes: 2 additions & 2 deletions agents/sink_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ static int cyclus_agent_tests_connected = ConnectAgentTests();
#endif // CYCLUS_AGENT_TESTS_CONNECTED

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INSTANTIATE_TEST_CASE_P(SinkFac, FacilityTests,
INSTANTIATE_TEST_SUITE_P(SinkFac, FacilityTests,
::testing::Values(&SinkConstructor));

INSTANTIATE_TEST_CASE_P(SinkFac, AgentTests,
INSTANTIATE_TEST_SUITE_P(SinkFac, AgentTests,
::testing::Values(&SinkConstructor));
4 changes: 2 additions & 2 deletions agents/source_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ static int cyclus_agent_tests_connected = ConnectAgentTests();
#endif // CYCLUS_AGENT_TESTS_CONNECTED

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INSTANTIATE_TEST_CASE_P(SourceFac, FacilityTests,
INSTANTIATE_TEST_SUITE_P(SourceFac, FacilityTests,
::testing::Values(&SourceConstructor));

INSTANTIATE_TEST_CASE_P(SourceFac, AgentTests,
INSTANTIATE_TEST_SUITE_P(SourceFac, AgentTests,
::testing::Values(&SourceConstructor));
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ WORKDIR /cyclus
RUN python install.py -j ${make_cores} --build-type=Release --allow-milps --code_coverage
ENV PATH /root/.local/bin:$PATH
ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus
RUN lcov -c --rc lcov_branch_coverage=1 -d /cyclus -o initial_coverage.info --gcov-tool ${GCOV} --initial --no-external && \
RUN lcov -c -d /cyclus -o initial_coverage.info --gcov-tool ${GCOV} --initial --no-external && \
cyclus_unit_tests && \
cd tests && python -m pytest && cd .. && \
lcov -c --rc lcov_branch_coverage=1 -d /cyclus -o test_coverage.info --gcov-tool ${GCOV} --no-external && \
lcov --add-tracefile initial_coverage.info --add-tracefile test_coverage.info --rc lcov_branch_coverage=1 -o total_coverage.info && \
mkdir -p html && genhtml total_coverage.info --output-directory html --branch-coverage
lcov -c -d /cyclus -o test_coverage.info --gcov-tool ${GCOV} --no-external && \
lcov --add-tracefile initial_coverage.info --add-tracefile test_coverage.info -o total_coverage.info && \
mkdir -p html && genhtml total_coverage.info --output-directory html

FROM scratch as coverage-report
COPY --from=cyclus-coverage /cyclus /
Expand Down
4 changes: 2 additions & 2 deletions stubs/src/stub_facility_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ int ConnectAgentTests();
static int cyclus_agent_tests_connected = ConnectAgentTests();
#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
#endif // CYCLUS_AGENT_TESTS_CONNECTED
INSTANTIATE_TEST_CASE_P(StubFacility, FacilityTests,
INSTANTIATE_TEST_SUITE_P(StubFacility, FacilityTests,
::testing::Values(&StubFacilityConstructor));
INSTANTIATE_TEST_CASE_P(StubFacility, AgentTests,
INSTANTIATE_TEST_SUITE_P(StubFacility, AgentTests,
::testing::Values(&StubFacilityConstructor));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4 changes: 2 additions & 2 deletions stubs/src/stub_inst_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ int ConnectAgentTests();
static int cyclus_agent_tests_connected = ConnectAgentTests();
#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
#endif // CYCLUS_AGENT_TESTS_CONNECTED
INSTANTIATE_TEST_CASE_P(StubInst, InstitutionTests,
INSTANTIATE_TEST_SUITE_P(StubInst, InstitutionTests,
::testing::Values(&StubInstConstructor));
INSTANTIATE_TEST_CASE_P(StubInst, AgentTests,
INSTANTIATE_TEST_SUITE_P(StubInst, AgentTests,
::testing::Values(&StubInstConstructor));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4 changes: 2 additions & 2 deletions stubs/src/stub_region_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ int ConnectAgentTests();
static int cyclus_agent_tests_connected = ConnectAgentTests();
#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
#endif // CYCLUS_AGENT_TESTS_CONNECTED
INSTANTIATE_TEST_CASE_P(StubRegion, RegionTests,
INSTANTIATE_TEST_SUITE_P(StubRegion, RegionTests,
::testing::Values(&StubRegionConstructor));
INSTANTIATE_TEST_CASE_P(StubRegion, AgentTests,
INSTANTIATE_TEST_SUITE_P(StubRegion, AgentTests,
::testing::Values(&StubRegionConstructor));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39 changes: 10 additions & 29 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,17 @@ SET(GENERATED_TEST_LIST "" CACHE INTERNAL "")
SET(GENERATED_FILTER_LIST "" CACHE INTERNAL "")
SET(GENERATED_TEST_SOURCE_LIST "" CACHE INTERNAL "")

# The gtest include file directories.
SET(GTEST_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest"
)

# The gtest library directories.
SET(GTEST_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}/lib")

# Alerts CMake to any tests we need to worry about
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})

FIND_PACKAGE(Threads)
IF(CMAKE_USE_PTHREADS_INIT) # The pthreads library is available.
SET(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
ENDIF()

# Build libgtest
SET(GTest
"${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest/gtest/gtest-all.cc"
)
include(FetchContent)
FetchContent_Declare(
googletest
BUILD_GMOCK FALSE # do not build googlemock subproject
INSTALL_GTEST FALSE # do not install googletest, we will do this ourselves
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
FetchContent_MakeAvailable(googletest)

INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}")

ADD_LIBRARY(gtest ${GTest})

IF(CMAKE_USE_PTHREADS_INIT)
TARGET_LINK_LIBRARIES(gtest ${CMAKE_THREAD_LIBS_INIT})
ENDIF()

SET_TARGET_PROPERTIES(gtest
PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib/cyclus"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/cyclus"
Expand All @@ -46,8 +28,8 @@ INSTALL(TARGETS gtest
COMPONENT testing
)

INSTALL(FILES GoogleTest/gtest/gtest.h
DESTINATION include/cyclus/gtest
INSTALL(DIRECTORY ${googletest_SOURCE_DIR}/googletest/include/gtest
DESTINATION include/cyclus
COMPONENT testing
)

Expand Down Expand Up @@ -95,7 +77,6 @@ SET(
SET(
CYCLUS_CORE_INCLUDE_DIRS "${CYCLUS_CORE_INCLUDE_DIRS}"
"${CYCLUS_CORE_TEST_INCLUDE_DIRS}"
"${GTEST_INCLUDE_DIRS}"
PARENT_SCOPE
)

Expand Down
Loading

0 comments on commit 26f5438

Please sign in to comment.