dirkbaechle avatar dirkbaechle committed e1048e0

- fixed usage of subprocess module in runtest.py
- fixed tests in test/runtest (needed -j option for suppressing the count/percent messages)

Comments (0)

Files changed (16)

 
 # Try to use subprocess instead of the more low-level
 # spawn command...
-has_subprocess = True
+use_subprocess = True
 try:
     import subprocess
+except:
+    use_subprocess = False
+    
+if (use_subprocess and
+    not suppress_stdout and
+    not suppress_stderr):
+    # If no suppress mode is selected, we still use the
+    # old spawn routines instead of the modern subprocess module.
+    # This is important for the test/runtest scripts, where we
+    # call runtest.py within the single tests. With subprocess the
+    # stderr of the subprocess lands in stdout of the top test script,
+    # which lets the test fail. :(
+    # TODO: find a way to use subprocess with proper stream redirection...
+    use_subprocess = False
 
+if use_subprocess:
     def spawn_it(command_args):
         p = subprocess.Popen(' '.join(command_args),
                              stdout=subprocess.PIPE,
         spawned_stdout = p.stdout.read()
         spawned_stderr = p.stderr.read()
         return (spawned_stderr, spawned_stdout, p.wait())
-except:
+else:
     has_subprocess = False
     # Set up lowest-common-denominator spawning of a process on both Windows
     # and non-Windows systems that works all the way back to Python 1.5.2.
         if s < 0 or s > 2:
             sys.stdout.write("Unexpected exit status %d\n" % s)
 
-if not has_subprocess:
+if not use_subprocess:
     import popen2
     try:
         popen2.Popen3

test/runtest/aegis/batch-output.py

 PASSING TEST STDERR
 """
 
-test.run(arguments = '-o aegis.out --aegis test', stderr=expect_stderr)
+test.run(arguments = '-j -o aegis.out --aegis test', stderr=expect_stderr)
 
 expect = """\
 test_result = [

test/runtest/baseline/combined.py

 PASSING TEST STDERR
 """
 
-test.run(arguments='-b . test',
+test.run(arguments='-j -b . test',
          status=1,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/baseline/fail.py

 FAILING TEST STDERR
 """
 
-test.run(arguments='-b . test/fail.py',
+test.run(arguments='-j -b . test/fail.py',
          status=1,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/baseline/no_result.py

 NO RESULT TEST STDERR
 """
 
-test.run(arguments='-b . test/no_result.py',
+test.run(arguments='-j -b . test/no_result.py',
          status=2,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/baseline/pass.py

 PASSING TEST STDERR
 """
 
-test.run(arguments='-b . test',
+test.run(arguments='-j -b . test',
          stdout=expect_stdout,
          stderr=expect_stderr)
 

test/runtest/fallback.py

     test_pass_py,
 ]
 
-test.run(arguments = ' '.join(testlist),
+test.run(arguments = '-j '+' '.join(testlist),
          status = 1,
          stdout = expect_stdout,
          stderr = expect_stderr)

test/runtest/noqmtest.py

     test_pass_py,
 ]
 
-test.run(arguments = '--noqmtest %s' % ' '.join(testlist),
+test.run(arguments = '-j --noqmtest %s' % ' '.join(testlist),
          status = 1,
          stdout = expect_stdout,
          stderr = expect_stderr)

test/runtest/print_time.py

 PASSING TEST STDERR
 """
 
-test.run(arguments='-t test',
+test.run(arguments='-j -t test',
          status=1,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/python.py

 PASSING TEST STDERR
 """
 
-test.run(arguments=['-P', mypython, 'test'],
+test.run(arguments=['-j','-P', mypython, 'test'],
          stdout=expect_stdout,
          stderr=expect_stderr)
 

test/runtest/simple/combined.py

 PASSING TEST STDERR
 """
 
-test.run(arguments='test',
+test.run(arguments='-j test',
          status=1,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/simple/fail.py

 FAILING TEST STDERR
 """
 
-test.run(arguments='test/fail.py',
+test.run(arguments='-j test/fail.py',
          status=1,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/simple/no_result.py

 NO RESULT TEST STDERR
 """
 
-test.run(arguments='test/no_result.py',
+test.run(arguments='-j test/no_result.py',
          status=2,
          stdout=expect_stdout,
          stderr=expect_stderr)

test/runtest/simple/pass.py

 PASSING TEST STDERR
 """
 
-test.run(arguments='test/pass.py', stdout=expect_stdout, stderr=expect_stderr)
+test.run(arguments='-j test/pass.py', stdout=expect_stdout, stderr=expect_stderr)
 
 test.pass_test()
 

test/runtest/src.py

 PASSING TEST STDERR
 """ % locals()
 
-test.run(arguments='src', stdout=expect_stdout, stderr=expect_stderr)
+test.run(arguments='-j src', stdout=expect_stdout, stderr=expect_stderr)
 
 test.pass_test()
 

test/runtest/testlistfile.py

 PASSING TEST STDERR
 """
 
-test.run(arguments='-f t.txt', stdout=expect_stdout, stderr=expect_stderr)
+test.run(arguments='-j -f t.txt', stdout=expect_stdout, stderr=expect_stderr)
 
 test.pass_test()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.