From: stevenknight Date: Fri, 17 Feb 2006 11:13:44 +0000 (+0000) Subject: Add a --verbose option to runtest.py. (Baptiste Lepilleur) Fix (?) a deadlock using... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4fe9e6cff967201d8f9bf4855943fb0ecb9fdb25;p=scons.git Add a --verbose option to runtest.py. (Baptiste Lepilleur) Fix (?) a deadlock using the --xml option on Windows. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1426 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/etc/TestCmd.py b/etc/TestCmd.py index cd662459..a2635c97 100644 --- a/etc/TestCmd.py +++ b/etc/TestCmd.py @@ -176,8 +176,8 @@ version. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. __author__ = "Steven Knight " -__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 diff --git a/etc/TestCommon.py b/etc/TestCommon.py index 76ee8f02..af38ab5f 100644 --- a/etc/TestCommon.py +++ b/etc/TestCommon.py @@ -80,8 +80,8 @@ The TestCommon module also provides the following variables # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. __author__ = "Steven Knight " -__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 diff --git a/runtest.py b/runtest.py index e96ed831..1530415c 100644 --- a/runtest.py +++ b/runtest.py @@ -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: diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 1455d140..a95891e7 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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.