Re: [PATCH] t/perf: correctly align non-ASCII descriptions in output
- From
Jeff King <peff@peff.net>
- Date
- Apr 21, 2017, 20:41 UTC
- Message-ID
- <20170421204154.c5mvmnccxkxdm5aw@sigill.intra.peff.net>
- In-Reply-To
- <20170421194428.1377-1-avarab@gmail.com>
On Fri, Apr 21, 2017 at 07:44:28PM +0000, Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> 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.
Makes sense. As this is purely about test titles in our project, choosing utf8 as the only encoding is quite sensible.
Show 9 quoted lines
> diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
> index 924b19dab4..1dbc85b214 100755
> --- a/t/perf/aggregate.perl
> +++ b/t/perf/aggregate.perl
> @@ -88,6 +88,7 @@ for my $t (@tests) {
> sub read_descr {
> my $name = shift;
> open my $fh, "<", $name or return "<error reading description>";
> + binmode $fh, ":utf8" or die "PANIC on binmode: $!";I thought there was some "use" flag we could set to just make all of our handles utf8. But all I could come up with was stuff like PERLIO and "perl -C". Using binmode isn't too bad, though (I think you could just do it as part of the open, too, but I'm not sure if antique versions of perl support that).
-Peff