Skip to content

Commit 807e1d2

Browse files
authored
[test] guard python install tests, run only if pyroot found
as suggested by guitargeek
1 parent 704a0e0 commit 807e1d2

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

test/PostInstall/CMakeLists.txt

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,23 @@ if(BUILD_TESTING)
1818
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
1919
set_tests_properties(run-hsimple PROPERTIES FIXTURES_SETUP HSIMPLE)
2020
set_tests_properties(read-hsimple PROPERTIES FIXTURES_REQUIRED HSIMPLE)
21-
22-
find_package(Python3 3.9 REQUIRED)
23-
# Need to duplicate the import ROOT test because the PASS_REGULAR_EXPRESSION
24-
# property will disable checking the exit code of the test so import ROOT
25-
# might fail but ctest would not report it
26-
add_test(NAME python-import-root
27-
COMMAND ${Python3_EXECUTABLE} -c "import ROOT"
28-
)
29-
set_tests_properties(python-import-root
30-
PROPERTIES ENVIRONMENT PYTHONPATH=${ROOT_LIBRARY_DIR}
31-
)
32-
add_test(NAME python-create-histo
33-
COMMAND ${Python3_EXECUTABLE} -c "import ROOT; h = ROOT.TH1D(\"myHistoName\",\"h\", 100, -5, 5); print(h.GetName());"
34-
)
35-
set_tests_properties(python-create-histo
36-
PROPERTIES ENVIRONMENT PYTHONPATH=${ROOT_LIBRARY_DIR}
37-
PASS_REGULAR_EXPRESSION "myHistoName"
38-
)
21+
if(ROOT_pyroot_FOUND)
22+
find_package(Python3 3.9 REQUIRED)
23+
# Need to duplicate the import ROOT test because the PASS_REGULAR_EXPRESSION
24+
# property will disable checking the exit code of the test so import ROOT
25+
# might fail but ctest would not report it
26+
add_test(NAME python-import-root
27+
COMMAND ${Python3_EXECUTABLE} -c "import ROOT"
28+
)
29+
set_tests_properties(python-import-root
30+
PROPERTIES ENVIRONMENT PYTHONPATH=${ROOT_LIBRARY_DIR}
31+
)
32+
add_test(NAME python-create-histo
33+
COMMAND ${Python3_EXECUTABLE} -c "import ROOT; h = ROOT.TH1D(\"myHistoName\",\"h\", 100, -5, 5); print(h.GetName());"
34+
)
35+
set_tests_properties(python-create-histo
36+
PROPERTIES ENVIRONMENT PYTHONPATH=${ROOT_LIBRARY_DIR}
37+
PASS_REGULAR_EXPRESSION "myHistoName"
38+
)
39+
endif()
3940
endif()

0 commit comments

Comments
 (0)