zturner created this revision.
zturner added reviewers: dawn, chaoren.
zturner added a subscriber: lldb-commits.

Previously all test output was reported by each individual
instance of dotest.py.  After a recent patch, dosep gets dotest
outptu via a pipe, and selectively decides which output to
print.

This breaks certain scripts which rely on having full output
of each dotest instance to do various parsing and/or log-scraping.

While we make no promises about the format of dotest output, it's
easy to restore this to the old behavior for now, although it is
behind a flag.  To re-enable full output, run dosep.py with the -s
option.

http://reviews.llvm.org/D11816

Files:
  test/dosep.py

Index: test/dosep.py
===================================================================
--- test/dosep.py
+++ test/dosep.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python
 
 """
 Run the test suite using a separate process for each test file.
@@ -67,6 +67,7 @@
 test_counter = None
 total_tests = None
 dotest_options = None
+output_on_success = False
 
 def setup_global_variables(lock, counter, total, options):
     global output_lock, test_counter, total_tests, dotest_options
@@ -75,18 +76,30 @@
     total_tests = total
     dotest_options = options
 
-def update_status(name = None, command = None, output = None):
+def report_test_failure(name, command, stdout, stderr):
+    global output_lock
+    with output_lock:
+        print >> sys.stderr, stdout
+        print >> sys.stderr, "[%s] FAILED" % name
+        print >> sys.stderr, "Command invoked: %s" % ' '.join(command)
+        print >> sys.stderr, "stderr:\n%s" % stderr
+        update_progress()
+
+def report_test_pass(name, stdout):
+    global output_lock, output_on_success
+    with output_lock:
+        if output_on_success:
+            print >> sys.stderr, stdout
+        print >> sys.stderr, "[%s] PASSED" % name
+        update_progress()
+
+def update_progress():
     global output_lock, test_counter, total_tests
     with output_lock:
-        if output is not None:
-            print >> sys.stderr
-            print >> sys.stderr, "Failed test suite: %s" % name
-            print >> sys.stderr, "Command invoked: %s" % ' '.join(command)
-            print >> sys.stderr, "stdout:\n%s" % output[0]
-            print >> sys.stderr, "stderr:\n%s" % output[1]
-        sys.stderr.write("\r%*d out of %d test suites processed" %
+        sys.stderr.write("\r%*d out of %d test suites processed\n" %
             (len(str(total_tests)), test_counter.value, total_tests))
         test_counter.value += 1
+    sys.stdout.flush()
     sys.stderr.flush()
 
 def parse_test_results(output):
@@ -126,7 +139,10 @@
     output = process.communicate()
     exit_status = process.returncode
     passes, failures = parse_test_results(output)
-    update_status(name, command, output if exit_status != 0 else None)
+    if exit_status == 0:
+        report_test_pass(name, output[1])
+    else:
+        report_test_failure(name, command, output[0], output[1])
     return exit_status, passes, failures
 
 def process_dir(root, files, test_root, dotest_argv):
@@ -194,11 +210,11 @@
         test_work_items.append((root, files, test_directory, dotest_argv))
 
     global output_lock, test_counter, total_tests
-    output_lock = multiprocessing.Lock()
+    output_lock = multiprocessing.RLock()
     total_tests = len(test_work_items)
     test_counter = multiprocessing.Value('i', 0)
     print >> sys.stderr, "Testing: %d tests, %d threads" % (total_tests, num_threads)
-    update_status()
+    update_progress()
 
     # Run the items, either in a pool (for multicore speedup) or
     # calling each individually.
@@ -327,6 +343,12 @@
                       dest='dotest_options',
                       help="""The options passed to 'dotest.py' if specified.""")
 
+    parser.add_option('-s', '--output-on-success',
+                      action='store_true',
+                      dest='output_on_success',
+                      default=False,
+                      help="""Print full output of 'dotest.py' even when it succeeds.""")
+
     parser.add_option('-t', '--threads',
                       type='int',
                       dest='num_threads',
@@ -340,6 +362,8 @@
 
     parser = dotest_args.create_parser()
     global dotest_options
+    global output_on_success
+    output_on_success = opts.output_on_success
     dotest_options = dotest_args.parse_args(parser, dotest_argv)
 
     if not dotest_options.s:
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to