[llvm-commits] [LNT] r155442 - /lnt/trunk/lnt/tests/compile.py

Daniel Dunbar daniel at zuster.org
Tue Apr 24 08:16:41 PDT 2012


Author: ddunbar
Date: Tue Apr 24 10:16:41 2012
New Revision: 155442

URL: http://llvm.org/viewvc/llvm-project?rev=155442&view=rev
Log:
lnt.tests.compile: Improve quoting of logged commands, and fix a few other minor bugs.

Modified:
    lnt/trunk/lnt/tests/compile.py

Modified: lnt/trunk/lnt/tests/compile.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/compile.py?rev=155442&r1=155441&r2=155442&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/compile.py (original)
+++ lnt/trunk/lnt/tests/compile.py Tue Apr 24 10:16:41 2012
@@ -19,6 +19,17 @@
 from lnt.testing.util import commands, machineinfo
 from lnt.util import stats
 
+def args_to_quoted_string(args):
+    def quote_arg(arg):
+        if "'" in arg:
+            return '"%s"' % arg.replace('(', '\\(')\
+                .replace(')', '\\)')
+        elif '"' in arg or ' ' in arg:
+            return "'%s'" % arg
+        return arg
+    return ' '.join([quote_arg(a)
+                     for a in args])
+
 # Interface to runN.
 #
 # FIXME: Simplify.
@@ -350,8 +361,7 @@
     # Collect the samples.
     print >>test_log, '%s: executing full build: %s' % (
         datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'),
-        " ".join("'%s'" % arg
-                 for arg in cmd))
+        args_to_quoted_string(cmd))
     stdout_path = os.path.join(output_base, "stdout.log")
     stderr_path = os.path.join(output_base, "stderr.log")
     preprocess_cmd = 'rm -rf "%s"' % (build_base,)
@@ -390,7 +400,7 @@
             ('%s: warning: test command had stderr files with '
              'different sizes: %r') %
             (datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'),
-             stdout_sizes))
+             stderr_sizes))
     
 ###
 
@@ -742,7 +752,7 @@
         if not opts.configs_to_test:
             configs_to_test = ['Debug', 'Release']
         else:
-            configs_to_test = opts.config_to_test
+            configs_to_test = opts.configs_to_test
 
         # Compute the list of all tests.
         all_tests = list(get_tests(opts.test_suite_externals, flags_to_test,





More information about the llvm-commits mailing list