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") make("install")
install_tree("doc", prefix.share.doc) 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") @run_after("install")
def cache_test_sources(self): def cache_test_sources(self):
"""Copy test files after the package is installed for test()."""
if self.spec.satisfies("@master"): if self.spec.satisfies("@master"):
self.cache_extra_test_sources(["tests"]) self.cache_extra_test_sources(["tests"])
def test(self): def test(self):
if self.spec.satisfies("@master"): """Perform stand-alone/smoke tests using installed package."""
exe_name = self.spec["python"].command.path if not self.spec.satisfies("@master"):
test_name = join_path( print('Skipping: Tests are only available for the master branch')
self.install_test_root, "tests", "regression_test", "test.py" return
)
bin_name = join_path(self.prefix.bin, "spdyn") test_name = join_path(
opts = [ self.cached_tests_work_dir, "regression_test", "test.py"
test_name, )
self.spec["mpi"].prefix.bin.mpirun + " -np 8 " + bin_name, bin_name = join_path(self.prefix.bin, "spdyn")
] opts = [
env["OMP_NUM_THREADS"] = "1" test_name,
self.run_test(exe_name, options=opts, expected="Passed 53 / 53") 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
)