tests/oommf: convert to new stand-alone test process (#38009)
* oommf: convert to new stand-alone test process * oommf: Switch build-time tests to documented approach
This commit is contained in:
parent
01c1d334ae
commit
0aa4b4d990
1 changed files with 45 additions and 76 deletions
|
@ -39,13 +39,6 @@ class Oommf(Package):
|
||||||
# default URL for versions
|
# default URL for versions
|
||||||
url = "https://github.com/fangohr/oommf/archive/refs/tags/20a1_20180930_ext.tar.gz"
|
url = "https://github.com/fangohr/oommf/archive/refs/tags/20a1_20180930_ext.tar.gz"
|
||||||
|
|
||||||
#: post-install phase methods used to check the installation
|
|
||||||
install_time_test_callbacks = [
|
|
||||||
"check_install_version",
|
|
||||||
"check_install_platform",
|
|
||||||
"check_install_stdprob3",
|
|
||||||
]
|
|
||||||
|
|
||||||
maintainers("fangohr")
|
maintainers("fangohr")
|
||||||
|
|
||||||
version(
|
version(
|
||||||
|
@ -160,7 +153,7 @@ def oommf_tcl_path(self):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tclsh(self):
|
def tclsh(self):
|
||||||
return Executable(join_path(self.spec["tcl"].prefix.bin, "tclsh"))
|
return Executable(self.spec["tcl"].prefix.bin.tclsh)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def test_env(self):
|
def test_env(self):
|
||||||
|
@ -210,86 +203,62 @@ def setup_run_environment(self, env):
|
||||||
# set OOMMFTCL so ubermag / oommf can find oommf
|
# set OOMMFTCL so ubermag / oommf can find oommf
|
||||||
env.set("OOMMFTCL", join_path(oommfdir, "oommf.tcl"))
|
env.set("OOMMFTCL", join_path(oommfdir, "oommf.tcl"))
|
||||||
|
|
||||||
def _check_install_oommf_command(self, oommf_args):
|
@run_after("install")
|
||||||
"Given a list of arguments for oommf.tcl, execute those."
|
@on_package_attributes(run_tests=True)
|
||||||
print("Testing oommf.tcl with arguments: " + str(oommf_args))
|
def check_install_version(self):
|
||||||
|
print("checking oommf.tcl can execute (+version)")
|
||||||
|
self.test_version()
|
||||||
|
|
||||||
|
@run_after("install")
|
||||||
|
@on_package_attributes(run_tests=True)
|
||||||
|
def check_install_platform(self):
|
||||||
|
print("checking oommf.tcl can execute (+platform)")
|
||||||
|
self.test_platform()
|
||||||
|
|
||||||
|
@run_after("install")
|
||||||
|
@on_package_attributes(run_tests=True)
|
||||||
|
def check_install_stdprob3(self):
|
||||||
|
print("Testing oommf.tcl standard problem 3")
|
||||||
|
self.test_stdprob3()
|
||||||
|
|
||||||
|
def test_version(self):
|
||||||
|
"""check oommf.tcl can execute (+version)"""
|
||||||
|
out = self.tclsh(
|
||||||
|
self.oommf_tcl_path, "+version", output=str.split, error=str.split, env=self.test_env
|
||||||
|
)
|
||||||
|
assert "info:" in out
|
||||||
|
|
||||||
|
def test_platform(self):
|
||||||
|
"""Check oommf.tcl can execute (+platform)"""
|
||||||
test_env = self.test_env
|
test_env = self.test_env
|
||||||
|
|
||||||
# the "+platform" test needs the following environment variable:
|
# the "+platform" test needs the following environment variable:
|
||||||
if oommf_args == ["+platform"]:
|
|
||||||
test_env["PATH"] = os.environ["PATH"]
|
test_env["PATH"] = os.environ["PATH"]
|
||||||
|
|
||||||
output = self.tclsh(
|
out = self.tclsh(
|
||||||
self.oommf_tcl_path, *oommf_args, output=str.split, error=str.split, env=test_env
|
self.oommf_tcl_path, "+platform", output=str.split, error=str.split, env=test_env
|
||||||
)
|
|
||||||
|
|
||||||
print("output received from oommf is %s" % output)
|
|
||||||
|
|
||||||
def check_install_version(self):
|
|
||||||
self._check_install_oommf_command(["+version"])
|
|
||||||
|
|
||||||
def check_install_platform(self):
|
|
||||||
self._check_install_oommf_command(["+platform"])
|
|
||||||
|
|
||||||
def check_install_stdprob3(self):
|
|
||||||
oommf_examples = join_path(self.spec.prefix.usr.bin, "oommf/app/oxs/examples")
|
|
||||||
task = join_path(oommf_examples, "stdprob3.mif")
|
|
||||||
self._check_install_oommf_command(["boxsi", "+fg", "-kill", "all", task])
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
"""Run these smoke tests when requested explicitly"""
|
|
||||||
|
|
||||||
# run "oommf +version"
|
|
||||||
spec = self.spec
|
|
||||||
exe = join_path(spec["tcl"].prefix.bin, "tclsh")
|
|
||||||
oommf_tcl_path = join_path(spec.prefix.bin, "oommf.tcl")
|
|
||||||
options = [oommf_tcl_path, "+version"]
|
|
||||||
purpose = "Check oommf.tcl can execute (+version)"
|
|
||||||
expected = ["info:"]
|
|
||||||
|
|
||||||
self.run_test(
|
|
||||||
exe,
|
|
||||||
options=options,
|
|
||||||
expected=expected,
|
|
||||||
status=[0],
|
|
||||||
installed=False,
|
|
||||||
purpose=purpose,
|
|
||||||
skip_missing=False,
|
|
||||||
work_dir=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
# run "oommf +platform"
|
|
||||||
options = [oommf_tcl_path, "+platform"]
|
|
||||||
purpose = "Check oommf.tcl can execute (+platform)"
|
|
||||||
expected = ["OOMMF threads", "OOMMF release", "OOMMF API index", "Temp file directory"]
|
|
||||||
self.run_test(
|
|
||||||
exe,
|
|
||||||
options=options,
|
|
||||||
expected=expected,
|
|
||||||
status=[0],
|
|
||||||
installed=False,
|
|
||||||
purpose=purpose,
|
|
||||||
skip_missing=False,
|
|
||||||
work_dir=None,
|
|
||||||
)
|
)
|
||||||
|
expected = [r"OOMMF threads", r"OOMMF release", r"OOMMF API index", r"Temp file directory"]
|
||||||
|
check_outputs(expected, out)
|
||||||
|
|
||||||
|
def test_stdprob3(self):
|
||||||
|
"""check standard problem 3"""
|
||||||
# run standard problem 3 with oommf (about 30 seconds runtime)
|
# run standard problem 3 with oommf (about 30 seconds runtime)
|
||||||
purpose = "Testing oommf.tcl standard problem 3"
|
|
||||||
print(purpose)
|
|
||||||
|
|
||||||
oommf_examples = join_path(spec.prefix.usr.bin, "oommf/app/oxs/examples")
|
oommf_examples = self.spec.prefix.usr.bin.oommf.app.oxs.examples
|
||||||
task = join_path(oommf_examples, "stdprob3.mif")
|
task = join_path(oommf_examples, "stdprob3.mif")
|
||||||
|
|
||||||
options = [oommf_tcl_path, "boxsi", "+fg", task, "-kill", "all"]
|
out = self.tclsh(
|
||||||
|
self.oommf_tcl_path,
|
||||||
expected = ['End "stdprob3.mif"', "Mesh geometry: 32 x 32 x 32 = 32 768 cells"]
|
"boxsi",
|
||||||
self.run_test(
|
"+fg",
|
||||||
exe,
|
"-kill",
|
||||||
options=options,
|
"all",
|
||||||
expected=expected,
|
task,
|
||||||
status=[0],
|
output=str.split,
|
||||||
installed=False,
|
error=str.split,
|
||||||
purpose=purpose,
|
env=self.test_env,
|
||||||
skip_missing=False,
|
|
||||||
work_dir=None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
expected = [r'End "stdprob3.mif"', r"Mesh geometry: 32 x 32 x 32 = 32 768 cells"]
|
||||||
|
check_outputs(expected, out)
|
||||||
|
|
Loading…
Reference in a new issue