From d387667f1e7a9564f8a77dcff4c5d0f9d38c7786 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 19 May 2026 19:28:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(tests):=20=E6=B7=BB=E5=8A=A0=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E8=B7=AF=E5=BE=84=E9=85=8D=E7=BD=AE=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 --no-aot 参数以支持非AOT编译模式运行测试 - 添加 --compiler 参数用于指定编译器二进制文件路径 - 设置默认编译器路径为 ./bin/compiler.php - 支持通过 --compiler 指定自定义编译器如 swoole_compiler - 修改系统调用以使用配置的编译器路径替代硬编码路径 - 更新全局变量声明以包含新的编译器路径参数 --- run-tests.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index a9003db8..0b74873d 100755 --- a/run-tests.php +++ b/run-tests.php @@ -128,6 +128,12 @@ Options: Run the tests multiple times in the same process and check the output of the last execution (CLI SAPI only). + --no-aot Run tests without AOT compilation (plain PHP mode). + + --compiler + Use specified compiler binary (default: ./bin/compiler.php). + For bootstrap testing, use: --compiler ./swoole_compiler + --bless Bless failed tests using scripts/dev/bless_tests.php. HELP; @@ -149,7 +155,7 @@ function main(): void $end_time, $environment, $exts_skipped, $exts_tested, $exts_to_test, $failed_tests_file, $ignored_by_ext, $ini_overwrites, $colorize, - $log_format, $no_clean, $no_aot, $no_file_cache, + $log_format, $no_clean, $no_aot, $compiler_path, $no_file_cache, $pass_options, $php, $php_cgi, $preload, $result_tests_file, $slow_min_ms, $start_time, $temp_source, $temp_target, $test_cnt, @@ -494,6 +500,9 @@ function main(): void case '--no-aot': $no_aot = true; break; + case '--compiler': + $compiler_path = $argv[++$i]; + break; case '--color': $colorize = true; break; @@ -665,6 +674,9 @@ function main(): void if (!$php) { $php = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY; } + if (!$compiler_path) { + $compiler_path = './bin/compiler.php'; + } $php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE') ?: get_binary($php, 'php-cgi', 'sapi/cgi/php-cgi'); $phpdbg = getenv('TEST_PHPDBG_EXECUTABLE') ?: get_binary($php, 'phpdbg', 'sapi/phpdbg/phpdbg'); @@ -1811,6 +1823,7 @@ function run_test(string $php, $file, array $env): string global $slow_min_ms; global $preload, $file_cache; global $num_repeats; + global $compiler_path; // Parallel testing global $workerID; global $show_progress; @@ -4201,6 +4214,8 @@ function debug() function compile_php_file(string $file): string { + global $compiler_path; + $data = trim(file_get_contents($file)); if (!str_starts_with($data, '')) { throw new Exception('Invalid PHP file'); @@ -4208,7 +4223,7 @@ function compile_php_file(string $file): string if (!str_contains($data, 'function main()')) { file_put_contents($file, "