Add a --verbose option to runtest.py. (Baptiste Lepilleur) Fix (?) a deadlock using...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 17 Feb 2006 11:13:44 +0000 (11:13 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 17 Feb 2006 11:13:44 +0000 (11:13 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1426 fdb21ef1-2011-0410-befe-b5e4ea1792b1

etc/TestCmd.py
etc/TestCommon.py
runtest.py
src/CHANGES.txt

index cd6624595ed6e2046cbed5dc464123ab40e802d6..a2635c97744e13bef2a02ea1b57f0bef8d32c4c4 100644 (file)
@@ -176,8 +176,8 @@ version.
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCmd.py 0.18.D001 2005/10/15 06:40:23 knight"
-__version__ = "0.18"
+__revision__ = "TestCmd.py 0.20.D001 2006/02/16 06:28:21 knight"
+__version__ = "0.20"
 
 import os
 import os.path
@@ -449,13 +449,18 @@ class TestCmd:
                        interpreter = None,
                        workdir = None,
                        subdir = None,
-                       verbose = 0,
+                       verbose = None,
                        match = None,
                        combine = 0):
         self._cwd = os.getcwd()
         self.description_set(description)
         self.program_set(program)
         self.interpreter_set(interpreter)
+        if verbose is None:
+            try:
+                verbose = max( 0, int(os.environ.get('TESTCMD_VERBOSE', 0)) )
+            except ValueError:
+                verbose = 0
         self.verbose_set(verbose)
         self.combine = combine
         if not match is None:
@@ -715,6 +720,19 @@ class TestCmd:
             self.status = p.wait()
         if chdir:
             os.chdir(oldcwd)
+        if self.verbose >= 2:
+            write = sys.stdout.write
+            write('============ STATUS: %d\n' % self.status)
+            out = self.stdout()
+            if out or self.verbose >= 3:
+                write('============ BEGIN STDOUT (len=%d):\n' % len(out))
+                write(out)
+                write('============ END STDOUT\n')
+            err = self.stderr()
+            if err or self.verbose >= 3:
+                write('============ BEGIN STDERR (len=%d)\n' % len(err))
+                write(err)
+                write('============ END STDERR\n')
 
     def sleep(self, seconds = default_sleep_seconds):
         """Sleeps at least the specified number of seconds.  If no
index 76ee8f026027cac14ee1c4a54e65d1c51d4f5575..af38ab5fa86803f9d15b4a5488ba763f127275f4 100644 (file)
@@ -80,8 +80,8 @@ The TestCommon module also provides the following variables
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCommon.py 0.18.D001 2005/10/15 06:40:23 knight"
-__version__ = "0.18"
+__revision__ = "TestCommon.py 0.20.D001 2006/02/16 06:28:21 knight"
+__version__ = "0.20"
 
 import os
 import os.path
index e96ed8315af1bdd50a9d67dcd72d35dff9876d91..1530415c922b123f149251454ca06ee8ee907b2a 100644 (file)
@@ -140,6 +140,9 @@ Options:
   -q, --quiet                 Don't print the test being executed.
   -t, --time                  Print test execution time.
   -v version                  Specify the SCons version.
+  --verbose=LEVEL             Set verbose level: 1 = print executed commands,
+                                2 = print commands and non-zero output,
+                                3 = print commands and all output.
   -X                          Test script is executable, don't feed to Python.
   -x SCRIPT, --exec SCRIPT    Test SCRIPT.
   --xml                       Print results in SCons XML format.
@@ -150,7 +153,7 @@ opts, args = getopt.getopt(sys.argv[1:], "adf:ho:P:p:qv:Xx:t",
                              'debug', 'file=', 'help', 'output=',
                              'package=', 'passed', 'python=', 'quiet',
                              'version=', 'exec=', 'time',
-                             'xml'])
+                             'verbose=', 'xml'])
 
 for o, a in opts:
     if o == '-a' or o == '--all':
@@ -178,6 +181,8 @@ for o, a in opts:
         printcommand = 0
     elif o == '-t' or o == '--time':
         print_time = lambda fmt, time: sys.stdout.write(fmt % time)
+    elif o in ['--verbose']:
+        os.environ['TESTCMD_VERBOSE'] = a
     elif o == '-v' or o == '--version':
         version = a
     elif o == '-X':
@@ -235,7 +240,8 @@ except AttributeError:
             return status >> 8
 else:
     def spawn_it(command_args):
-       command_args = map(escape, command_args)
+        command_args = map(escape, command_args)
+        command_args = map(lambda s: string.replace(s, '\\','\\\\'), command_args)
         return os.spawnv(os.P_WAIT, command_args[0], command_args)
 
 class Base:
@@ -264,8 +270,8 @@ except AttributeError:
         def execute(self):
             (tochild, fromchild, childerr) = os.popen3(self.command_str)
             tochild.close()
-            self.stdout = fromchild.read()
             self.stderr = childerr.read()
+            self.stdout = fromchild.read()
             fromchild.close()
             self.status = childerr.close()
             if not self.status:
index 1455d140525c853b0fb04db8c64846ee96c1a6ec..a95891e7b13af00735086163e05a649e37ba4d0b 100644 (file)
@@ -133,6 +133,8 @@ RELEASE 0.97 - XXX
     $WINDOWSIMPLIBPREFIX construction variables.  The old names are now
     deprecated, but preserved for backwards compatibility.
 
+  - Fix (?) a runtest.py hang on Windows when the --xml option is used.
+
   From Chen Lee:
 
   - Add x64 support for Microsoft Visual Studio 8.
@@ -155,6 +157,9 @@ RELEASE 0.97 - XXX
 
   - Speed up the SCons/EnvironmentTests.py unit tests.
 
+  - Add a --verbose= option to runtest.py to print executed commands
+    and their output at various levels.
+
   From Christian Maaser:
 
   - Add support for Visual Studio Express Editions.