genesis: update stand-alone tests to use test stage work directory (#24193)

This commit is contained in:
Tamara Dahlgren 2021-07-26 01:24:29 -07:00 committed by GitHub
parent 9edd281044
commit cb87271a01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,21 +105,37 @@ def install(self, spec, prefix):
make("install")
install_tree("doc", prefix.share.doc)
@property
def cached_tests_work_dir(self):
"""The working directory for cached test sources."""
return join_path(self.test_suite.current_test_cache_dir,
"tests")
@run_after("install")
def cache_test_sources(self):
"""Copy test files after the package is installed for test()."""
if self.spec.satisfies("@master"):
self.cache_extra_test_sources(["tests"])
def test(self):
if self.spec.satisfies("@master"):
exe_name = self.spec["python"].command.path
test_name = join_path(
self.install_test_root, "tests", "regression_test", "test.py"
)
bin_name = join_path(self.prefix.bin, "spdyn")
opts = [
test_name,
self.spec["mpi"].prefix.bin.mpirun + " -np 8 " + bin_name,
]
env["OMP_NUM_THREADS"] = "1"
self.run_test(exe_name, options=opts, expected="Passed 53 / 53")
"""Perform stand-alone/smoke tests using installed package."""
if not self.spec.satisfies("@master"):
print('Skipping: Tests are only available for the master branch')
return
test_name = join_path(
self.cached_tests_work_dir, "regression_test", "test.py"
)
bin_name = join_path(self.prefix.bin, "spdyn")
opts = [
test_name,
self.spec["mpi"].prefix.bin.mpirun + " -np 8 " + bin_name,
]
env["OMP_NUM_THREADS"] = "1"
self.run_test(
self.spec["python"].command.path,
options=opts,
expected="Passed 53 / 53",
purpose="test: running regression test",
work_dir=self.cached_tests_work_dir
)