|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""Exercise the build entry point, stopping at GN before compiling V8.""" |
| 3 | +import os |
| 4 | +from pathlib import Path |
| 5 | +import subprocess |
| 6 | +import tempfile |
| 7 | +import unittest |
| 8 | + |
| 9 | +ROOT = Path(__file__).resolve().parents[1] |
| 10 | + |
| 11 | +class AppleArgs(unittest.TestCase): |
| 12 | + def args_for(self, variant): |
| 13 | + with tempfile.TemporaryDirectory() as tmp: |
| 14 | + directory = Path(tmp) |
| 15 | + gn = directory / 'gn' |
| 16 | + gn.write_text('#!/bin/sh\nprintf "%s\\n" "$@" > "$ARGS_CAPTURE"\nexit 77\n') |
| 17 | + gn.chmod(0o755) |
| 18 | + env = dict(os.environ, PATH=tmp + ':' + os.environ['PATH'], ARGS_CAPTURE=str(directory / 'args')) |
| 19 | + result = subprocess.run([str(ROOT / 'scripts/matrix/build-ios.sh'), '--variant', variant, '--v8-dir', tmp], env=env, capture_output=True, text=True) |
| 20 | + self.assertEqual(result.returncode, 77, result.stderr) |
| 21 | + return (directory / 'args').read_text() |
| 22 | + |
| 23 | + def test_tvos_is_release_jitless_and_without_wasm(self): |
| 24 | + for variant, environment in [('arm64-tvdevice', 'device'), ('arm64-tvsimulator', 'simulator')]: |
| 25 | + args = self.args_for(variant) |
| 26 | + for flag in ['target_platform="tvos"', 'use_blink=true', 'v8_enable_drumbrake=false', 'v8_enable_webassembly=false', 'is_debug=false', 'v8_enable_lite_mode=true', f'target_environment="{environment}"']: |
| 27 | + self.assertIn(flag, args) |
| 28 | + |
| 29 | + def test_ios_and_catalyst_do_not_receive_tvos_overrides(self): |
| 30 | + for variant in ['arm64-device', 'arm64-simulator', 'x64-simulator', 'arm64-catalyst', 'x64-catalyst']: |
| 31 | + args = self.args_for(variant) |
| 32 | + self.assertNotIn('target_platform=', args) |
| 33 | + self.assertNotIn('use_blink=', args) |
| 34 | + self.assertNotIn('v8_enable_drumbrake=', args) |
| 35 | + self.assertIn('is_debug=false', args) |
| 36 | + self.assertEqual('v8_enable_lite_mode=true' in args, 'catalyst' not in variant) |
| 37 | + |
| 38 | +if __name__ == '__main__': |
| 39 | + unittest.main() |
0 commit comments