Fix TEST_REWRITE

This commit is contained in:
jpic 2020-01-31 21:50:41 +01:00
parent 8ae4687cf2
commit 7e9af1fe35
2 changed files with 5 additions and 5 deletions

View File

@ -35,9 +35,7 @@ class BuildScript(Script):
if cmd.startswith('sudo '):
_cmd = _cmd[5:]
if '\n' in _cmd.strip():
# 1337: multiline supports, kindof breaks sudo but really fixes cd
_cmd = ' '.join(['bash -eux <<__EOF\n', _cmd, '\n__EOF'])
_cmd = ' '.join(['bash -eux <<__EOF\n', _cmd.strip(), '\n__EOF'])
if cmd.startswith('sudo '):
return f'buildah run --user root $ctr -- {_cmd}'

View File

@ -27,12 +27,14 @@ def script_test(name, *visitors):
f'test_{name}.sh',
)
if os.getenv('TEST_REWRITE') and os.path.exists(path):
os.unlink(path)
if not os.path.exists(path):
with open(path, 'w+') as f:
f.write(result)
raise Exception(f'Fixture created test_{name}.sh')
elif os.getenv('TEST_REWRITE') and os.path.exists(path):
os.unlink(path)
with open(path, 'r') as f:
expected = f.read()
result = difflib.unified_diff(