Skip to content

Commit a41cf3e

Browse files
committed
Revert "Make diff section contents red(-)/green(+) in run-tests.php"
This reverts commit 58489bd. This also uses ANSI escape code coloring for .diff files, where it is not meaningful.
1 parent 58489bd commit a41cf3e

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

run-tests.php

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,6 @@ function count_array_diff(
28772877

28782878
function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): array
28792879
{
2880-
global $colorize;
28812880
$idx1 = 0;
28822881
$cnt1 = @count($ar1);
28832882
$idx2 = 0;
@@ -2886,25 +2885,6 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
28862885
$old1 = [];
28872886
$old2 = [];
28882887

2889-
$format_expected_line = function (int $line_number, string $contents) use ($colorize): string {
2890-
$output = sprintf("%03d- ", $line_number) . $contents;
2891-
if ($colorize) {
2892-
// Reuse the colors used for `-` in other diff tools.
2893-
// Here, red should be interpreted as "removed", and not "bad".
2894-
return "\e[1;31m{$output}\e[0m";
2895-
}
2896-
return $output;
2897-
};
2898-
$format_actual_line = function (int $line_number, string $contents) use ($colorize): string {
2899-
$output = sprintf("%03d+ ", $line_number) . $contents;
2900-
if ($colorize) {
2901-
// Reuse the colors used for `+` in other diff tools.
2902-
// Here, green should be interpreted as "added", and not "good".
2903-
return "\e[1;32m{$output}\e[0m";
2904-
}
2905-
return $output;
2906-
};
2907-
29082888
while ($idx1 < $cnt1 && $idx2 < $cnt2) {
29092889
if (comp_line($ar1[$idx1], $ar2[$idx2], $is_reg)) {
29102890
$idx1++;
@@ -2915,12 +2895,12 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
29152895
$c2 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2 + 1, $cnt1, $cnt2, 10);
29162896

29172897
if ($c1 > $c2) {
2918-
$old1[$idx1] = $format_expected_line($idx1 + 1, $w[$idx1++]);
2898+
$old1[$idx1] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
29192899
} elseif ($c2 > 0) {
2920-
$old2[$idx2] = $format_actual_line($idx2 + 1, $ar2[$idx2++]);
2900+
$old2[$idx2] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
29212901
} else {
2922-
$old1[$idx1] = $format_expected_line($idx1 + 1, $w[$idx1++]);
2923-
$old2[$idx2] = $format_actual_line($idx2 + 1, $ar2[$idx2++]);
2902+
$old1[$idx1] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
2903+
$old2[$idx2] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
29242904
}
29252905
}
29262906
}
@@ -2953,11 +2933,11 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
29532933
}
29542934

29552935
while ($idx1 < $cnt1) {
2956-
$diff[] = $format_expected_line($idx1 + 1, $w[$idx1++]);
2936+
$diff[] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
29572937
}
29582938

29592939
while ($idx2 < $cnt2) {
2960-
$diff[] = $format_actual_line($idx2 + 1, $ar2[$idx2++]);
2940+
$diff[] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
29612941
}
29622942

29632943
return $diff;

0 commit comments

Comments
 (0)