native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
Python
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110import jsonimport osfrom pathlib import Pathimport shutilimport subprocessimport tempfileimport unittest
class AppBuildPathTests(unittest.TestCase): def run_failed_build(self, derived_path): with tempfile.TemporaryDirectory() as directory: root = Path(directory) shutil.copyfile(Path(__file__).resolve().parents[1] / "Makefile", root / "Makefile") (root / "overrides.mk").write_text("ensure-ghostty:\n\t@true\n") (root / "xcodebuild").write_text( '#!/usr/bin/env python3\nimport json, pathlib, sys\n' 'pathlib.Path("arguments.json").write_text(json.dumps(sys.argv[1:]))\n' 'sys.exit(23)\n' ) (root / "mise").write_text("#!/bin/sh\ncat\n") for name in ["xcodebuild", "mise"]: (root / name).chmod(0o755) env = dict(os.environ, PATH=f"{root}:{os.environ['PATH']}") env.pop("PROWL_DERIVED_DATA_PATH", None) if derived_path is not None: env["PROWL_DERIVED_DATA_PATH"] = derived_path result = subprocess.run( ["make", "-f", "Makefile", "-f", "overrides.mk", "test-app", "SHELL=/bin/bash"], cwd=root, env=env, capture_output=True, text=True, ) self.assertNotEqual(result.returncode, 0) self.assertTrue((root / "arguments.json").exists(), result.stderr) return json.loads((root / "arguments.json").read_text())
def run_grouped_build(self, fail_mirror=False, fail_events=False): with tempfile.TemporaryDirectory() as directory: root = Path(directory) shutil.copyfile(Path(__file__).resolve().parents[1] / "Makefile", root / "Makefile") (root / "overrides.mk").write_text("ensure-ghostty:\n\t@true\n") (root / "scripts").mkdir() for name in ["assert-xcresult-tests.sh", "print-xcresult-failures.sh"]: (root / "scripts" / name).write_text("exit 0\n") (root / "xcodebuild").write_text( '#!/usr/bin/env python3\nimport json, sys\n' 'with open("calls.jsonl", "a") as out: out.write(json.dumps(sys.argv[1:]) + "\\n")\n' f'fail = ({fail_mirror!r} and "-only-testing:supacodeTests/MirrorHostTests" in sys.argv) or ' f'({fail_events!r} and "-only-testing:supacodeTests/GitWorktreeRegistryMonitorTests" in sys.argv)\n' 'sys.exit(23 if fail else 0)\n' ) (root / "mise").write_text("#!/bin/sh\ncat\n") for name in ["xcodebuild", "mise"]: (root / name).chmod(0o755) env = dict(os.environ, PATH=f"{root}:{os.environ['PATH']}") result = subprocess.run( ["make", "-f", "Makefile", "-f", "overrides.mk", "test-app", "SHELL=/bin/bash"], cwd=root, env=env, capture_output=True, text=True, ) calls = [json.loads(line) for line in (root / "calls.jsonl").read_text().splitlines()] return result, calls
def test_network_suites_run_once_outside_the_bulk_suite(self): result, calls = self.run_grouped_build() self.assertEqual(result.returncode, 0, result.stderr) for suite in ["MirrorHostTests", "MirrorDevicePairingTests", "MirrorConnectionTests", "MirrorTerminalIntegrationTests"]: target = f"supacodeTests/{suite}" self.assertIn(f"-skip-testing:{target}", calls[0]) runs = [call for call in calls if f"-only-testing:{target}" in call] self.assertEqual(len(runs), 1) self.assertEqual(runs[0][0], "test-without-building")
def test_network_suite_failure_fails_the_app_test_target(self): result, calls = self.run_grouped_build(fail_mirror=True) self.assertNotEqual(result.returncode, 0) self.assertTrue(any("-only-testing:supacodeTests/MirrorHostTests" in call for call in calls))
def test_event_monitors_run_once_outside_the_bulk_suite(self): result, calls = self.run_grouped_build() self.assertEqual(result.returncode, 0, result.stderr) targets = [ "supacodeTests/GitWorktreeRegistryMonitorTests", "supacodeTests/CLISocketServerTests/disconnectMonitorActivatesDuringCreation()", "supacodeTests/CLISocketServerTests/disconnectMonitorOutlivesOriginalDescriptor()", ] for target in targets: self.assertIn(f"-skip-testing:{target}", calls[0]) runs = [call for call in calls if f"-only-testing:{target}" in call] self.assertEqual(len(runs), 1) self.assertEqual(runs[0][0], "test-without-building") self.assertTrue(all(f"-only-testing:{item}" in runs[0] for item in targets))
def test_event_monitor_failure_fails_the_app_test_target(self): result, calls = self.run_grouped_build(fail_events=True) self.assertNotEqual(result.returncode, 0) self.assertTrue(any("-only-testing:supacodeTests/GitWorktreeRegistryMonitorTests" in call for call in calls))
def test_default_build_reaches_xcodebuild_with_bash_nounset(self): arguments = self.run_failed_build(None) self.assertNotIn("-derivedDataPath", arguments) self.assertEqual(arguments[0], "test")
def test_explicit_build_path_preserves_spaces_and_failure(self): arguments = self.run_failed_build("/tmp/build path") self.assertEqual(arguments[arguments.index("-derivedDataPath") + 1], "/tmp/build path")
if __name__ == "__main__": unittest.main()