[Bps-public-commit] smokingit-worker branch, master, updated. 1bf900537706f103d26464883b9e6900e7daabd3

Alex Vandiver alexmv at bestpractical.com
Wed Apr 2 12:20:02 EDT 2014


The branch, master has been updated
       via  1bf900537706f103d26464883b9e6900e7daabd3 (commit)
      from  70642b1b6fdcb6b3ebfee6ff1eb6a9d988a33755 (commit)

Summary of changes:
 lib/Smokingit/Worker.pm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 1bf900537706f103d26464883b9e6900e7daabd3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Apr 2 12:19:50 2014 -0400

    Write and exec a shell script for configuration
    
    This is less error-prone.  Also, use AnyEvent::Util::run_cmd for exit value and output.

diff --git a/lib/Smokingit/Worker.pm b/lib/Smokingit/Worker.pm
index 5494587..89f3607 100644
--- a/lib/Smokingit/Worker.pm
+++ b/lib/Smokingit/Worker.pm
@@ -6,6 +6,7 @@ use base 'AnyEvent::RabbitMQ::RPC';
 
 use EV;
 use AnyEvent;
+use AnyEvent::Util;
 use AnyMQ;
 
 use TAP::Harness;
@@ -13,6 +14,7 @@ use TAP::Parser::Multiplexer::AnyEvent;
 use Storable qw( nfreeze thaw );
 use YAML;
 use Cwd qw();
+use File::Temp qw/ tempfile /;
 
 use Smokingit::Worker::Clean::TmpFiles;
 use Smokingit::Worker::Clean::Postgres;
@@ -162,9 +164,18 @@ sub run_tests {
             smoke_id => $request->{smoke_id},
             status   => "configuring",
         );
-        $config =~ s/\s*;?\s*\n+/ && /g;
-        my $output = `($config) 2>&1`;
-        my $ret = $?;
+        my ($fh, $filename) = tempfile();
+        $config =~ s/\r\n/\n/g;
+        $config = "#!/bin/sh\nset -e\nexec 2>&1\n$config\n";
+        print $fh $config;
+        close $fh;
+        chmod 0755, $filename;
+
+        my $output = "";
+        my $done = AnyEvent::Util::run_cmd $filename,
+            ">" => \$output;
+
+        my $ret = $done->recv;
         my $exit_val = $ret >> 8;
         return $error->("Configuration failed (exit value $exit_val)!\n\n" . $output)
             if $ret;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list