Skip to content

Commit fb80b6a

Browse files
author
Andrey Khozov
committed
convert checkers stdout/stderr from bytes to string
1 parent b6ba242 commit fb80b6a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/CS/Model/Checker.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,14 @@ sub _run {
158158
$h = start $cmd, \undef, \$stdout, \$stderr, 'init', sub { chdir $path->dirname }, $t;
159159
$h->finish;
160160
};
161+
161162
$stdout //= '';
162163
$stdout =~ s/\x00//g;
164+
utf8::decode $stdout;
165+
166+
$stderr //= '';
167+
$stderr =~ s/\x00//g;
168+
utf8::decode $stderr;
163169

164170
if (length $stdout > MAX_OUTPUT_LENGTH) {
165171
$self->app->log->warn("Length of STDOUT for '@$cmd' exceeds limit");
@@ -171,7 +177,7 @@ sub _run {
171177
elapsed => tv_interval($start),
172178
exception => $@,
173179
exit => {value => $?, code => $? >> 8, signal => $? & 127, coredump => $? & 128},
174-
stderr => ($stderr // '') =~ s/\x00//gr,
180+
stderr => $stderr,
175181
stdout => $stdout,
176182
timeout => 0
177183
};

t/basic.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $db->select(runs => '*', {service_id => 1, team_id => 1})->expand->hashes->map(
4747
sub {
4848
is $_->{round}, 1, 'right round';
4949
is $_->{status}, 104, 'right status';
50-
is $_->{stdout}, "some error!\n", 'right stdout';
50+
is $_->{stdout}, "some error 😉\n", 'right stdout';
5151
}
5252
);
5353

t/checkers/down.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/perl
22

3-
print "some error!\n";
3+
print "some error 😉\n";
44
exit 104;

0 commit comments

Comments
 (0)