Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,12 @@ function run_test(string $php, $file, array $env): string
}

// write .diff
$diff = generate_diff($wanted, $wanted_re, $output);
if (!empty($environment['TEST_PHP_DIFF_CMD'])) {
$diff = generate_diff_external($environment['TEST_PHP_DIFF_CMD'], $exp_filename, $output_filename);
} else {
$diff = generate_diff($wanted, $wanted_re, $output);
}

if (is_array($IN_REDIRECT)) {
$orig_shortname = str_replace(TEST_PHP_SRCDIR . '/', '', $file);
$diff = "# original source file: $orig_shortname\n" . $diff;
Expand Down Expand Up @@ -2959,6 +2964,13 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
return $diff;
}

function generate_diff_external(string $diff_cmd, string $exp_file, string $output_file): string
{
$retval = shell_exec("{$diff_cmd} {$exp_file} {$output_file}");

return is_string($retval) ? $retval : 'Could not run external diff tool set through PHP_TEST_DIFF_CMD environment variable';
}

function generate_diff(string $wanted, ?string $wanted_re, string $output): string
{
$w = explode("\n", $wanted);
Expand Down