Bug 791574 - Use a Unix-compatible list2cmdline. r=terrence.
authorSteve Fink <sfink@mozilla.com>
Tue, 18 Sep 2012 09:58:31 -0700
changeset 107765 ea2e059c896b86d863e318e62311c2ff2d617346
parent 107754 d1e20611089c6cd09e12ac1a6b8f2a0e48a2d29a
child 107766 f0e182ab06a9a0aa65825544ac44135e9e67e42a
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-esr52@2704e441363f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs791574
milestone18.0a1
Bug 791574 - Use a Unix-compatible list2cmdline. r=terrence. Sadly, subprocess.list2cmdline only seems to do something sensible for Windows, which I find rather bizarre. This patch fixes the problem where -s can give you something like ./js -e option(\'allow_xml\'); -f ... which is totally invalid in bash.
js/src/tests/lib/results.py
--- a/js/src/tests/lib/results.py
+++ b/js/src/tests/lib/results.py
@@ -1,11 +1,15 @@
 import re
-from subprocess import list2cmdline
 from progressbar import NullProgressBar, ProgressBar
+import pipes
+
+# subprocess.list2cmdline does not properly escape for sh-like shells
+def escape_cmdline(args):
+    return ' '.join([ pipes.quote(a) for a in args ])
 
 class TestOutput:
     """Output from a test run."""
     def __init__(self, test, cmd, out, err, rc, dt, timed_out):
         self.test = test   # Test
         self.cmd = cmd     # str:   command line of test
         self.out = out     # str:   stdout
         self.err = err     # str:   stderr
@@ -102,17 +106,17 @@ class ResultsSink:
             self.counts['TIMEOUT'] += 1
         if isinstance(output, NullTestOutput):
             if self.options.tinderbox:
                 self.print_tinderbox_result('TEST-KNOWN-FAIL', output.test.path, time=output.dt, skip=True)
             self.counts['SKIP'] += 1
             self.n += 1
         else:
             if self.options.show_cmd:
-                print >> self.fp, list2cmdline(output.cmd)
+                print >> self.fp, escape_cmdline(output.cmd)
 
             if self.options.show_output:
                 print >> self.fp, '    rc = %d, run time = %f' % (output.rc, output.dt)
                 self.fp.write(output.out)
                 self.fp.write(output.err)
 
             result = TestResult.from_output(output)
             tup = (result.result, result.test.expect, result.test.random)