Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
c4f7c335
Commit
c4f7c335
authored
5 years ago
by
Marko Petric
Browse files
Options
Downloads
Patches
Plain Diff
Add import test for dd4hep python modules
parent
42debfe3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDTest/CMakeLists.txt
+7
-3
7 additions, 3 deletions
DDTest/CMakeLists.txt
DDTest/python/test_import.py
+53
-0
53 additions, 0 deletions
DDTest/python/test_import.py
with
60 additions
and
3 deletions
DDTest/CMakeLists.txt
+
7
−
3
View file @
c4f7c335
...
...
@@ -45,6 +45,10 @@ foreach(TEST_NAME
set_tests_properties
(
t_
${
TEST_NAME
}
PROPERTIES FAIL_REGULAR_EXPRESSION
"TEST_FAILED"
)
endforeach
()
ADD_TEST
(
t_test_python_import
"
${
CMAKE_INSTALL_PREFIX
}
/bin/run_test.sh"
pytest
${
PROJECT_SOURCE_DIR
}
/DDTest/python/test_import.py
)
SET_TESTS_PROPERTIES
(
t_test_python_import PROPERTIES FAIL_REGULAR_EXPRESSION
"Exception;EXCEPTION;ERROR;Error"
)
if
(
DD4HEP_USE_GEANT4
)
foreach
(
TEST_NAME
test_EventReaders
...
...
@@ -58,10 +62,10 @@ if (DD4HEP_USE_GEANT4)
set_tests_properties
(
t_
${
TEST_NAME
}
PROPERTIES FAIL_REGULAR_EXPRESSION
"TEST_FAILED"
)
endforeach
(
TEST_NAME
)
ADD_TEST
(
test_ddsim
"
${
CMAKE_INSTALL_PREFIX
}
/bin/run_test.sh"
ADD_TEST
(
t_
test_ddsim
"
${
CMAKE_INSTALL_PREFIX
}
/bin/run_test.sh"
ddsim --compactFile=
${
CMAKE_INSTALL_PREFIX
}
/DDDetectors/compact/SiD.xml --runType=batch -G -N=2 --outputFile=testSid.root
--part.userParticleHandler=
)
SET_TESTS_PROPERTIES
(
test_ddsim PROPERTIES FAIL_REGULAR_EXPRESSION
"Exception;EXCEPTION;ERROR;Error"
)
SET_TESTS_PROPERTIES
(
t_
test_ddsim PROPERTIES FAIL_REGULAR_EXPRESSION
"Exception;EXCEPTION;ERROR;Error"
)
endif
()
install
(
DIRECTORY include/DD4hep DESTINATION include
)
\ No newline at end of file
install
(
DIRECTORY include/DD4hep DESTINATION include
)
This diff is collapsed.
Click to expand it.
DDTest/python/test_import.py
0 → 100644
+
53
−
0
View file @
c4f7c335
#!/usr/bin/env python
"""
Some imports to make sure that the DD4hep environment is complete
"""
from
__future__
import
absolute_import
,
unicode_literals
,
print_function
import
traceback
import
warnings
import
pytest
parametrize
=
pytest
.
mark
.
parametrize
moduleNames
=
[
'
DDDigi
'
,
'
DDG4
'
,
'
dd4hep
'
,
'
DDRec
'
,
]
# List here the modules that are allowed to Fail.
# Ideally, this should always be empty...
ALLOWED_TO_FAIL
=
[]
# List of modules that need graphic libraries.
# When failing, these tests are just marked as skipped with a warning
GRAPHIC_MODULES
=
[]
@parametrize
(
'
moduleName
'
,
moduleNames
)
def
test_module
(
moduleName
):
"""
Try to import a module from DD4hep.
Modules that are in the ALLOWED_TO_FAIL list are shown as skipped and generate a warning
Modules that require graphic libraries (GRAPHIC_MODULES) are skipped on container
"""
try
:
__import__
(
moduleName
)
# Test whether it is correctly imported from DD4hep
except
ImportError
as
e
:
msg
=
"
could not import %s: %s
"
%
(
moduleName
,
repr
(
e
))
print
(
traceback
.
print_exc
())
if
moduleName
in
ALLOWED_TO_FAIL
:
warnings
.
warn
(
msg
)
pytest
.
skip
(
"
WARN:
"
+
msg
)
elif
moduleName
in
GRAPHIC_MODULES
:
warnings
.
warn
(
msg
+
"
(Possibly due to system graphic libraries not present)
"
)
pytest
.
skip
(
"
WARN:
"
+
msg
+
"
(Possibly due to system graphic libraries not present)
"
)
else
:
pytest
.
fail
(
"
ERROR:
"
+
msg
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment