Bug 1001689 - Stop suppressing the xmanager log file, r=njn
authorSteve Fink <sfink@mozilla.com>
Thu, 27 Mar 2014 09:00:58 -0700
changeset 181816 bb50d61e7777360430155b246dc89b4c8da2902b
parent 181815 728803659bcbdbb59611ba6c8a4f03e938c12977
child 181817 a4d2747c511a32bbad28f37affcf72754d76ccad
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersnjn
bugs1001689
milestone32.0a1
Bug 1001689 - Stop suppressing the xmanager log file, r=njn When suppressing logs (aka displaying output messages), we still need the xmanager output to go into its log file, because its port number is read out of it (yes, it's ugly.) So pipe through tee instead of redirecting to the log.
js/src/devtools/rootAnalysis/run_complete
--- a/js/src/devtools/rootAnalysis/run_complete
+++ b/js/src/devtools/rootAnalysis/run_complete
@@ -194,32 +194,39 @@ sub get_manager_address
     my $log_data = `cat $log_file`;
     my ($port) = $log_data =~ /Listening on ([\.\:0-9]*)/
       or die "no manager found";
     print OUT "Connecting to manager on port $port\n" unless $suppress_logs;
     print "Connecting to manager on port $port.\n";
     return $1;
 }
 
+sub logging_suffix {
+    my ($show_logs, $log_file) = @_;
+    return $show_logs ? "2>&1 | tee $log_file"
+                      : "> $log_file 2>&1";
+}
+
 sub run_build
 {
     print "build started: ";
     print scalar(localtime());
     print "\n";
 
     # fork off a process to run the build.
     defined(my $pid = fork) or die;
 
     # log file for the manager.
     my $manager_log_file = "$result_dir/build_manager.log";
 
     if (!$pid) {
         # this is the child process, fork another process to run a manager.
         defined(my $pid = fork) or die;
-        exec("$xmanager -terminate-on-assert > $manager_log_file 2>&1") if (!$pid);
+        my $logging = logging_suffix($suppress_logs, $manager_log_file);
+        exec("$xmanager -terminate-on-assert $logging") if (!$pid);
         $kill_on_exit{$pid} = 1;
 
         if (!$suppress_logs) {
             # open new streams to redirect stdout and stderr.
             open(LOGOUT, "> $result_dir/build.log");
             open(LOGERR, "> $result_dir/build_err.log");
             STDOUT->fdopen(\*LOGOUT, "w");
             STDERR->fdopen(\*LOGERR, "w");
@@ -281,17 +288,18 @@ sub run_pass
     my $log_file = "$result_dir/manager.$name.log";
 
     # extra commands to pass to the manager.
     my $manager_extra = "";
     $manager_extra .= "-modset-wait=10" if ($name eq "xmemlocal");
 
     # fork off a manager process for the analysis.
     defined(my $pid = fork) or die;
-    exec("$xmanager $manager_extra > $log_file 2>&1") if (!$pid);
+    my $logging = logging_suffix($suppress_logs, $log_file);
+    exec("$xmanager $manager_extra $logging") if (!$pid);
 
     my $address = get_manager_address($log_file);
 
     # write the poll file for this pass.
     if (! -d dirname($poll_file)) {
         system("mkdir", "-p", dirname($poll_file));
     }
     open(POLL, "> $poll_file");