"""The experimental input mode must refuse unrelated projects before any setup.""" from pathlib import Path import subprocess import sys import tempfile import unittest ROOT=Path(__file__).resolve().parents[1] class FlightActionRunner(unittest.TestCase): def test_actual_controller_scope_refused_before_setup(self): for project,rounds,timeout,smoke in [(p,r,t,s) for p,r,t in [('core','1','420'),('chat','2','420'),('chat','1','419')] for s in ['aircraft-control','aircraft-cancel','aircraft-translate']]: with self.subTest(project=project,rounds=rounds,timeout=timeout,smoke=smoke),tempfile.TemporaryDirectory() as directory: root=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(root/'prefix'),'--profile',str(root/'profile'),'--project',project,'--smoke',smoke,'--rounds',rounds,'--timeout',timeout],capture_output=True,text=True) self.assertNotEqual(result.returncode,0) self.assertIn('aircraft-control/aircraft-cancel/aircraft-translate requires Chat, one round, and at least 420 seconds',result.stderr) self.assertEqual(list(root.iterdir()),[]) def test_scope_refused_without_profile_or_process_setup(self): for project,smoke in [('core','victory'),('chat','victory'),('chat','powered-flight')]: with self.subTest(project=project,smoke=smoke),tempfile.TemporaryDirectory() as directory: root=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(root/'prefix'),'--profile',str(root/'profile'),'--project',project,'--smoke',smoke,'--rounds','1','--timeout','420','--flight-action-inputs'],capture_output=True,text=True) self.assertNotEqual(result.returncode,0) self.assertIn('flight-action-inputs requires the Core powered-flight fixture',result.stderr) self.assertEqual(list(root.iterdir()),[]) def test_autohover_requires_explicit_action_input_fixture(self): for project,smoke,extra in [('core','victory',[]),('chat','powered-flight',['--flight-action-inputs']),('core','powered-flight',[])]: with self.subTest(project=project,smoke=smoke,extra=extra),tempfile.TemporaryDirectory() as directory: root=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(root/'prefix'),'--profile',str(root/'profile'),'--project',project,'--smoke',smoke,'--rounds','1','--timeout','420','--flight-autohover',*extra],capture_output=True,text=True) self.assertNotEqual(result.returncode,0) self.assertIn('flight-autohover requires Core powered-flight with flight-action-inputs',result.stderr) self.assertEqual(list(root.iterdir()),[]) self.assertIn("if a.flight_autohover: command += ['-errFlightAutohover', '1']",(ROOT/'tools/headless_workbench.py').read_text()) def test_translation_requires_both_proven_control_paths(self): for extra in [[],['--flight-action-inputs'],['--flight-autohover']]: with self.subTest(extra=extra),tempfile.TemporaryDirectory() as directory: root=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(root/'prefix'),'--profile',str(root/'profile'),'--project','core','--smoke','powered-translate','--rounds','1','--timeout','420',*extra],capture_output=True,text=True) self.assertNotEqual(result.returncode,0) self.assertIn('powered-translate requires Core with flight-action-inputs and flight-autohover',result.stderr) self.assertEqual(list(root.iterdir()),[]) with tempfile.TemporaryDirectory() as directory: root=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(root/'prefix'),'--profile',str(root/'profile'),'--project','core','--smoke','powered-translate','--rounds','1','--timeout','420','--flight-action-inputs','--flight-autohover'],capture_output=True,text=True) self.assertIn('must be a disposable cloned prefix',result.stderr) self.assertEqual(list(root.iterdir()),[]) def test_valid_scope_still_requires_disposable_prefix(self): with tempfile.TemporaryDirectory() as directory: root=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'),'--compat',str(root/'prefix'),'--profile',str(root/'profile'),'--project','core','--smoke','powered-flight','--rounds','1','--timeout','420','--flight-action-inputs'],capture_output=True,text=True) self.assertNotEqual(result.returncode,0) self.assertIn('must be a disposable cloned prefix',result.stderr) self.assertEqual(list(root.iterdir()),[]) self.assertIn("if a.flight_action_inputs: command += ['-errFlightActionInputs', '1']",(ROOT/'tools/headless_workbench.py').read_text()) if __name__=='__main__':unittest.main()