On Sat, 29 Apr 2023 at 16:57, Dagfinn Ilmari Mannsåker
<ilmari@ilmari.org> wrote:
>
> Leon Timmermans <fawaka@gmail.com> writes:
>
> > First of all, you really shouldn't be printing to STDOUT/STDERR in a test
> > anyway. The test framework owns the outputs, and it will actually take care
> > that the output is UTF-8. This problem doesn't exist if you use the tool
> > the way it's meant to be used.
>
> A concrete example:
>
> $ cat mojibake.t
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use Test2::V0;
>
> pass("ok");
>
> diag "skjærgårdsøl";
> no utf8;
> diag "blåbærsyltetøy";
>
> done_testing();
>
> $ perl mojibake.t
> # Seeded srand with seed '20230429' from local date.
What produces that output? I checked the Test2 repo and I couldn't
find any code that emits that.
Unfortunately one can't set srand() explicitly without breaking rand()
under fork(). In 5.37.3 we added support for a PERL_RAND_SEED env var
that does things "right" (deterministic but each fork gets its own
seed).
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
<ilmari@ilmari.org> wrote:
>
> Leon Timmermans <fawaka@gmail.com> writes:
>
> > First of all, you really shouldn't be printing to STDOUT/STDERR in a test
> > anyway. The test framework owns the outputs, and it will actually take care
> > that the output is UTF-8. This problem doesn't exist if you use the tool
> > the way it's meant to be used.
>
> A concrete example:
>
> $ cat mojibake.t
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use Test2::V0;
>
> pass("ok");
>
> diag "skjærgårdsøl";
> no utf8;
> diag "blåbærsyltetøy";
>
> done_testing();
>
> $ perl mojibake.t
> # Seeded srand with seed '20230429' from local date.
What produces that output? I checked the Test2 repo and I couldn't
find any code that emits that.
Unfortunately one can't set srand() explicitly without breaking rand()
under fork(). In 5.37.3 we added support for a PERL_RAND_SEED env var
that does things "right" (deterministic but each fork gets its own
seed).
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"