summaryrefslogtreecommitdiffstats
path: root/QMTest/TestCommon.py
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-05-26 16:17:09 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-05-26 16:17:09 (GMT)
commit545d2a0a389e9eacdb1d92fbf5f26f2d981029ad (patch)
tree23f5cda5c621bd7bb657ef9fd1d07e4578d4a934 /QMTest/TestCommon.py
parent5c2e07585593ee4994b8e7d79b3d181a56cd7f13 (diff)
downloadSCons-545d2a0a389e9eacdb1d92fbf5f26f2d981029ad.zip
SCons-545d2a0a389e9eacdb1d92fbf5f26f2d981029ad.tar.gz
SCons-545d2a0a389e9eacdb1d92fbf5f26f2d981029ad.tar.bz2
Start the deprecation cycle for the BuildDir() method and the build_dir
keyword parameter. Several existing tests were still using BuildDir() or build_dir; they were converted to use VariantDir() and variant_dir. New tests were added to validate that the --warn=deprecated-build-dir option and the SetOption method did the right thing. This led to the discovery that a commonly-used test pattern provided by the infrastructure gobbled up too much, causing tests to succeed when they should have failed. Fixing the pattern led to other tests needing to be fixed. In the process, it was discovered that the SCONSFLAG environment variable was not getting correctly reset to its original value. Fixing this also caused additional tests to misbehave, requiring them to be updated. And test/Sig.py, which tests the deprecated SCons.Sig module, was moved to the test/Deprecated directory. All in all, quite a lot of action for what was supposed to be a simple change.
Diffstat (limited to 'QMTest/TestCommon.py')
-rw-r--r--QMTest/TestCommon.py53
1 files changed, 28 insertions, 25 deletions
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index 6ee2bd5..1120b55 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -206,6 +206,22 @@ elif os.name == 'nt':
def _status(self):
return self.status
+def _options_arguments(options, arguments):
+ """
+ This handles the "options" keyword argument and merges it
+ with the arguments.
+ """
+ if options:
+ if arguments is None:
+ arguments = options
+ else:
+ if isinstance(options, str):
+ options = [options]
+ if isinstance(arguments, str):
+ arguments = [arguments]
+ arguments = ' '.join(options + arguments)
+ return arguments
+
class TestCommon(TestCmd):
# Additional methods from the Perl Test::Cmd::Common module
@@ -477,13 +493,15 @@ class TestCommon(TestCmd):
print self.banner('STDERR ')
print actual_stderr
self.fail_test()
- if not expected_stdout is None and not match(actual_stdout, expected_stdout):
+ if expected_stdout is not None \
+ and not match(actual_stdout, expected_stdout):
self.diff(expected_stdout, actual_stdout, 'STDOUT ')
if actual_stderr:
print self.banner('STDERR ')
print actual_stderr
self.fail_test()
- if not expected_stderr is None and not match(actual_stderr, expected_stderr):
+ if expected_stderr is not None \
+ and not match(actual_stderr, expected_stderr):
print self.banner('STDOUT ')
print actual_stdout
self.diff(expected_stderr, actual_stderr, 'STDERR ')
@@ -491,28 +509,18 @@ class TestCommon(TestCmd):
def start(self, program = None,
interpreter = None,
+ options = None,
arguments = None,
universal_newlines = None,
**kw):
"""
- Starts a program or script for the test environment.
-
- This handles the "options" keyword argument and exceptions.
+ Starts a program or script for the test environment, handling
+ any exceptions.
"""
+ arguments = _options_arguments(options, arguments)
try:
- options = kw['options']
- del kw['options']
- except KeyError:
- pass
- else:
- if options:
- if arguments is None:
- arguments = options
- else:
- arguments = options + " " + arguments
- try:
- return TestCmd.start(self, program, interpreter, arguments, universal_newlines,
- **kw)
+ return TestCmd.start(self, program, interpreter, arguments,
+ universal_newlines, **kw)
except KeyboardInterrupt:
raise
except Exception, e:
@@ -557,7 +565,7 @@ class TestCommon(TestCmd):
stdout = None, stderr = '', status = 0, **kw):
"""Runs the program under test, checking that the test succeeded.
- The arguments are the same as the base TestCmd.run() method,
+ The parameters are the same as the base TestCmd.run() method,
with the addition of:
options Extra options that get appended to the beginning
@@ -579,12 +587,7 @@ class TestCommon(TestCmd):
not test standard output (stdout = None), and expects that error
output is empty (stderr = "").
"""
- if options:
- if arguments is None:
- arguments = options
- else:
- arguments = options + " " + arguments
- kw['arguments'] = arguments
+ kw['arguments'] = _options_arguments(options, arguments)
try:
match = kw['match']
del kw['match']