bugfix: Allow legacy tests to be read after hash break (#26078)
* added a test case Co-authored-by: Nathan Hanford <hanford1@llnl.gov>
This commit is contained in:
parent
feb66cba01
commit
2104f1273a
@ -287,7 +287,10 @@ def from_file(filename):
|
||||
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))
|
||||
|
@ -11,6 +11,7 @@
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user