summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorAcriusWinter <152348900+AcriusWinter@users.noreply.github.com>2024-07-09 19:02:36 -0700
committerGitHub <noreply@github.com>2024-07-09 19:02:36 -0700
commitb237ee3689a1037eff86bc2504a7c055f1dd80e4 (patch)
tree340fbc91087d364517beecc2789758487a00b54b /var
parentaa911eca40e565243c43c789e8f04155e37a4785 (diff)
downloadspack-b237ee3689a1037eff86bc2504a7c055f1dd80e4.tar.gz
spack-b237ee3689a1037eff86bc2504a7c055f1dd80e4.tar.bz2
spack-b237ee3689a1037eff86bc2504a7c055f1dd80e4.tar.xz
spack-b237ee3689a1037eff86bc2504a7c055f1dd80e4.zip
octopus: old to new test API (#45143)
* octopus: old to new test API * Minor simplifications and cleanup --------- Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/octopus/package.py88
1 files changed, 34 insertions, 54 deletions
diff --git a/var/spack/repos/builtin/packages/octopus/package.py b/var/spack/repos/builtin/packages/octopus/package.py
index 4abe82b304..8dd4dc0439 100644
--- a/var/spack/repos/builtin/packages/octopus/package.py
+++ b/var/spack/repos/builtin/packages/octopus/package.py
@@ -316,54 +316,38 @@ class Octopus(AutotoolsPackage, CudaPackage):
@run_after("install")
@on_package_attributes(run_tests=True)
- def smoke_tests_after_install(self):
+ def benchmark_tests_after_install(self):
"""Function stub to run tests after install if desired
(for example through `spack install --test=root octopus`)
"""
- self.smoke_tests()
+ self.test_version()
+ self.test_example()
+ self.test_he()
- def test(self):
- """Entry point for smoke tests run through `spack test run octopus`."""
- self.smoke_tests()
-
- def smoke_tests(self):
- """Actual smoke tests for Octopus."""
- #
- # run "octopus --version"
- #
- exe = join_path(self.spec.prefix.bin, "octopus")
- options = ["--version"]
- purpose = "Check octopus can execute (--version)"
+ def test_version(self):
+ """Check octopus can execute (--version)"""
# Example output:
#
# spack-v0.17.2$ octopus --version
# octopus 11.3 (git commit )
- expected = ["octopus "]
-
- self.run_test(
- exe,
- options=options,
- expected=expected,
- status=[0],
- installed=False,
- purpose=purpose,
- skip_missing=False,
- )
+
+ exe = which(self.spec.prefix.bin.octopus)
+ out = exe("--version", output=str.split, error=str.split)
+ assert "octopus " in out
+
+ def test_recipe(self):
+ """run recipe example"""
# Octopus expects a file with name `inp` in the current working
# directory to read configuration information for a simulation run from
# that file. We copy the relevant configuration file in a dedicated
- # subfolder for each test.
+ # subfolder for the test.
#
# As we like to be able to run these tests also with the
# `spack install --test=root` command, we cannot rely on
# self.test_suite.current_test_data_dir, and need to copy the test
# input files manually (see below).
- #
- # run recipe example
- #
-
expected = [
"Running octopus",
"CalculationMode = recipe",
@@ -371,24 +355,27 @@ class Octopus(AutotoolsPackage, CudaPackage):
"recipe leads to an edible dish, " 'for it is clearly "system-dependent".',
"Calculation ended on",
]
- options = []
- purpose = "Run Octopus recipe example"
+
with working_dir("example-recipe", create=True):
print("Current working directory (in example-recipe)")
fs.copy(join_path(os.path.dirname(__file__), "test", "recipe.inp"), "inp")
- self.run_test(
- exe,
- options=options,
- expected=expected,
- status=[0],
- installed=False,
- purpose=purpose,
- skip_missing=False,
- )
+ exe = which(self.spec.prefix.bin.octopus)
+ out = exe(output=str.split, error=str.split)
+ check_outputs(expected, out)
+ def test_he(self):
+ """run He example"""
+
+ # Octopus expects a file with name `inp` in the current working
+ # directory to read configuration information for a simulation run from
+ # that file. We copy the relevant configuration file in a dedicated
+ # subfolder for the test.
#
- # run He example
- #
+ # As we like to be able to run these tests also with the
+ # `spack install --test=root` command, we cannot rely on
+ # self.test_suite.current_test_data_dir, and need to copy the test
+ # input files manually (see below).
+
expected = [
"Running octopus",
"Info: Starting calculation mode.",
@@ -397,17 +384,10 @@ class Octopus(AutotoolsPackage, CudaPackage):
"Info: Writing states.",
"Calculation ended on",
]
- options = []
- purpose = "Run tiny calculation for He"
+
with working_dir("example-he", create=True):
print("Current working directory (in example-he)")
fs.copy(join_path(os.path.dirname(__file__), "test", "he.inp"), "inp")
- self.run_test(
- exe,
- options=options,
- expected=expected,
- status=[0],
- installed=False,
- purpose=purpose,
- skip_missing=False,
- )
+ exe = which(self.spec.prefix.bin.octopus)
+ out = exe(output=str.split, error=str.split)
+ check_outputs(expected, out)