summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-07-15 12:39:34 (GMT)
committerSteven Knight <knight@baldmt.com>2004-07-15 12:39:34 (GMT)
commit502bdb0f465217b1b34bfd53cbf32385e40bdce5 (patch)
treec2864cbd6341ba776c90abb8c2cbb1456906a0a5 /etc
parent9378d5faa513dad65da961b279c92722d593be28 (diff)
downloadSCons-502bdb0f465217b1b34bfd53cbf32385e40bdce5.zip
SCons-502bdb0f465217b1b34bfd53cbf32385e40bdce5.tar.gz
SCons-502bdb0f465217b1b34bfd53cbf32385e40bdce5.tar.bz2
Win32 portability: add an explicit match argument to TestCommon.py, use it to only use match_re_dotall when we're using TestSCons.noisy_ar.
Diffstat (limited to 'etc')
-rw-r--r--etc/TestCmd.py16
-rw-r--r--etc/TestCommon.py68
-rw-r--r--etc/TestSCons.py5
3 files changed, 47 insertions, 42 deletions
diff --git a/etc/TestCmd.py b/etc/TestCmd.py
index 48aa204..9533398 100644
--- a/etc/TestCmd.py
+++ b/etc/TestCmd.py
@@ -175,8 +175,8 @@ version.
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCmd.py 0.7.D001 2004/07/08 10:02:13 knight"
-__version__ = "0.7"
+__revision__ = "TestCmd.py 0.8.D001 2004/07/15 06:24:14 knight"
+__version__ = "0.8"
import os
import os.path
@@ -496,7 +496,7 @@ class TestCmd:
"""
if not self._dirlist:
return
- os.chdir(self._cwd)
+ os.chdir(self._cwd)
self.workdir = None
if condition is None:
condition = self.condition
@@ -510,7 +510,7 @@ class TestCmd:
self.writable(dir, 1)
shutil.rmtree(dir, ignore_errors = 1)
self._dirlist = []
-
+
try:
global _Cleanup
_Cleanup.remove(self)
@@ -789,10 +789,10 @@ class TestCmd:
def where_is(self, file, path=None, pathext=None):
"""Find an executable file.
"""
- if is_List(file):
- file = apply(os.path.join, tuple(file))
- if not os.path.isabs(file):
- file = where_is(file, path, pathext)
+ if is_List(file):
+ file = apply(os.path.join, tuple(file))
+ if not os.path.isabs(file):
+ file = where_is(file, path, pathext)
return file
def workdir_set(self, path):
diff --git a/etc/TestCommon.py b/etc/TestCommon.py
index 8f4f22c..ff8a3f3 100644
--- a/etc/TestCommon.py
+++ b/etc/TestCommon.py
@@ -43,7 +43,8 @@ provided by the TestCommon class:
test.run(options = "options to be prepended to arguments",
stdout = "expected standard output from the program",
stderr = "expected error output from the program",
- status = expected_status)
+ status = expected_status,
+ match = match_function)
The TestCommon module also provides the following variables
@@ -75,8 +76,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.7.D001 2004/07/08 10:02:13 knight"
-__version__ = "0.7"
+__revision__ = "TestCommon.py 0.8.D001 2004/07/15 06:24:14 knight"
+__version__ = "0.8"
import os
import os.path
@@ -220,7 +221,7 @@ class TestCommon(TestCmd):
self.fail_test(not self.match(file_contents, expect))
except:
print "Unexpected contents of `%s'" % file
- print "EXPECTED contents ======"
+ print "EXPECTED contents ======"
print expect
print "ACTUAL contents ========"
print file_contents
@@ -240,7 +241,7 @@ class TestCommon(TestCmd):
def run(self, options = None, arguments = None,
stdout = None, stderr = '', status = 0, **kw):
- """Runs the program under test, checking that the test succeeded.
+ """Runs the program under test, checking that the test succeeded.
The arguments are the same as the base TestCmd.run() method,
with the addition of:
@@ -248,13 +249,13 @@ class TestCommon(TestCmd):
options Extra options that get appended to the beginning
of the arguments.
- stdout The expected standard output from
- the command. A value of None means
- don't test standard output.
+ stdout The expected standard output from
+ the command. A value of None means
+ don't test standard output.
- stderr The expected error output from
- the command. A value of None means
- don't test error output.
+ stderr The expected error output from
+ the command. A value of None means
+ don't test error output.
status The expected exit status from the
command. A value of None means don't
@@ -263,32 +264,37 @@ class TestCommon(TestCmd):
By default, this expects a successful exit (status = 0), does
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
- try:
- apply(TestCmd.run, [self], kw)
- except:
- print "STDOUT ============"
- print self.stdout()
- print "STDERR ============"
- print self.stderr()
- raise
- if _failed(self, status):
+ try:
+ match = kw['match']
+ del kw['match']
+ except KeyError:
+ match = self.match
+ try:
+ apply(TestCmd.run, [self], kw)
+ except:
+ print "STDOUT ============"
+ print self.stdout()
+ print "STDERR ============"
+ print self.stderr()
+ raise
+ if _failed(self, status):
expect = ''
if status != 0:
expect = " (expected %s)" % str(status)
print "%s returned %s%s" % (self.program, str(_status(self)), expect)
print "STDOUT ============"
print self.stdout()
- print "STDERR ============"
- print self.stderr()
- raise TestFailed
- if not stdout is None and not self.match(self.stdout(), stdout):
+ print "STDERR ============"
+ print self.stderr()
+ raise TestFailed
+ if not stdout is None and not match(self.stdout(), stdout):
print "Expected STDOUT =========="
print stdout
print "Actual STDOUT ============"
@@ -298,11 +304,11 @@ class TestCommon(TestCmd):
print "STDERR ==================="
print stderr
raise TestFailed
- if not stderr is None and not self.match(self.stderr(), stderr):
+ if not stderr is None and not match(self.stderr(), stderr):
print "STDOUT ==================="
print self.stdout()
- print "Expected STDERR =========="
- print stderr
- print "Actual STDERR ============"
- print self.stderr()
- raise TestFailed
+ print "Expected STDERR =========="
+ print stderr
+ print "Actual STDERR ============"
+ print self.stderr()
+ raise TestFailed
diff --git a/etc/TestSCons.py b/etc/TestSCons.py
index 737f8a2..202f5d5 100644
--- a/etc/TestSCons.py
+++ b/etc/TestSCons.py
@@ -188,6 +188,7 @@ class TestSCons(TestCommon):
arguments = options + " " + arguments
kw['arguments'] = arguments
kw['stdout'] = self.wrap_stdout(read_str = read_str, build_str = s)
+ kw['match'] = self.match_exact
apply(self.run, [], kw)
def not_up_to_date(self, options = None, arguments = None, **kw):
@@ -204,10 +205,8 @@ class TestSCons(TestCommon):
kw['stdout'] = self.wrap_stdout(build_str="("+s+"[^\n]*\n)*")
kw['stdout'] = string.replace(kw['stdout'],'\n','\\n')
kw['stdout'] = string.replace(kw['stdout'],'.','\\.')
- old_match_func = self.match_func
- self.match_func = match_re_dotall
+ kw['match'] = self.match_re_dotall
apply(self.run, [], kw)
- self.match_func = old_match_func
# In some environments, $AR will generate a warning message to stderr
# if the library doesn't previously exist and is being created. One