summaryrefslogtreecommitdiff
path: root/test/builderrors.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2009-02-06 14:55:23 +0000
committerSteven Knight <knight@baldmt.com>2009-02-06 14:55:23 +0000
commita4d9a13b7a85f2c7f55fc409056e3b9628902022 (patch)
tree978573b4ff11f036428c0a08a89085313ad990fa /test/builderrors.py
parentf706866a1d840a6fc1251ad6c62e137c240967fd (diff)
downloadscons-a4d9a13b7a85f2c7f55fc409056e3b9628902022.tar.gz
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/builderrors.py')
-rw-r--r--test/builderrors.py43
1 files changed, 19 insertions, 24 deletions
diff --git a/test/builderrors.py b/test/builderrors.py
index deb52a07..88260c05 100644
--- a/test/builderrors.py
+++ b/test/builderrors.py
@@ -25,8 +25,8 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
-import string
import sys
+
import TestSCons
_python_ = TestSCons._python_
@@ -116,9 +116,7 @@ env.Command(target='foo.out', source=[], action='not_a_program')
""")
test.run(status=2, stderr=None)
-err = test.stderr()
-test.fail_test(string.find(err, 'Exception') != -1 or \
- string.find(err, 'Traceback') != -1)
+test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback'])
# Test ETOOLONG (arg list too long). This is not in exitvalmap,
@@ -133,14 +131,17 @@ env.Command(target='longcmd.out', source=[], action='echo %s')
"""%long_cmd)
test.run(status=2, stderr=None)
-err = test.stderr()
-test.fail_test(string.find(err, 'Exception') != -1 or \
- string.find(err, 'Traceback') != -1)
+
+test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback'])
+
# Python 1.5.2 on a FC3 system doesn't even get to the exitvalmap
# because it fails with "No such file or directory." Just comment
# this out for now, there are plenty of other good tests below.
-#test.fail_test(string.find(err, "too long") == -1 and # posix
-# string.find(err, "nvalid argument") == -1) # win32
+#expected = [
+# "too long", # posix
+# "nvalid argument", # win32
+#]
+#test.must_contain_any_line(test.stderr(), expected)
# Test bad shell ('./one' is a dir, so it can't be used as a shell).
@@ -156,15 +157,13 @@ env.Command(target='badshell.out', source=[], action='foo')
""")
test.run(status=2, stderr=None)
-err = test.stderr()
-if string.find(err, 'Exception') != -1 or string.find(err, 'Traceback') != -1:
- print "Exception or Traceback found in the following error output:"
- print err
- test.fail_test()
-if string.find(err, 'ermission') == -1 and string.find(err, 'such file') == -1:
- print "Missing '[Pp]ermission' or 'such file' string in the following error output:"
- print err
- test.fail_test()
+test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback'])
+expect = [
+ 'No such file',
+ 'Permission denied',
+ 'permission denied',
+]
+test.must_contain_any_line(test.stderr(), expect)
# Test command with exit status -1.
@@ -176,9 +175,7 @@ env.Command('dummy.txt', None, ['python -c "import sys; sys.exit(-1)"'])
""")
test.run(status=2, stderr=None)
-err = test.stderr()
-test.fail_test(string.find(err, 'Exception') != -1 or \
- string.find(err, 'Traceback') != -1)
+test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback'])
# Test SConscript with errors and an atexit function.
@@ -202,9 +199,7 @@ atexit.register(print_build_failures)
""")
test.run(status=2, stderr=None)
-err = test.stderr()
-test.fail_test(string.find(err, 'Exception') != -1 or \
- string.find(err, 'Traceback') != -1)
+test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback'])
# No tests failed; OK.