27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
"""Row 325 old-project-key mutant; run only in Sage's test slot."""
|
|
import hashlib
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
root = Path(__file__).resolve().parents[4]
|
|
source = root / 'docs/guides/case1-business.mosaic-stack.json'
|
|
fixed = source.read_bytes()
|
|
needle = b'"projects": {\n "stack": {'
|
|
assert fixed.count(needle) == 1
|
|
try:
|
|
source.write_bytes(fixed.replace(needle, b'"projects": {\n "mosaic-stack": {'))
|
|
result = subprocess.run([
|
|
'timeout', '-k', '10', '90', 'node', '--test', '--test-reporter=tap',
|
|
'--test-name-pattern=row 325: the Case 1 project',
|
|
'packages/business/tests/case1-project-key.test.mjs',
|
|
], cwd=root, env=os.environ, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
Path(__file__).with_suffix('.log').write_text(result.stdout)
|
|
print(f'old-key mutant: exit {result.returncode}', flush=True)
|
|
assert result.returncode == 1, result.stdout
|
|
assert '# fail 1\n' in result.stdout and 'mosaic-stack' in result.stdout, result.stdout
|
|
finally:
|
|
source.write_bytes(fixed)
|
|
assert source.read_bytes() == fixed
|
|
print('restored sha256 ' + hashlib.sha256(fixed).hexdigest(), flush=True)
|