t/perf: correctly align non-ASCII descriptions in output
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 21 Apr 2017 19:44:28 +0000 (19:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Apr 2017 04:33:15 +0000 (21:33 -0700)
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 342e9ef2d9 ("Introduce a performance
testing framework", 2012-02-17).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/perf/aggregate.perl
t/perf/p0000-perf-lib-sanity.sh
index 924b19dab4122a36112bd908a6252e754ecc531a..1dbc85b21407dcfc83d9dc6a56e8e0f21c748c0c 100755 (executable)
@@ -88,6 +88,7 @@ sub format_times {
 sub read_descr {
        my $name = shift;
        open my $fh, "<", $name or return "<error reading description>";
+       binmode $fh, ":utf8" or die "PANIC on binmode: $!";
        my $line = <$fh>;
        close $fh or die "cannot close $name";
        chomp $line;
@@ -147,6 +148,8 @@ sub have_slash {
 my $totalwidth = 3*@dirs+$descrlen;
 $totalwidth += $_ for (@colwidth);
 
+binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
+
 printf "%-${descrlen}s", "Test";
 for my $i (0..$#dirs) {
        my $d = $dirs[$i];
index cf8e1efce7cd29679c3ffdb2fa7d03489c38c1c9..002c21e52a6763ee14ac243b2b3a1af242fc2834 100755 (executable)
@@ -33,6 +33,8 @@ test_perf 'export a weird var' '
        test_export bar
 '
 
+test_perf 'éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś' 'true'
+
 test_expect_success 'test_export works with weird vars' '
        echo "$bar" &&
        test "$bar" = "weird # variable"