tests/slepc: convert to new stand-alone test process (#38653)

This commit is contained in:
Tamara Dahlgren 2023-06-30 13:34:42 -07:00 committed by GitHub
parent 86d2399c76
commit 131acbdacc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,48 +183,36 @@ def archive_files(self):
join_path(self.stage.source_path, "make.log"), join_path(self.stage.source_path, "make.log"),
] ]
def run_hello_test(self): def test_hello(self):
"""Run stand alone test: hello""" """build and run hello"""
test_dir = self.test_suite.current_test_data_dir test_dir = self.test_suite.current_test_data_dir
if not os.path.exists(test_dir): if not os.path.exists(test_dir):
print("Skipping slepc test") raise SkipTest(f"Test data directory ({test_dir}) is missing")
return
exe = "hello" test_exe = "hello"
cc_exe = os.environ["CC"] options = [
f"-I{self.prefix.include}",
"-L",
self.prefix.lib,
"-l",
"slepc",
"-L",
self.spec["petsc"].prefix.lib,
"-l",
"petsc",
"-L",
self.spec["mpi"].prefix.lib,
"-l",
"mpi",
"-o",
test_exe,
join_path(test_dir, f"{test_exe}.c"),
]
self.run_test( cc = which(os.environ["CC"])
exe=cc_exe, with working_dir(test_dir):
options=[ cc(*options)
"-I{0}".format(self.prefix.include),
"-L",
self.prefix.lib,
"-l",
"slepc",
"-L",
self.spec["petsc"].prefix.lib,
"-l",
"petsc",
"-L",
self.spec["mpi"].prefix.lib,
"-l",
"mpi",
"-o",
exe,
join_path(test_dir, "hello.c"),
],
purpose="test: compile {0} example".format(exe),
work_dir=test_dir,
)
self.run_test( hello = which(test_exe)
exe=exe, out = hello(output=str.split, error=str.split)
options=[], assert "Hello world" in out
expected=["Hello world"],
purpose="test: run {0} example".format(exe),
work_dir=test_dir,
)
def test(self):
self.run_hello_test()