summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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