@@ -131,6 +131,7 @@ function show_usage(): void
131131 Run the tests multiple times in the same process and check the
132132 output of the last execution (CLI SAPI only).
133133
134+ --bless Bless failed tests using scripts/dev/bless_tests.php.
134135
135136HELP ;
136137}
@@ -157,7 +158,8 @@ function main(): void
157158 $ repeat , $ result_tests_file , $ slow_min_ms , $ start_time , $ switch ,
158159 $ temp_source , $ temp_target , $ test_cnt , $ test_dirs ,
159160 $ test_files , $ test_idx , $ test_list , $ test_results , $ testfile ,
160- $ user_tests , $ valgrind , $ sum_results , $ shuffle , $ file_cache , $ num_repeats ;
161+ $ user_tests , $ valgrind , $ sum_results , $ shuffle , $ file_cache , $ num_repeats ,
162+ $ bless ;
161163 // Parallel testing
162164 global $ workers , $ workerID ;
163165 global $ context_line_count ;
@@ -357,6 +359,7 @@ function main(): void
357359 $ preload = false ;
358360 $ file_cache = null ;
359361 $ shuffle = false ;
362+ $ bless = false ;
360363 $ workers = null ;
361364 $ context_line_count = 3 ;
362365 $ num_repeats = 1 ;
@@ -582,6 +585,9 @@ function main(): void
582585 $ num_repeats = (int ) $ argv [++$ i ];
583586 $ environment ['SKIP_REPEAT ' ] = 1 ;
584587 break ;
588+ case '--bless ' :
589+ $ bless = true ;
590+ break ;
585591 //case 'w'
586592 case '- ' :
587593 // repeat check with full switch
@@ -782,6 +788,9 @@ function main(): void
782788 }
783789
784790 $ junit ->saveXML ();
791+ if ($ bless ) {
792+ bless_failed_tests ($ PHP_FAILED_TESTS ['FAILED ' ]);
793+ }
785794 if (getenv ('REPORT_EXIT_STATUS ' ) !== '0 ' && getenv ('REPORT_EXIT_STATUS ' ) !== 'no ' &&
786795 ($ sum_results ['FAILED ' ] || $ sum_results ['BORKED ' ] || $ sum_results ['LEAKED ' ])) {
787796 exit (1 );
@@ -3996,4 +4005,19 @@ function check_proc_open_function_exists(): void
39964005 }
39974006}
39984007
4008+ function bless_failed_tests (array $ failedTests ): void
4009+ {
4010+ if (empty ($ failedTests )) {
4011+ return ;
4012+ }
4013+ $ args = [
4014+ PHP_BINARY ,
4015+ __DIR__ . '/scripts/dev/bless_tests.php ' ,
4016+ ];
4017+ foreach ($ failedTests as $ test ) {
4018+ $ args [] = $ test ['name ' ];
4019+ }
4020+ proc_open ($ args , [], $ pipes );
4021+ }
4022+
39994023main ();
0 commit comments