# 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
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:
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
-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.
'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':
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':
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:
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:
$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.
- 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.