@@ -2495,14 +2495,16 @@ function run_test(string $php, $file, array $env): string
2495
2495
];
2496
2496
}
2497
2497
2498
+ // Remember CLEAN output to report borked test if it otherwise passes.
2499
+ $ clean_output = null ;
2498
2500
if ($ test ->sectionNotEmpty ('CLEAN ' ) && (!$ no_clean || $ cfg ['keep ' ]['clean ' ])) {
2499
2501
show_file_block ('clean ' , $ test ->getSection ('CLEAN ' ));
2500
2502
save_text ($ test_clean , trim ($ test ->getSection ('CLEAN ' )), $ temp_clean );
2501
2503
2502
2504
if (!$ no_clean ) {
2503
2505
$ extra = !IS_WINDOWS ?
2504
2506
"unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD; " : "" ;
2505
- system_with_timeout ("$ extra $ php $ pass_options $ extra_options -q $ orig_ini_settings $ no_file_cache \"$ test_clean \"" , $ env );
2507
+ $ clean_output = system_with_timeout ("$ extra $ orig_php $ pass_options -q $ orig_ini_settings $ no_file_cache \"$ test_clean \"" , $ env );
2506
2508
}
2507
2509
2508
2510
if (!$ cfg ['keep ' ]['clean ' ]) {
@@ -2654,25 +2656,6 @@ function run_test(string $php, $file, array $env): string
2654
2656
2655
2657
if (preg_match ("/^ $ wanted_re \$/s " , $ output )) {
2656
2658
$ passed = true ;
2657
- if (!$ cfg ['keep ' ]['php ' ] && !$ leaked ) {
2658
- @unlink ($ test_file );
2659
- @unlink ($ preload_filename );
2660
- }
2661
- @unlink ($ tmp_post );
2662
-
2663
- if (!$ leaked && !$ failed_headers ) {
2664
- if ($ test ->hasSection ('XFAIL ' )) {
2665
- $ warn = true ;
2666
- $ info = " (warn: XFAIL section but test passes) " ;
2667
- } elseif ($ test ->hasSection ('XLEAK ' )) {
2668
- $ warn = true ;
2669
- $ info = " (warn: XLEAK section but test passes) " ;
2670
- } else {
2671
- show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2672
- $ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
2673
- return 'PASSED ' ;
2674
- }
2675
- }
2676
2659
}
2677
2660
} else {
2678
2661
$ wanted = trim ($ test ->getSection ('EXPECT ' ));
@@ -2682,29 +2665,46 @@ function run_test(string $php, $file, array $env): string
2682
2665
// compare and leave on success
2683
2666
if (!strcmp ($ output , $ wanted )) {
2684
2667
$ passed = true ;
2668
+ }
2685
2669
2686
- if (!$ cfg ['keep ' ]['php ' ] && !$ leaked ) {
2687
- @unlink ($ test_file );
2688
- @unlink ($ preload_filename );
2670
+ $ wanted_re = null ;
2671
+ }
2672
+
2673
+ if ($ passed ) {
2674
+ if (!$ cfg ['keep ' ]['php ' ] && !$ leaked ) {
2675
+ @unlink ($ test_file );
2676
+ @unlink ($ preload_filename );
2677
+ }
2678
+ @unlink ($ tmp_post );
2679
+
2680
+ if (!$ leaked && !$ failed_headers ) {
2681
+ // If the test passed and CLEAN produced output, report test as borked.
2682
+ if ($ clean_output ) {
2683
+ show_result ("BORK " , $ output , $ tested_file , 'reason: invalid output from CLEAN ' , $ temp_filenames );
2684
+ $ PHP_FAILED_TESTS ['BORKED ' ][] = [
2685
+ 'name ' => $ file ,
2686
+ 'test_name ' => '' ,
2687
+ 'output ' => '' ,
2688
+ 'diff ' => '' ,
2689
+ 'info ' => "$ clean_output [ $ file] " ,
2690
+ ];
2691
+
2692
+ $ junit ->markTestAs ('BORK ' , $ shortname , $ tested , null , $ clean_output );
2693
+ return 'BORKED ' ;
2689
2694
}
2690
- @unlink ($ tmp_post );
2691
2695
2692
- if (!$ leaked && !$ failed_headers ) {
2693
- if ($ test ->hasSection ('XFAIL ' )) {
2694
- $ warn = true ;
2695
- $ info = " (warn: XFAIL section but test passes) " ;
2696
- } elseif ($ test ->hasSection ('XLEAK ' )) {
2697
- $ warn = true ;
2698
- $ info = " (warn: XLEAK section but test passes) " ;
2699
- } else {
2700
- show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2701
- $ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
2702
- return 'PASSED ' ;
2703
- }
2696
+ if ($ test ->hasSection ('XFAIL ' )) {
2697
+ $ warn = true ;
2698
+ $ info = " (warn: XFAIL section but test passes) " ;
2699
+ } elseif ($ test ->hasSection ('XLEAK ' )) {
2700
+ $ warn = true ;
2701
+ $ info = " (warn: XLEAK section but test passes) " ;
2702
+ } else {
2703
+ show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2704
+ $ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
2705
+ return 'PASSED ' ;
2704
2706
}
2705
2707
}
2706
-
2707
- $ wanted_re = null ;
2708
2708
}
2709
2709
2710
2710
// Test failed so we need to report details.
0 commit comments