-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for gtest if testing is enabled. #451
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
Changes from 1 commit
c35b27d
2befa51
48f6bc8
405426a
cd1255a
12f9519
4198148
0d56bb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
* Move test folder in every module; * Remove mock objects; * Clarify comment; * Add a simple test.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1079,16 +1079,19 @@ function(ROOT_ADD_TEST test) | |
| endfunction() | ||
|
|
||
| #---------------------------------------------------------------------------- | ||
| # function ROOT_ADD_GTEST(<testsuite> <name> LIBRARIES) | ||
| # function ROOT_ADD_GTEST(<testsuite> source1 source2... LIBRARIES) | ||
| # | ||
| function(ROOT_ADD_GTEST test_suite test_name) | ||
| function(ROOT_ADD_GTEST test_suite) | ||
| CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES" ${ARGN}) | ||
|
|
||
| include_directories(${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add the source directory to the include dirs, or does that happen by default? (I want to be able to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
|
||
| # Note we cannot use ROOT_EXECUTABLE because it requires to pass LIBRARIES to link with. | ||
| # The test suites should chose this in their specific CMakeLists.txt file. | ||
| ROOT_EXECUTABLE(${test_suite} ${test_name} LIBRARIES ${ARG_LIBRARIES}) | ||
| set(source_files ${ARG_UNPARSED_ARGUMENTS}) | ||
| # Note we cannot use ROOT_EXECUTABLE without user-specified set of LIBRARIES to link with. | ||
| # The test suites should choose this in their specific CMakeLists.txt file. | ||
| # FIXME: For better coherence we could restrict the libraries the test suite could link | ||
| # against. For example, tests in Core should link only against libCore. This could be tricky | ||
| # to implement because some ROOT components create more than one library. | ||
| ROOT_EXECUTABLE(${test_suite} ${source_files} LIBRARIES ${ARG_LIBRARIES}) | ||
| target_link_libraries(${test_suite} gtest gtest_main gmock gmock_main) | ||
| ROOT_ADD_TEST(gtest-${test_suite} COMMAND ${test_suite}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is missing some environment: is what I pass to ROOT_ADD_TEST in roottest/cmake/modules/RootCTestMacros.cmake's
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I am missing context but it seems this is out of the scope of this PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed for runing the tests without setting thisroot.sh before. I.e. no, AFAIK this is a prerequisite.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, this was resolved internally. There was something to check, outside of this PR. |
||
| endfunction() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # FIXME: The tests in core should require only libCore. OTOH, TQObjectTests uses the interpreter to register the class. | ||
| # This means that if we run make CoreBaseTests the executable wouldn't be runnable because it requires libCling and | ||
| # onepcm targets to be built. | ||
| set (link_libs Core) | ||
|
|
||
| ROOT_ADD_GTEST(CoreBaseTests | ||
| TNamedTests.cxx | ||
| TQObjectTests.cxx | ||
| LIBRARIES ${link_libs} | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #include "gtest/gtest.h" | ||
| #include "gmock/gmock.h" | ||
|
|
||
| #include "TNamed.h" | ||
|
|
||
| TEST(TNamed, Sanity) | ||
| { | ||
| TNamed n("Name", "Title"); | ||
| EXPECT_STREQ("Name", n.GetName()); | ||
| EXPECT_STREQ("Title", n.GetTitle()); | ||
| } |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that
LIBRARIES <lib1> <lib2>or how does that work? Could you clarify in the comment/doc?