Skip to content

Commit 62c17dc

Browse files
committed
[build] Add post-install test for Python bindings
1 parent cd7fd86 commit 62c17dc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/PostInstall/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,22 @@ 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.8 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+
)
2139
endif()

0 commit comments

Comments
 (0)