Stop successor services on native game-over and preserve escape results
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Runner rejects unsafe fixture reuse before any native/audio initialization."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
CASES=('native-end-active','native-end-preparing')
|
||||
FILES=('erri-native-end-round.json','erri-native-end-round.json.tmp','erri-native-end-round.json.bak')
|
||||
class NativeEndRunnerTests(unittest.TestCase):
|
||||
def invoke(self,profile,case,*extra):
|
||||
return subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(profile/'absent-prefix'),'--profile',str(profile),'--smoke',case,'--project','core','--rounds','2','--timeout','120',*extra],text=True,capture_output=True)
|
||||
def test_scope_rejected_before_launch(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for case in CASES:
|
||||
for args in [('--project','chat'),('--rounds','1'),('--rounds','3'),('--timeout','119')]:
|
||||
with self.subTest(case=case,args=args):
|
||||
r=self.invoke(Path(tmp),case,*args)
|
||||
self.assertNotEqual(r.returncode,0)
|
||||
self.assertIn('native-end fixtures require Core',r.stderr)
|
||||
self.assertEqual(list(Path(tmp).iterdir()),[])
|
||||
def test_existing_files_and_broken_links_are_preserved(self):
|
||||
for case in CASES:
|
||||
for name in FILES:
|
||||
for linked in (False,True):
|
||||
with self.subTest(case=case,name=name,linked=linked),tempfile.TemporaryDirectory() as tmp:
|
||||
root=Path(tmp);p=root/name
|
||||
if linked:p.symlink_to(root/'missing')
|
||||
else:p.write_bytes(b'prior evidence')
|
||||
r=self.invoke(root,case)
|
||||
self.assertNotEqual(r.returncode,0)
|
||||
self.assertIn('native-end fixture paths must not preexist',r.stderr)
|
||||
if linked:self.assertTrue(p.is_symlink())
|
||||
else:self.assertEqual(p.read_bytes(),b'prior evidence')
|
||||
self.assertEqual(list(root.iterdir()),[p])
|
||||
def test_valid_scope_reaches_prefix_guard_without_writes(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for case in CASES:
|
||||
r=self.invoke(Path(tmp),case)
|
||||
self.assertIn('must be a disposable cloned prefix',r.stderr)
|
||||
self.assertEqual(list(Path(tmp).iterdir()),[])
|
||||
def test_unrelated_outcome_keeps_prior_marker_untouched(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
p=Path(tmp)/FILES[0];p.write_text('existing')
|
||||
r=self.invoke(Path(tmp),'victory')
|
||||
self.assertIn('must be a disposable cloned prefix',r.stderr)
|
||||
self.assertEqual(p.read_text(),'existing')
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in New Issue
Block a user