|
35 | 35 | foreach (['.diff', '.exp', '.log', '.mem', '.out', '.php', '.sh'] as $ext) { |
36 | 36 | @unlink($tests_dir. '/'.$base_name . $ext); |
37 | 37 | } |
38 | | - } else { |
39 | | - printf("please, edit manually [%s]".PHP_EOL, $iterator->key()); |
| 38 | + |
| 39 | + continue; |
| 40 | + } elseif (false !== ($pos = strpos($test_content, '--EXPECTF--'))) { |
| 41 | + |
| 42 | + printf("--EXPECTF-- [%s]".PHP_EOL, $iterator->key()); |
| 43 | + |
| 44 | + // get replacements |
| 45 | + |
| 46 | + $tests = substr($test_content, 0, $pos); |
| 47 | + $result = file_get_contents($tests_dir . '/' . $out_file); |
| 48 | + |
| 49 | + preg_match_all('#// EXPECTF: \-\-\-(.+)#', $tests, $expectf_search); |
| 50 | + preg_match_all('#// EXPECTF: \+\+\+(.+)#', $tests, $expectf_replace); |
| 51 | + |
| 52 | + if (count($expectf_search) != count($expectf_replace)) { |
| 53 | + printf("please, edit manually [%s]: searches and replaces count doesn't match".PHP_EOL, $iterator->key()); |
| 54 | + continue; |
| 55 | + } |
| 56 | + |
| 57 | + foreach (array_combine($expectf_search[1], $expectf_replace[1]) as $search => $replace) { |
| 58 | + $result = preg_replace($search, $replace, $result); |
| 59 | + } |
| 60 | + |
| 61 | + $test_content = $tests; |
| 62 | + $test_content .= '--EXPECTF--'.PHP_EOL; |
| 63 | + $test_content .= $result; |
| 64 | + $test_content .= PHP_EOL; |
| 65 | + |
| 66 | + file_put_contents($tests_dir . '/' . $test_file, $test_content); |
| 67 | + |
| 68 | + foreach (['.diff', '.exp', '.log', '.mem', '.out', '.php', '.sh'] as $ext) { |
| 69 | + @unlink($tests_dir. '/'.$base_name . $ext); |
| 70 | + } |
| 71 | + |
| 72 | + continue; |
40 | 73 | } |
| 74 | + |
| 75 | + printf("please, edit manually [%s]".PHP_EOL, $iterator->key()); |
41 | 76 | } |
0 commit comments