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"),
]
def run_hello_test(self):
"""Run stand alone test: hello"""
def test_hello(self):
"""build and run hello"""
test_dir = self.test_suite.current_test_data_dir
if not os.path.exists(test_dir):
print("Skipping slepc test")
return
raise SkipTest(f"Test data directory ({test_dir}) is missing")
exe = "hello"
cc_exe = os.environ["CC"]
test_exe = "hello"
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(
exe=cc_exe,
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,
)
cc = which(os.environ["CC"])
with working_dir(test_dir):
cc(*options)
self.run_test(
exe=exe,
options=[],
expected=["Hello world"],
purpose="test: run {0} example".format(exe),
work_dir=test_dir,
)
def test(self):
self.run_hello_test()
hello = which(test_exe)
out = hello(output=str.split, error=str.split)
assert "Hello world" in out