From 5c3e48fd0dc334efb4aafffc22c26a4db99d390a Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 21 Jan 2022 15:17:47 -0500 Subject: [PATCH] CliRunners: decode UTF8 before printing stderr/stdout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes yath output. It used to say: step â is now runnable Now it says: step ‘/run...2ipqz6hbc41m4c5w5bkq-dependent-job.drv’ is now runnable --- t/lib/CliRunners.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/lib/CliRunners.pm b/t/lib/CliRunners.pm index e693eeb7..7ae936c0 100644 --- a/t/lib/CliRunners.pm +++ b/t/lib/CliRunners.pm @@ -27,6 +27,8 @@ sub evalSucceeds { $jobset->discard_changes; # refresh from DB if ($res) { chomp $stdout; chomp $stderr; + utf8::decode($stdout) or die "Invalid unicode in stdout."; + utf8::decode($stderr) or die "Invalid unicode in stderr."; print STDERR "Evaluation unexpectedly failed for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg; print STDERR "STDOUT: $stdout\n" if $stdout ne ""; print STDERR "STDERR: $stderr\n" if $stderr ne ""; @@ -40,6 +42,8 @@ sub evalFails { $jobset->discard_changes; # refresh from DB if (!$res) { chomp $stdout; chomp $stderr; + utf8::decode($stdout) or die "Invalid unicode in stdout."; + utf8::decode($stderr) or die "Invalid unicode in stderr."; print STDERR "Evaluation unexpectedly succeeded for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg; print STDERR "STDOUT: $stdout\n" if $stdout ne ""; print STDERR "STDERR: $stderr\n" if $stderr ne ""; @@ -51,6 +55,8 @@ sub runBuild { my ($build) = @_; my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id)); if ($res) { + utf8::decode($stdout) or die "Invalid unicode in stdout."; + utf8::decode($stderr) or die "Invalid unicode in stderr."; print STDERR "Queue runner stdout: $stdout\n" if $stdout ne ""; print STDERR "Queue runner stderr: $stderr\n" if $stderr ne ""; } @@ -60,6 +66,8 @@ sub runBuild { sub sendNotifications() { my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-notify", "--queued-only")); if ($res) { + utf8::decode($stdout) or die "Invalid unicode in stdout."; + utf8::decode($stderr) or die "Invalid unicode in stderr."; print STDERR "hydra notify stdout: $stdout\n" if $stdout ne ""; print STDERR "hydra notify stderr: $stderr\n" if $stderr ne ""; }