hdf: convert to new stand-alone test process (#37843)
This commit is contained in:
parent
752e02e2f2
commit
40073e7b21
@ -191,7 +191,7 @@ def check(self):
|
|||||||
with working_dir(self.build_directory):
|
with working_dir(self.build_directory):
|
||||||
make("check", parallel=False)
|
make("check", parallel=False)
|
||||||
|
|
||||||
extra_install_tests = "hdf/util/testfiles"
|
extra_install_tests = join_path("hdf", "util", "testfiles")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cached_tests_work_dir(self):
|
def cached_tests_work_dir(self):
|
||||||
@ -204,81 +204,78 @@ def setup_build_tests(self):
|
|||||||
install test subdirectory for use during `spack test run`."""
|
install test subdirectory for use during `spack test run`."""
|
||||||
self.cache_extra_test_sources(self.extra_install_tests)
|
self.cache_extra_test_sources(self.extra_install_tests)
|
||||||
|
|
||||||
def _test_check_versions(self):
|
def _check_version_match(self, exe):
|
||||||
"""Perform version checks on selected installed package binaries."""
|
"""Ensure exe version check yields spec version."""
|
||||||
spec_vers_str = "Version {0}".format(self.spec.version.up_to(2))
|
path = join_path(self.prefix.bin, exe)
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
raise SkipTest(f"{exe} is not installed")
|
||||||
|
|
||||||
exes = ["hdfimport", "hrepack", "ncdump", "ncgen"]
|
exe = which(path)
|
||||||
for exe in exes:
|
out = exe("-V", output=str.split, error=str.split)
|
||||||
reason = "test: ensuring version of {0} is {1}".format(exe, spec_vers_str)
|
vers = f"Version {self.spec.version.up_to(2)}"
|
||||||
self.run_test(
|
assert vers in out
|
||||||
exe, ["-V"], spec_vers_str, installed=True, purpose=reason, skip_missing=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def _test_gif_converters(self):
|
def test_hdfimport_version(self):
|
||||||
"""This test performs an image conversion sequence and diff."""
|
"""ensure hdfimport version matches spec"""
|
||||||
work_dir = "."
|
self._check_version_match("hdfimport")
|
||||||
storm_fn = os.path.join(self.cached_tests_work_dir, "storm110.hdf")
|
|
||||||
|
|
||||||
gif_fn = "storm110.gif"
|
def test_hrepack_version(self):
|
||||||
new_hdf_fn = "storm110gif.hdf"
|
"""ensure hrepack version matches spec"""
|
||||||
|
self._check_version_match("hrepack")
|
||||||
|
|
||||||
# Convert a test HDF file to a gif
|
def test_ncdump_version(self):
|
||||||
self.run_test(
|
"""ensure ncdump version matches spec"""
|
||||||
"hdf2gif",
|
self._check_version_match("hrepack")
|
||||||
[storm_fn, gif_fn],
|
|
||||||
"",
|
|
||||||
installed=True,
|
|
||||||
purpose="test: hdf-to-gif",
|
|
||||||
work_dir=work_dir,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convert the gif to an HDF file
|
def test_ncgen_version(self):
|
||||||
self.run_test(
|
"""ensure ncgen version matches spec"""
|
||||||
"gif2hdf",
|
self._check_version_match("ncgen")
|
||||||
[gif_fn, new_hdf_fn],
|
|
||||||
"",
|
|
||||||
installed=True,
|
|
||||||
purpose="test: gif-to-hdf",
|
|
||||||
work_dir=work_dir,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Compare the original and new HDF files
|
def test_gif_converters(self):
|
||||||
self.run_test(
|
"""test image conversion sequence and diff"""
|
||||||
"hdiff",
|
base_name = "storm110"
|
||||||
[new_hdf_fn, storm_fn],
|
storm_fn = join_path(self.cached_tests_work_dir, f"{base_name}.hdf")
|
||||||
"",
|
if not os.path.exists(storm_fn):
|
||||||
installed=True,
|
raise SkipTest(f"Missing test image {storm_fn}")
|
||||||
purpose="test: compare orig to new hdf",
|
|
||||||
work_dir=work_dir,
|
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")
|
||||||
|
|
||||||
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
|
test_data_dir = self.test_suite.current_test_data_dir
|
||||||
work_dir = "."
|
details_file = os.path.join(test_data_dir, f"{base_name}.out")
|
||||||
|
|
||||||
reason = "test: checking hdfls output"
|
|
||||||
details_file = os.path.join(test_data_dir, "storm110.out")
|
|
||||||
expected = get_escaped_text_output(details_file)
|
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):
|
storm_fn = os.path.join(self.cached_tests_work_dir, f"{base_name}.hdf")
|
||||||
"""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
|
hdfls = which(self.prefix.bin.hdfls)
|
||||||
self._test_gif_converters()
|
out = hdfls(storm_fn, output=str.split, error=str.split)
|
||||||
|
check_outputs(expected, out)
|
||||||
# Run hdfls output
|
|
||||||
self._test_list()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user