summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--var/spack/repos/builtin/packages/hdf/package.py149
1 files changed, 73 insertions, 76 deletions
diff --git a/var/spack/repos/builtin/packages/hdf/package.py b/var/spack/repos/builtin/packages/hdf/package.py
index e4f44dbb3a..d087ea05ec 100644
--- a/var/spack/repos/builtin/packages/hdf/package.py
+++ b/var/spack/repos/builtin/packages/hdf/package.py
@@ -191,7 +191,7 @@ class Hdf(AutotoolsPackage):
with working_dir(self.build_directory):
make("check", parallel=False)
- extra_install_tests = "hdf/util/testfiles"
+ extra_install_tests = join_path("hdf", "util", "testfiles")
@property
def cached_tests_work_dir(self):
@@ -204,81 +204,78 @@ class Hdf(AutotoolsPackage):
install test subdirectory for use during `spack test run`."""
self.cache_extra_test_sources(self.extra_install_tests)
- def _test_check_versions(self):
- """Perform version checks on selected installed package binaries."""
- spec_vers_str = "Version {0}".format(self.spec.version.up_to(2))
+ def _check_version_match(self, exe):
+ """Ensure exe version check yields spec version."""
+ path = join_path(self.prefix.bin, exe)
+ if not os.path.isfile(path):
+ raise SkipTest(f"{exe} is not installed")
+
+ exe = which(path)
+ out = exe("-V", output=str.split, error=str.split)
+ vers = f"Version {self.spec.version.up_to(2)}"
+ assert vers in out
+
+ def test_hdfimport_version(self):
+ """ensure hdfimport version matches spec"""
+ self._check_version_match("hdfimport")
+
+ def test_hrepack_version(self):
+ """ensure hrepack version matches spec"""
+ self._check_version_match("hrepack")
+
+ def test_ncdump_version(self):
+ """ensure ncdump version matches spec"""
+ self._check_version_match("hrepack")
+
+ def test_ncgen_version(self):
+ """ensure ncgen version matches spec"""
+ self._check_version_match("ncgen")
+
+ def test_gif_converters(self):
+ """test image conversion sequence and diff"""
+ base_name = "storm110"
+ storm_fn = join_path(self.cached_tests_work_dir, f"{base_name}.hdf")
+ if not os.path.exists(storm_fn):
+ raise SkipTest(f"Missing test image {storm_fn}")
+
+ if not os.path.exists(self.prefix.bin.hdf2gif) or not os.path.exists(
+ self.prefix.bin.gif2hdf
+ ):
+ raise SkipTest("Missing one or more installed: 'hdf2gif', 'gif2hdf'")
+
+ gif_fn = f"{base_name}.gif"
+ new_hdf_fn = f"{base_name}gif.hdf"
+
+ with test_part(
+ self, "test_gif_converters_hdf2gif", purpose=f"convert {base_name} hdf-to-gif"
+ ):
+ hdf2gif = which(self.prefix.bin.hdf2gif)
+ hdf2gif(storm_fn, gif_fn)
+
+ with test_part(
+ self, "test_gif_converters_gif2hdf", purpose=f"convert {base_name} gif-to-hdf"
+ ):
+ gif2hdf = which(self.prefix.bin.gif2hdf)
+ gif2hdf(gif_fn, new_hdf_fn)
+
+ with test_part(
+ self, "test_gif_converters_hdiff", purpose=f"compare new and orig {base_name} hdf"
+ ):
+ hdiff = which(self.prefix.bin.hdiff)
+ hdiff(new_hdf_fn, storm_fn)
+
+ def test_list(self):
+ """compare low-level HDF file information to expected"""
+ base_name = "storm110"
+ if not os.path.isfile(self.prefix.bin.hdfls):
+ raise SkipTest("hdfls is not installed")
- exes = ["hdfimport", "hrepack", "ncdump", "ncgen"]
- for exe in exes:
- reason = "test: ensuring version of {0} is {1}".format(exe, spec_vers_str)
- self.run_test(
- exe, ["-V"], spec_vers_str, installed=True, purpose=reason, skip_missing=True
- )
-
- def _test_gif_converters(self):
- """This test performs an image conversion sequence and diff."""
- work_dir = "."
- storm_fn = os.path.join(self.cached_tests_work_dir, "storm110.hdf")
-
- gif_fn = "storm110.gif"
- new_hdf_fn = "storm110gif.hdf"
-
- # Convert a test HDF file to a gif
- self.run_test(
- "hdf2gif",
- [storm_fn, gif_fn],
- "",
- installed=True,
- purpose="test: hdf-to-gif",
- work_dir=work_dir,
- )
-
- # Convert the gif to an HDF file
- self.run_test(
- "gif2hdf",
- [gif_fn, new_hdf_fn],
- "",
- installed=True,
- purpose="test: gif-to-hdf",
- work_dir=work_dir,
- )
-
- # Compare the original and new HDF files
- self.run_test(
- "hdiff",
- [new_hdf_fn, storm_fn],
- "",
- installed=True,
- purpose="test: compare orig to new hdf",
- work_dir=work_dir,
- )
-
- def _test_list(self):
- """This test compares low-level HDF file information to expected."""
- storm_fn = os.path.join(self.cached_tests_work_dir, "storm110.hdf")
test_data_dir = self.test_suite.current_test_data_dir
- work_dir = "."
-
- reason = "test: checking hdfls output"
- details_file = os.path.join(test_data_dir, "storm110.out")
+ details_file = os.path.join(test_data_dir, f"{base_name}.out")
expected = get_escaped_text_output(details_file)
- self.run_test(
- "hdfls",
- [storm_fn],
- expected,
- installed=True,
- purpose=reason,
- skip_missing=True,
- work_dir=work_dir,
- )
-
- def test(self):
- """Perform smoke tests on the installed package."""
- # Simple version check tests on subset of known binaries that respond
- self._test_check_versions()
-
- # Run gif converter sequence test
- self._test_gif_converters()
-
- # Run hdfls output
- self._test_list()
+
+ storm_fn = os.path.join(self.cached_tests_work_dir, f"{base_name}.hdf")
+
+ hdfls = which(self.prefix.bin.hdfls)
+ out = hdfls(storm_fn, output=str.split, error=str.split)
+ check_outputs(expected, out)