summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNathan Hanford <8302958+nhanford@users.noreply.github.com>2021-11-22 20:49:41 -0800
committerGitHub <noreply@github.com>2021-11-22 21:49:41 -0700
commit2104f1273a32669472316a59a33b6ec4bb2d6d70 (patch)
treeb3958cd8cc4ce61d23d11a316d2cb0f8ee161cf2 /lib
parentfeb66cba011446da25b90982de7a29d869d9c53e (diff)
downloadspack-2104f1273a32669472316a59a33b6ec4bb2d6d70.tar.gz
spack-2104f1273a32669472316a59a33b6ec4bb2d6d70.tar.bz2
spack-2104f1273a32669472316a59a33b6ec4bb2d6d70.tar.xz
spack-2104f1273a32669472316a59a33b6ec4bb2d6d70.zip
bugfix: Allow legacy tests to be read after hash break (#26078)
* added a test case Co-authored-by: Nathan Hanford <hanford1@llnl.gov>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/install_test.py5
-rw-r--r--lib/spack/spack/test/cmd/test.py29
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py
index 07644f5cc5..a8fe0f4024 100644
--- a/lib/spack/spack/install_test.py
+++ b/lib/spack/spack/install_test.py
@@ -287,7 +287,10 @@ class TestSuite(object):
try:
with open(filename, 'r') as f:
data = sjson.load(f)
- return TestSuite.from_dict(data)
+ test_suite = TestSuite.from_dict(data)
+ content_hash = os.path.basename(os.path.dirname(filename))
+ test_suite._hash = content_hash
+ return test_suite
except Exception as e:
tty.debug(e)
raise sjson.SpackJSONError("error parsing JSON TestSuite:", str(e))
diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py
index 9ee117b281..f82f767bc8 100644
--- a/lib/spack/spack/test/cmd/test.py
+++ b/lib/spack/spack/test/cmd/test.py
@@ -11,6 +11,7 @@ import pytest
import spack.cmd.install
import spack.config
import spack.package
+import spack.store
from spack.cmd.test import has_test_method
from spack.main import SpackCommand
@@ -231,3 +232,31 @@ def test_has_test_method_fails(capsys):
captured = capsys.readouterr()[1]
assert 'is not a class' in captured
+
+
+def test_hash_change(mock_test_stage, mock_packages, mock_archive, mock_fetch,
+ install_mockery_mutable_config):
+ """Ensure output printed from pkgs is captured by output redirection."""
+ install('printing-package')
+ spack_test('run', '--alias', 'printpkg', 'printing-package')
+
+ stage_files = os.listdir(mock_test_stage)
+
+ # Grab test stage directory contents
+ testdir = os.path.join(mock_test_stage, stage_files[0])
+
+ outfile = os.path.join(testdir, 'test_suite.lock')
+ with open(outfile, 'r') as f:
+ output = f.read()
+ changed_hash = output.replace(
+ spack.store.db.query('printing-package')[0].full_hash(),
+ 'fakehash492ucwhwvzhxfbmcc45x49ha')
+ with open(outfile, 'w') as f:
+ f.write(changed_hash)
+
+ # The find command should show the contents
+ find_output = spack_test('find')
+ assert 'printpkg' in find_output
+ # The results should be obtainable
+ results_output = spack_test('results')
+ assert 'PASSED' in results_output