summaryrefslogtreecommitdiffstats
path: root/test/option/debug-stacktrace.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2009-02-06 14:55:23 (GMT)
committerSteven Knight <knight@baldmt.com>2009-02-06 14:55:23 (GMT)
commite112f6b49c9063e6a584ff4f7abf9d7a644eef30 (patch)
tree978573b4ff11f036428c0a08a89085313ad990fa /test/option/debug-stacktrace.py
parent9405dad6e18db3934eec7b992e12a2016b1466db (diff)
downloadSCons-e112f6b49c9063e6a584ff4f7abf9d7a644eef30.zip
SCons-e112f6b49c9063e6a584ff4f7abf9d7a644eef30.tar.gz
SCons-e112f6b49c9063e6a584ff4f7abf9d7a644eef30.tar.bz2
Commonize new string-search-in-output methods:
test.must_contain_all_lines() test.must_contain_any_line() test.must_not_contain_any_line() Update tests to use them. Remove "import string" lines where the change made them unnecessary.
Diffstat (limited to 'test/option/debug-stacktrace.py')
-rw-r--r--test/option/debug-stacktrace.py43
1 files changed, 9 insertions, 34 deletions
diff --git a/test/option/debug-stacktrace.py b/test/option/debug-stacktrace.py
index 93cb206..80915fd 100644
--- a/test/option/debug-stacktrace.py
+++ b/test/option/debug-stacktrace.py
@@ -29,26 +29,9 @@ Test the --debug=stacktrace option.
"""
import TestSCons
-import sys
-import string
-import re
-import time
test = TestSCons.TestSCons()
-def must_contain_all_lines(content, lines):
- missing = filter(lambda l, c=content: string.find(c, l) == -1, lines)
- if missing:
- return [
- "Missing the following lines:\n",
- "\t" + string.join(missing, "\n\t") + "\n",
- "Output =====\n",
- content
- ]
- return None
-
-
-
test.write('SConstruct', """\
def kfile_scan(node, env, target):
raise Exception, "kfile_scan error"
@@ -77,10 +60,7 @@ lines = [
'raise Exception, "kfile_scan error"',
]
-err = must_contain_all_lines(test.stderr(), lines)
-if err:
- print string.join(err, '')
- test.fail_test(1)
+test.must_contain_all_lines(test.stderr(), lines)
@@ -96,7 +76,7 @@ test.run(arguments = '--debug=stacktrace',
status = 2,
stderr = None)
-lines = [
+user_error_lines = [
'UserError: explicit UserError!',
'scons: *** explicit UserError!',
]
@@ -104,15 +84,13 @@ lines = [
# The "(most recent call last)" message is used by more recent Python
# versions than the "(innermost last)" message, so that's the one
# we report if neither matches.
-recent_lines = [ "Traceback (most recent call last)" ] + lines
-inner_lines = [ "Traceback (innermost last)" ] + lines
-
-err = must_contain_all_lines(test.stderr(), recent_lines)
-if err and must_contain_all_lines(test.stderr(), inner_lines):
- print string.join(err, '')
- test.fail_test(1)
-
+traceback_lines = [
+ "Traceback (most recent call last)",
+ "Traceback (innermost last)",
+]
+test.must_contain_all_lines(test.stderr(), user_error_lines)
+test.must_contain_any_line(test.stderr(), traceback_lines)
# Test that full path names to SConscript files show up in stack traces.
@@ -128,10 +106,7 @@ lines = [
' File "%s", line 1:' % test.workpath('SConstruct'),
]
-err = must_contain_all_lines(test.stderr(), lines)
-if err:
- print string.join(err, '')
- test.fail_test(1)
+test.must_contain_all_lines(test.stderr(), lines)