Skip to content

Commit db7ed0f

Browse files
avargitster
authored andcommitted
t/perf: correctly align non-ASCII descriptions in output
Change the test descriptions from being treated as binary blobs by perl to being treated as UTF-8. This ensures that e.g. a test description like "æ" is counted as 1 character, not 2. I have WIP performance tests for non-ASCII grep patterns on another topic that are affected by this. Now instead of: $ ./run p0000-perf-lib-sanity.sh [...] 0000.4: export a weird var 0.00(0.00+0.00) 0000.5: éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś 0.00(0.00+0.00) 0000.7: important variables available in subshells 0.00(0.00+0.00) [...] We emit: [...] 0000.4: export a weird var 0.00(0.00+0.00) 0000.5: éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś 0.00(0.00+0.00) 0000.7: important variables available in subshells 0.00(0.00+0.00) [...] Fixes code originally added in 342e9ef ("Introduce a performance testing framework", 2012-02-17). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a2c2f8 commit db7ed0f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

t/perf/aggregate.perl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ sub format_times {
8888
sub read_descr {
8989
my $name = shift;
9090
open my $fh, "<", $name or return "<error reading description>";
91+
binmode $fh, ":utf8" or die "PANIC on binmode: $!";
9192
my $line = <$fh>;
9293
close $fh or die "cannot close $name";
9394
chomp $line;
@@ -147,6 +148,8 @@ sub have_slash {
147148
my $totalwidth = 3*@dirs+$descrlen;
148149
$totalwidth += $_ for (@colwidth);
149150

151+
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
152+
150153
printf "%-${descrlen}s", "Test";
151154
for my $i (0..$#dirs) {
152155
my $d = $dirs[$i];

t/perf/p0000-perf-lib-sanity.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ test_perf 'export a weird var' '
3333
test_export bar
3434
'
3535

36+
test_perf 'éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś' 'true'
37+
3638
test_expect_success 'test_export works with weird vars' '
3739
echo "$bar" &&
3840
test "$bar" = "weird # variable"

0 commit comments

Comments
 (0)