diff options
author | Steven Knight <knight@baldmt.com> | 2009-02-06 14:55:23 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2009-02-06 14:55:23 (GMT) |
commit | e112f6b49c9063e6a584ff4f7abf9d7a644eef30 (patch) | |
tree | 978573b4ff11f036428c0a08a89085313ad990fa /test/builderrors.py | |
parent | 9405dad6e18db3934eec7b992e12a2016b1466db (diff) | |
download | SCons-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/builderrors.py')
-rw-r--r-- | test/builderrors.py | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/test/builderrors.py b/test/builderrors.py index deb52a0..88260c0 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. |