Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Less utf8 encode/decode (just decode immediately)
Better than it was, but there are still ways to improve the code.
For example, currently it may throw up on non-UTF8 data, which is less than
awesome for git bisect (we do not want to care if it is correct UTF-8 or not,
we just want to bisect).
  • Loading branch information
AlexDaniel committed Jul 24, 2016
1 parent 73a6a1a commit 465f84e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Perl6IRCBotable.pm
Expand Up @@ -52,7 +52,7 @@ sub get_output {
my $s_start = time();
my $pid = open3(undef, \*RESULT, \*RESULT, @_);
{
local $SIG{ALRM} = sub { kill 9, $pid; $out = encode_utf8("芦timed out after $wait seconds, output禄: "); };
local $SIG{ALRM} = sub { kill 9, $pid; $out = "芦timed out after $wait seconds, output禄: " };
alarm $wait;
waitpid($pid, 0);
alarm 0;
Expand All @@ -62,7 +62,7 @@ sub get_output {
my $exit_status = $? >> 8;
my $exit_signal = $? & 127;

$out .= do { local $/; <RESULT> } // '';
$out .= decode_utf8(do { local $/; <RESULT> }) // ''; # assume UTF-8, that's the best we can do
chomp $out;

return ($out, $exit_status, $exit_signal, $s_end - $s_start)
Expand Down
2 changes: 1 addition & 1 deletion benchable.pl
Expand Up @@ -25,7 +25,7 @@ package Benchable;
use parent 'Perl6IRCBotable';

use Cwd qw(cwd abs_path);
use Encode qw(encode_utf8 decode_utf8);
use Encode qw(encode_utf8);
use File::Temp qw(tempfile tempdir);
use List::Util qw(min max);
use Chart::Gnuplot;
Expand Down
8 changes: 4 additions & 4 deletions bisectable.pl
Expand Up @@ -24,7 +24,6 @@
package Bisectable;
use parent 'Perl6IRCBotable';

use Encode qw(decode_utf8);
use File::Temp qw(tempfile tempdir);
use Cwd qw(cwd abs_path);

Expand Down Expand Up @@ -101,12 +100,13 @@ sub process_message {

if ($exit_good == $exit_bad and $out_good eq $out_bad) {
$self->tell($message, "On both starting points the exit code is $exit_bad and the output is identical as well");
return 'Output on both points: ' . decode_utf8($out_good); # will be gisted automatically if required
return "Output on both points: $out_good"; # will be gisted automatically if required
}
my $output_file = '';
if ($exit_good == $exit_bad) {
$self->tell($message, "Exit code is $exit_bad on both starting points, bisecting by using the output");
(my $fh, $output_file) = tempfile(UNLINK => 1);
binmode $fh, ':encoding(UTF-8)';
print $fh $out_good;
close $fh;
}
Expand All @@ -125,7 +125,7 @@ sub process_message {
if ($init_status != 0) {
chdir($oldDir);
$self->tell($message, 'bisect log: ' . $self->upload({ 'query' => $body,
'result' => decode_utf8($init_output) }));
'result' => $init_output }));
return 'bisect init failure';
}
my ($bisect_output, $bisect_status);
Expand All @@ -142,7 +142,7 @@ sub process_message {
}
}
$self->tell($message, 'bisect log: ' . $self->upload({ 'query' => $body,
'result' => decode_utf8("$init_output\n$bisect_output") }));
'result' => "$init_output\n$bisect_output" }));
if ($bisect_status != 0) {
chdir($oldDir);
return "'bisect run' failure";
Expand Down
2 changes: 0 additions & 2 deletions committable.pl
Expand Up @@ -25,7 +25,6 @@ package Committable;
use parent 'Perl6IRCBotable';

use Cwd qw(cwd abs_path);
use Encode qw(decode_utf8);
use IPC::Signal 'sig_name';

use constant LIMIT => 300;
Expand Down Expand Up @@ -88,7 +87,6 @@ sub process_message {
$out = 'No build for this commit';
} else { # actually run the code
($out, my $exit, my $signal, my $time) = $self->get_output($self->BUILDS . "/$full_commit/bin/perl6", $filename);
$out = decode_utf8($out);
$out .= " 芦exit code = $exit" if ($exit != 0);
if ($signal != 0) {
my $signal_name = sig_name $signal;
Expand Down

0 comments on commit 465f84e

Please sign in to comment.