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 | |
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')
54 files changed, 182 insertions, 405 deletions
diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 914031b..f0a6158 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -30,7 +30,6 @@ the displayed archiver string. """ import TestSCons -import string _python_ = TestSCons._python_ @@ -67,8 +66,7 @@ test.write('file.2', "file.2\n/*ar*/\n") test.run() expect = 'Archiving output.lib from file.1 file.2' -test.fail_test(string.find(test.stdout(), expect) == -1) - +test.must_contain_all_lines(test.stdout(), [expect]) test.must_match('output.lib', "file.1\nfile.2\n") diff --git a/test/Actions/addpost-link.py b/test/Actions/addpost-link.py index 0a08cda..7721fde 100644 --- a/test/Actions/addpost-link.py +++ b/test/Actions/addpost-link.py @@ -85,6 +85,6 @@ test.must_not_exist('test1.obj') test.run(arguments="-Q case=2", stderr=None) expect = 'strip.py: %s' % test.workpath('test1.exe') -test.fail_test(string.find(test.stdout(), expect) == -1) +test.must_contain_all_lines(test.stdout(), [expect]) test.pass_test() diff --git a/test/CC/CFLAGS.py b/test/CC/CFLAGS.py index f14fcc5..6ccf7e2 100644 --- a/test/CC/CFLAGS.py +++ b/test/CC/CFLAGS.py @@ -24,7 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import sys, string +import sys import TestSCons test = TestSCons.TestSCons() @@ -38,8 +38,8 @@ print env.subst('$SHCXXCOM') print env.subst('$SHCXXCOMSTR') """) test.run(arguments = '.') -test.fail_test(string.find(test.stdout(), "-xyz") != -1) -test.fail_test(string.find(test.stdout(), "-abc") == -1) +test.must_not_contain_any_line(test.stdout(), ["-xyz"]) +test.must_contain_all_lines(test.stdout(), ["-abc"]) # Test passing CFLAGS to C compiler by actually compiling programs diff --git a/test/Configure/clean.py b/test/Configure/clean.py index a6ba7c1..3fcfcbd 100644 --- a/test/Configure/clean.py +++ b/test/Configure/clean.py @@ -66,15 +66,15 @@ lines = [ ] test.run(arguments = '-c clean=0') -test.must_not_contain_lines(lines, test.stdout()) +test.must_not_contain_any_line(test.stdout(), lines) test.run(arguments = '-c clean=1') -test.must_contain_lines(lines, test.stdout()) +test.must_contain_all_lines(test.stdout(), lines) test.run(arguments = '--clean clean=0') -test.must_not_contain_lines(lines, test.stdout()) +test.must_not_contain_any_line(test.stdout(), lines) test.run(arguments = '--clean clean=1') -test.must_contain_lines(lines, test.stdout()) +test.must_contain_all_lines(test.stdout(), lines) test.pass_test() diff --git a/test/Configure/help.py b/test/Configure/help.py index 32c68eb..9f58513 100644 --- a/test/Configure/help.py +++ b/test/Configure/help.py @@ -68,23 +68,23 @@ lines = [ # The help setting should have no effect on -H, so the -H output # should never contain the lines. test.run(arguments = '-H help=0') -test.must_not_contain_lines(lines, test.stdout()) +test.must_not_contain_any_line(test.stdout(), lines) test.run(arguments = '-H help=1') -test.must_not_contain_lines(lines, test.stdout()) +test.must_not_contain_any_line(test.stdout(), lines) # For -h and --help, the lines appear or not depending on how Configure() # is initialized. test.run(arguments = '-h help=0') -test.must_not_contain_lines(lines, test.stdout()) +test.must_not_contain_any_line(test.stdout(), lines) test.run(arguments = '-h help=1') -test.must_contain_lines(lines, test.stdout()) +test.must_contain_all_lines(test.stdout(), lines) test.run(arguments = '--help help=0') -test.must_not_contain_lines(lines, test.stdout()) +test.must_not_contain_any_line(test.stdout(), lines) test.run(arguments = '--help help=1') -test.must_contain_lines(lines, test.stdout()) +test.must_contain_all_lines(test.stdout(), lines) test.pass_test() diff --git a/test/Delete.py b/test/Delete.py index 63e4ab6..47f9d81 100644 --- a/test/Delete.py +++ b/test/Delete.py @@ -29,7 +29,6 @@ Verify that the Delete() Action works. """ import os.path -import string import TestSCons @@ -180,8 +179,11 @@ test.write('f14.in', "f14.in\n") test.run(status=2, stderr=None) -stderr = test.stderr() -test.fail_test(string.find(stderr, "No such file or directory") == -1 and - string.find(stderr, "The system cannot find the path specified") == -1) +fail_strings = [ + "No such file or directory", + "The system cannot find the path specified", +] + +test.must_contain_any_line(test.stderr(), fail_strings) test.pass_test() diff --git a/test/Deprecated/debug-dtree.py b/test/Deprecated/debug-dtree.py index 2aec880..8918052 100644 --- a/test/Deprecated/debug-dtree.py +++ b/test/Deprecated/debug-dtree.py @@ -31,7 +31,6 @@ dependencies (sources or Depends()) of a target. import TestSCons import sys -import string import re import time @@ -87,7 +86,7 @@ dtree1 = """ test.run(arguments = "--debug=dtree foo.xxx", stderr = stderr) -test.fail_test(string.find(test.stdout(), dtree1) == -1) +test.must_contain_all_lines(test.stdout(), [dtree1]) dtree2 = """ +-. @@ -99,7 +98,7 @@ dtree2 = """ """ test.run(arguments = "--debug=dtree .", stderr = stderr) -test.fail_test(string.find(test.stdout(), dtree2) == -1) +test.must_contain_all_lines(test.stdout(), [dtree2]) # Make sure we print the debug stuff even if there's a build failure. test.write('bar.h', """ @@ -113,6 +112,6 @@ THIS SHOULD CAUSE A BUILD FAILURE test.run(arguments = "--debug=dtree foo.xxx", status = 2, stderr = None) -test.fail_test(string.find(test.stdout(), dtree1) == -1) +test.must_contain_all_lines(test.stdout(), [dtree1]) test.pass_test() diff --git a/test/Deprecated/debug-tree.py b/test/Deprecated/debug-tree.py index 0703a16..73b8ec0 100644 --- a/test/Deprecated/debug-tree.py +++ b/test/Deprecated/debug-tree.py @@ -31,7 +31,6 @@ complete dependencies of a target. import TestSCons import sys -import string import re import time @@ -104,10 +103,7 @@ tree1 = """ test.run(arguments = "--debug=tree Foo.xxx", stderr = stderr) -if string.find(test.stdout(), tree1) == -1: - sys.stdout.write('Did not find expected tree in the following output:\n') - sys.stdout.write(test.stdout()) - test.fail_test() +test.must_contain_all_lines(test.stdout(), tree1) tree2 = """ +-. @@ -142,10 +138,7 @@ tree2 = """ test.run(arguments = "--debug=tree .", stderr = stderr) -if string.find(test.stdout(), tree2) == -1: - sys.stdout.write('Did not find expected tree in the following output:\n') - sys.stdout.write(test.stdout()) - test.fail_test() +test.must_contain_all_lines(test.stdout(), tree2) # Make sure we print the debug stuff even if there's a build failure. test.write('Bar.h', """ @@ -159,9 +152,6 @@ THIS SHOULD CAUSE A BUILD FAILURE test.run(arguments = "--debug=tree Foo.xxx", status = 2, stderr = None) -if string.find(test.stdout(), tree1) == -1: - sys.stdout.write('Did not find expected tree in the following output:\n') - sys.stdout.write(test.stdout()) - test.fail_test() +test.must_contain_all_lines(test.stdout(), tree1) test.pass_test() diff --git a/test/ENV.py b/test/ENV.py index 9a39f30..d7c543d 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -25,8 +25,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os -import string import sys + import TestSCons _python_ = TestSCons._python_ @@ -79,7 +79,11 @@ print 'FOO:', os.environ['FOO'] test.run() -test.fail_test(string.find(test.stdout(), "LIST: foo%sbar"%os.pathsep) == -1) -test.fail_test(string.find(test.stdout(), "FOO: foo") == -1) +expect = [ + "LIST: foo%sbar" % os.pathsep, + "FOO: foo", +] + +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py index 8485ce5..61bd74f 100644 --- a/test/Errors/Exception.py +++ b/test/Errors/Exception.py @@ -24,8 +24,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import string - import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) @@ -73,11 +71,6 @@ test.run(arguments='foo.out exit.out', stderr=expect, status=2) stdout = test.stdout() expect = "scons: `foo.out' is up to date." - -if string.find(stdout, expect) == -1: - print "Did not find expected string %s" % repr(expect) - print "STDOUT =======================================================" - print stdout - test.fail_test() +test.must_contain_all_lines(test.stdout(), [expect]) test.pass_test() diff --git a/test/Errors/execute-a-directory.py b/test/Errors/execute-a-directory.py index bcdcb7c..a13b4e0 100644 --- a/test/Errors/execute-a-directory.py +++ b/test/Errors/execute-a-directory.py @@ -99,11 +99,6 @@ else: Permission_denied % (test.workdir, 'f3'), Permission_denied % (test.workdir, 'f3'), ] - error_message_not_found = 1 - for err in errs: - if string.find(test.stderr(), err) != -1: - error_message_not_found = None - break - test.fail_test(error_message_not_found) + test.must_contain_any_line(test.stderr(), errs) test.pass_test() diff --git a/test/Errors/non-executable-file.py b/test/Errors/non-executable-file.py index d6e018b..3d5cd5b 100644 --- a/test/Errors/non-executable-file.py +++ b/test/Errors/non-executable-file.py @@ -93,11 +93,6 @@ else: Permission_denied % (not_executable, 'f1'), permission_denied % (not_executable, 'f1'), ] - error_message_not_found = 1 - for err in errs: - if string.find(test.stderr(), err) != -1: - error_message_not_found = None - break - test.fail_test(error_message_not_found) + test.must_contain_any_line(test.stderr(), errs) test.pass_test() diff --git a/test/Errors/nonexistent-executable.py b/test/Errors/nonexistent-executable.py index b2a9557..c2f7cfd 100644 --- a/test/Errors/nonexistent-executable.py +++ b/test/Errors/nonexistent-executable.py @@ -97,11 +97,6 @@ else: not_found_127 % (no_such_file, 'f1'), No_such % (no_such_file, 'f1'), ] - error_message_not_found = 1 - for err in errs: - if string.find(test.stderr(), err) != -1: - error_message_not_found = None - break - test.fail_test(error_message_not_found) + test.must_contain_any_line(test.stderr(), errs) test.pass_test() diff --git a/test/Java/no-JARCHDIR.py b/test/Java/no-JARCHDIR.py index 795689c..d0233f6 100644 --- a/test/Java/no-JARCHDIR.py +++ b/test/Java/no-JARCHDIR.py @@ -31,8 +31,6 @@ and when we explicity set it to None (it should not use the Java() classdir attribute at all). """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -75,13 +73,7 @@ foo/bar/a.class foo/bar/b.class """ -if string.find(test.stdout(), expect) == -1: - print "Did not find expected string in standard output." - print "Expected ==========================================================" - print expect - print "Output ============================================================" - print test.stdout() - test.fail_test() +test.must_contain_all_lines(test.stdout(), [expect]) @@ -109,13 +101,7 @@ classes/foo/bar/a.class classes/foo/bar/b.class """ -if string.find(test.stdout(), expect) == -1: - print "Did not find expected string in standard output." - print "Expected ==========================================================" - print expect - print "Output ============================================================" - print test.stdout() - test.fail_test() +test.must_contain_all_lines(test.stdout(), [expect]) diff --git a/test/PRINT_CMD_LINE_FUNC.py b/test/PRINT_CMD_LINE_FUNC.py index a95b181..0373a1e 100644 --- a/test/PRINT_CMD_LINE_FUNC.py +++ b/test/PRINT_CMD_LINE_FUNC.py @@ -28,7 +28,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test the PRINT_CMD_LINE_FUNC construction variable. """ -import string import sys import TestCmd import TestSCons @@ -60,14 +59,7 @@ expected_lines = [ "BUILDING prog%s from prog%s with" % (_exe, _obj), ] -missing_lines = filter(lambda l: string.find(test.stdout(), l) == -1, - expected_lines) -if missing_lines: - print "Expected the following lines in STDOUT:" - print "\t" + string.join(expected_lines, "\n\t") - print "ACTUAL STDOUT ==========" - print test.stdout() - test.fail_test(1) +test.must_contain_all_lines(test.stdout(), expected_lines) test.run(arguments = '-c .') diff --git a/test/ParseDepends.py b/test/ParseDepends.py index e979b91..9d7907d 100644 --- a/test/ParseDepends.py +++ b/test/ParseDepends.py @@ -25,7 +25,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path -import string import TestSCons @@ -152,6 +151,6 @@ ParseDepends('nonexistent_file', must_exist=1) test.run(status=2, stderr=None) -test.fail_test(string.find(test.stderr(), "No such file or directory") == -1) +test.must_contain_all_lines(test.stderr(), ["No such file or directory"]) test.pass_test() diff --git a/test/Repository/RMIC.py b/test/Repository/RMIC.py index bf8edff..f3c412b 100644 --- a/test/Repository/RMIC.py +++ b/test/Repository/RMIC.py @@ -28,8 +28,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test building Java applications when using Repositories. """ -import string - import TestSCons python = TestSCons.python @@ -275,8 +273,12 @@ public class Foo2 extends UnicastRemoteObject implements Hello { test.run(chdir = 'work1', options = opts, arguments = ".") -test.fail_test(string.find(test.stdout(), ' src/Foo1.java src/Foo2.java') == -1) -test.fail_test(string.find(test.stdout(), ' com.sub.foo.Foo1 com.sub.foo.Foo2') == -1) +expect = [ + ' src/Foo1.java src/Foo2.java', + ' com.sub.foo.Foo1 com.sub.foo.Foo2', +] + +test.must_contain_all_lines(test.stdout(), expect) # XXX I'd rather run the resulting class files through the JVM here to # see that they were built from the proper work1 sources, but I don't diff --git a/test/SCCS/diskcheck.py b/test/SCCS/diskcheck.py index ee29143..1845dc3 100644 --- a/test/SCCS/diskcheck.py +++ b/test/SCCS/diskcheck.py @@ -123,14 +123,7 @@ cat(["sub/fff.out"], ["sub/fff.in"]) cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) """, '\n') -stdout = test.stdout() -missing = filter(lambda l, s=stdout: string.find(s, l) == -1, lines) -if missing: - print "Missing the following output lines:" - print string.join(missing, '\n') - print "Actual STDOUT ==========" - print stdout - test.fail_test(1) +test.must_contain_all_lines(test.stdout(), lines) test.must_match('all', """\ s.aaa.in aaa.in diff --git a/test/SCCS/explicit.py b/test/SCCS/explicit.py index 0a52ace..dbfcb51 100644 --- a/test/SCCS/explicit.py +++ b/test/SCCS/explicit.py @@ -109,14 +109,7 @@ cat(["sub/fff.out"], ["sub/fff.in"]) cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) """, '\n') -stdout = test.stdout() -missing = filter(lambda l, s=stdout: string.find(s, l) == -1, lines) -if missing: - print "Missing the following output lines:" - print string.join(missing, '\n') - print "Actual STDOUT ==========" - print stdout - test.fail_test(1) +test.must_contain_all_lines(test.stdout(), lines) test.must_match('all', """\ %F% aaa.in diff --git a/test/SCCS/implicit.py b/test/SCCS/implicit.py index eca8e0c..aa5501f 100644 --- a/test/SCCS/implicit.py +++ b/test/SCCS/implicit.py @@ -75,14 +75,7 @@ sccs get foo.c sccs get foo.h """, '\n') -stdout = test.stdout() -missing = filter(lambda l, s=stdout: string.find(s, l) == -1, lines) -if missing: - print "Missing the following output lines:" - print string.join(missing, '\n') - print "Actual STDOUT ==========" - print stdout - test.fail_test(1) +test.must_contain_all_lines(test.stdout(), lines) diff --git a/test/SCCS/transparent.py b/test/SCCS/transparent.py index 384e27c..82577d2 100644 --- a/test/SCCS/transparent.py +++ b/test/SCCS/transparent.py @@ -109,14 +109,7 @@ cat(["sub/fff.out"], ["sub/fff.in"]) cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) """, '\n') -stdout = test.stdout() -missing = filter(lambda l, s=stdout: string.find(s, l) == -1, lines) -if missing: - print "Missing the following output lines:" - print string.join(missing, '\n') - print "Actual STDOUT ==========" - print stdout - test.fail_test(1) +test.must_contain_all_lines(test.stdout(), lines) test.must_match('all', """\ s.aaa.in aaa.in diff --git a/test/SCONSFLAGS.py b/test/SCONSFLAGS.py index fd0049c..e64e687 100644 --- a/test/SCONSFLAGS.py +++ b/test/SCONSFLAGS.py @@ -25,7 +25,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os -import string import TestCmd import TestSCons @@ -61,8 +60,8 @@ test.run(stdout = expect, # for the deprecation warning. test.run(arguments = "-H") -test.fail_test(string.find(test.stdout(), 'Help text.') >= 0) -test.fail_test(string.find(test.stdout(), '-H, --help-options') == -1) +test.must_not_contain_any_line(test.stdout(), ['Help text.']) +test.must_contain_all_lines(test.stdout(), ['-H, --help-options']) os.environ['SCONSFLAGS'] = '-Z' diff --git a/test/SideEffect/parallel.py b/test/SideEffect/parallel.py index 7c9bc27..de4f578 100644 --- a/test/SideEffect/parallel.py +++ b/test/SideEffect/parallel.py @@ -29,8 +29,6 @@ Verify that targets with the same SideEffect are not built in parallel when the -j option is used. """ -import string - import TestSCons _python_ = TestSCons._python_ @@ -80,8 +78,6 @@ test.write('baz.in', 'baz.in\n') test.run(arguments = "-j 4 .") -stdout = test.stdout() - build_lines = [ 'build.py h1.in h1.out', @@ -89,20 +85,7 @@ build_lines = [ 'build.py f3.in f3.out', ] -missing = [] -for line in build_lines: - if string.find(stdout, line) == -1: - missing.append(line) - -if missing: - print "===== standard output is missing the following lines:" - print string.join(missing, '\n') - print "===== STDOUT ========================================" - print stdout - test.fail_test() - - -log = test.read('log.txt') +test.must_contain_all_lines(test.stdout(), build_lines) log_lines = [ 'f3.in -> f3.out', @@ -110,17 +93,7 @@ log_lines = [ 'g2.in -> g2.out', ] -missing = [] -for line in log_lines: - if string.find(log, line) == -1: - missing.append(line) - -if missing: - print "===== log file 'log.txt' is missing the following lines:" - print string.join(missing, '\n') - print "===== STDOUT ===========================================" - print log - test.fail_test() +test.must_contain_all_lines(test.read('log.txt'), log_lines) test.pass_test() diff --git a/test/TEX/bibliography.py b/test/TEX/bibliography.py index a1943c0..1e09af2 100644 --- a/test/TEX/bibliography.py +++ b/test/TEX/bibliography.py @@ -31,8 +31,6 @@ be aware of the necessary created bibliography files. Test configuration contributed by Christopher Drexler. """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -111,7 +109,7 @@ test.must_exist(test.workpath('simple.blg')) test.run(arguments = '-c .') x = "Could not remove 'simple.aux': No such file or directory" -test.fail_test(string.find(test.stdout(), x) != -1) +test.must_not_contain_any_line(test.stdout(), [x]) test.must_not_exist(test.workpath('simple.aux')) test.must_not_exist(test.workpath('simple.bbl')) diff --git a/test/TEX/makeindex.py b/test/TEX/makeindex.py index 765ef4d..a41c9a7 100644 --- a/test/TEX/makeindex.py +++ b/test/TEX/makeindex.py @@ -31,8 +31,6 @@ aware of the necessary created index files. Test configuration courtesy Joel B. Mohler. """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -93,9 +91,9 @@ test.must_not_exist(test.workpath('no_index.ind')) test.run(arguments = '-c .') x = "Could not remove 'no_index.aux': No such file or directory" -test.fail_test(string.find(test.stdout(), x) != -1) +test.must_not_contain_any_line(test.stdout(), [x]) x = "Could not remove 'simple.aux': No such file or directory" -test.fail_test(string.find(test.stdout(), x) != -1) +test.must_not_contain_any_line(test.stdout(), [x]) test.must_not_exist(test.workpath('simple.aux')) test.must_not_exist(test.workpath('simple.idx')) diff --git a/test/TEX/multi-run.py b/test/TEX/multi-run.py index 2659e16..acca069 100644 --- a/test/TEX/multi-run.py +++ b/test/TEX/multi-run.py @@ -32,8 +32,6 @@ correctly re-run to resolve undefined references. Also verifies that package warnings are caught and re-run as needed. """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -151,10 +149,7 @@ env.PDF( "foo.tex" ) test.must_exist(['work1', 'foo.bbl']) foo_log = test.read(['work1', 'foo.log']) - if string.find(foo_log, 'undefined references') != -1: - print 'foo.log contains "undefined references":' - print foo_log - test.fail_test(1) + test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log') test.write(['work3', 'SConstruct'], """\ import os @@ -168,10 +163,7 @@ env.DVI( "foo3.tex" ) test.run(chdir = 'work3', arguments = '.') foo_log = test.read(['work3', 'foo3.log']) - if string.find(foo_log, 'Rerun LaTeX') != -1: - print 'foo.log contains "Rerun LaTeX":' - print foo_log - test.fail_test(1) + test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log') @@ -193,10 +185,7 @@ env.PDF( "foo.ltx" ) test.must_exist(['work2', 'foo.bbl']) foo_log = test.read(['work2', 'foo.log']) - if string.find(foo_log, 'undefined references') != -1: - print 'foo.log contains "undefined references":' - print foo_log - test.fail_test(1) + test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log') test.write(['work3', 'SConstruct'], """\ import os @@ -211,10 +200,7 @@ env.PDF( "foo3.tex" ) test.run(chdir = 'work3', arguments = '.') foo_log = test.read(['work3', 'foo3.log']) - if string.find(foo_log, 'Rerun LaTeX') != -1: - print 'foo.log contains "Rerun LaTeX":' - print foo_log - test.fail_test(1) + test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log') test.write(['work4', 'SConstruct'], """\ diff --git a/test/Value.py b/test/Value.py index 01647e3..01cb370 100644 --- a/test/Value.py +++ b/test/Value.py @@ -26,7 +26,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import re -import string import sys import TestSCons import TestCmd @@ -99,10 +98,7 @@ for source_signature in ['MD5', 'timestamp-newer']: out3 = """create\\(\\["f3.out"\\], \\[<.*.Custom instance at """ #" <- unconfuses emacs syntax highlighting - test.fail_test(string.find(test.stdout(), out1) == -1) - test.fail_test(string.find(test.stdout(), out2) == -1) - test.fail_test(string.find(test.stdout(), out7) == -1) - test.fail_test(string.find(test.stdout(), out8) == -1) + test.must_contain_all_lines(test.stdout(), [out1, out2, out7, out8]) test.fail_test(re.search(out3, test.stdout()) == None) test.must_match('f1.out', "/usr/local") @@ -118,8 +114,7 @@ for source_signature in ['MD5', 'timestamp-newer']: out5 = """create(["f2.out"], [4])""" out6 = """create\\(\\["f3.out"\\], \\[<.*.Custom instance at """ #" <- unconfuses emacs syntax highlighting - test.fail_test(string.find(test.stdout(), out4) == -1) - test.fail_test(string.find(test.stdout(), out5) == -1) + test.must_contain_all_lines(test.stdout(), [out4, out5]) test.fail_test(re.search(out6, test.stdout()) == None) test.must_match('f1.out', "/usr") @@ -134,10 +129,8 @@ for source_signature in ['MD5', 'timestamp-newer']: test.run(arguments='prefix=/var') out4 = """create(["f1.out"], ['/var'])""" - test.fail_test(string.find(test.stdout(), out4) == -1) - test.fail_test(string.find(test.stdout(), out5) != -1) - test.fail_test(string.find(test.stdout(), out7) == -1) - test.fail_test(string.find(test.stdout(), out8) == -1) + test.must_contain_all_lines(test.stdout(), [out4, out7, out8]) + test.must_not_contain_any_line(test.stdout(), [out5]) test.fail_test(re.search(out6, test.stdout()) == None) test.up_to_date('prefix=/var', '.') 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. diff --git a/test/diskcheck.py b/test/diskcheck.py index b8ef2fe..7e099c1 100644 --- a/test/diskcheck.py +++ b/test/diskcheck.py @@ -30,8 +30,6 @@ control where or not we look for on-disk matches files and directories that we look up. """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -50,7 +48,7 @@ File('subdir') test.run() test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.fail_test(string.find(test.stderr(), "found where file expected") == -1) +test.must_contain_all_lines(test.stderr(), ["found where file expected"]) @@ -62,7 +60,7 @@ Dir('file') test.run() test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.fail_test(string.find(test.stderr(), "found where directory expected") == -1) +test.must_contain_all_lines(test.stderr(), ["found where directory expected"]) @@ -74,7 +72,7 @@ Dir('file/subdir') test.run() test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.fail_test(string.find(test.stderr(), "found where directory expected") == -1) +test.must_contain_all_lines(test.stderr(), ["found where directory expected"]) diff --git a/test/exceptions.py b/test/exceptions.py index 98e3e83..12efdf0 100644 --- a/test/exceptions.py +++ b/test/exceptions.py @@ -26,7 +26,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import re -import string import sys import TestSCons import TestCmd @@ -122,18 +121,7 @@ expected_stderr_list = [ test.run(arguments = '-j7 -k .', status = 2, stderr = None) -missing = [] -for es in expected_stderr_list: - if string.find(test.stderr(), es) == -1: - missing.append(es) - -if missing: - sys.stderr.write("Missing the following lines from stderr:\n") - for m in missing: - sys.stderr.write(m) - sys.stderr.write('STDERR ===============================================\n') - sys.stderr.write(test.stderr()) - test.fail_test(1) +test.must_contain_all_lines(test.stderr(), expected_stderr_list) test.pass_test() diff --git a/test/implicit-cache/DualTargets.py b/test/implicit-cache/DualTargets.py index cf41640..a2afcc5 100644 --- a/test/implicit-cache/DualTargets.py +++ b/test/implicit-cache/DualTargets.py @@ -29,8 +29,6 @@ Test that --implicit-cache works correctly in conjonction with a builder that produces multiple targets. """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -84,7 +82,7 @@ test.must_exist('x.lib') test.must_exist('x.a') test.must_exist('x.b') -test.fail_test(string.find(test.stdout(), 'Copy') == -1) +test.must_contain_all_lines(test.stdout(), ['Copy']) # Double check that targets are not rebuilt. test.run(arguments = '.') @@ -93,7 +91,7 @@ test.must_exist('x.lib') test.must_exist('x.a') test.must_exist('x.b') -test.fail_test(string.find(test.stdout(), 'Copy') != -1) +test.must_not_contain_any_line(test.stdout(), ['Copy']) # Double check that targets are not rebuilt even with --implicit-cache test.run(arguments = '--implicit-cache x.a') @@ -102,7 +100,7 @@ test.must_exist('x.lib') test.must_exist('x.a') test.must_exist('x.b') -test.fail_test(string.find(test.stdout(), 'Copy') != -1) +test.must_not_contain_any_line(test.stdout(), ['Copy']) # Double check that targets are not rebuilt even with --implicit-cache # a second time. @@ -112,7 +110,7 @@ test.must_exist('x.lib') test.must_exist('x.a') test.must_exist('x.b') -test.fail_test(string.find(test.stdout(), 'Copy') != -1) +test.must_not_contain_any_line(test.stdout(), ['Copy']) # Double check that targets are not rebuilt if we reran without # --implicit-cache @@ -122,7 +120,7 @@ test.must_exist('x.lib') test.must_exist('x.a') test.must_exist('x.b') -test.fail_test(string.find(test.stdout(), 'Copy') != -1) +test.must_not_contain_any_line(test.stdout(), ['Copy']) # Double check again test.run(arguments = '.') @@ -131,7 +129,7 @@ test.must_exist('x.lib') test.must_exist('x.a') test.must_exist('x.b') -test.fail_test(string.find(test.stdout(), 'Copy') != -1) +test.must_not_contain_any_line(test.stdout(), ['Copy']) # Then only of the targets using --implicit-cache test.pass_test() diff --git a/test/no-global-dependencies.py b/test/no-global-dependencies.py index 3b6ba97..eb3e609 100644 --- a/test/no-global-dependencies.py +++ b/test/no-global-dependencies.py @@ -35,8 +35,6 @@ done to speed-up a partial rebuild when the developer knows that only a subset of the targets need to be rebuilt. """ -import string - import TestSCons test = TestSCons.TestSCons() @@ -92,12 +90,12 @@ test.must_not_exist('build/dir1/x.cpp') # Build everything first. test.run(arguments = 'duplicate=False view_all_dependencies=True .') test.must_exist('build/dir1/x.cpp') -test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1) +test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # Double check that targets are not rebuilt. test.run(arguments = 'duplicate=False view_all_dependencies=True .') test.must_exist('build/dir1/x.cpp') -test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1) +test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # Clean-up only the object file test.run(arguments = 'duplicate=False view_all_dependencies=False -c .') @@ -106,17 +104,17 @@ test.must_exist('build/dir1/x.cpp') # Rebuild the only object file without seeing all the dependencies. test.run(arguments = 'duplicate=False view_all_dependencies=False .') test.must_exist('build/dir1/x.cpp') -test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1) +test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # Double check that targets are not rebuilt without and with all the # dependencies. test.run(arguments = 'duplicate=False view_all_dependencies=False .') test.must_exist('build/dir1/x.cpp') -test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1) +test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) test.run(arguments = 'duplicate=False view_all_dependencies=True .') test.must_exist('build/dir1/x.cpp') -test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1) +test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # Clean-up everything. test.run(arguments = 'duplicate=False view_all_dependencies=True -c .') @@ -136,12 +134,12 @@ test.must_not_exist('build/dir1/x.cpp') # # Build everything first. # test.run(arguments = 'duplicate=True view_all_dependencies=True .') # test.must_exist('build/dir1/x.cpp') -# test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1) +# test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # # Double check that targets are not rebuilt. # test.run(arguments = 'duplicate=True view_all_dependencies=True .') # test.must_exist('build/dir1/x.cpp') -# test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1) +# test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # # Clean-up only the object file # test.run(arguments = 'duplicate=True view_all_dependencies=False -c .') @@ -150,17 +148,17 @@ test.must_not_exist('build/dir1/x.cpp') # # Rebuild the only object file without seeing all the dependencies. # test.run(arguments = 'duplicate=True view_all_dependencies=False .') # test.must_exist('build/dir1/x.cpp') -# test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1) +# test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # # Double check that targets are not rebuilt without and with all the # # dependencies. # test.run(arguments = 'duplicate=True view_all_dependencies=False .') # test.must_exist('build/dir1/x.cpp') -# test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1) +# test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # test.run(arguments = 'duplicate=True view_all_dependencies=True .') # test.must_exist('build/dir1/x.cpp') -# test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1) +# test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # # Clean-up everything. # test.run(arguments = 'duplicate=True view_all_dependencies=True -c .') diff --git a/test/option-j.py b/test/option-j.py index ffb290c..4a3669b 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -146,7 +146,7 @@ warn = \ """scons: warning: parallel builds are unsupported by this version of Python; \tignoring -j or num_jobs option. """ -test.fail_test(string.find(test.stderr(), warn) == -1) +test.must_contain_all_lines(test.stderr(), [warn]) str = test.read("f1") start1,finish1 = map(float, string.split(str, "\n")) diff --git a/test/option/debug-includes.py b/test/option/debug-includes.py index de9b288..b923306 100644 --- a/test/option/debug-includes.py +++ b/test/option/debug-includes.py @@ -31,7 +31,6 @@ dependencies of a target. import TestSCons import sys -import string import re import time @@ -88,13 +87,7 @@ includes = """ """ test.run(arguments = "--debug=includes foo.obj") -if string.find(test.stdout(), includes) == -1: - print "Did not find expected string in standard output." - print "Expected ==========================================================" - print includes - print "Actual ============================================================" - print test.stdout() - test.fail_test() +test.must_contain_all_lines(test.stdout(), [includes]) @@ -115,7 +108,7 @@ if string.find(test.stdout(), includes) == -1: #test.run(arguments = "--debug=includes foo.exe", # status = 2, # stderr = None) -#test.fail_test(string.find(test.stdout(), includes) == -1) +#test.must_contain_all_lines(test.stdout(), [includes]) diff --git a/test/option/debug-memoizer.py b/test/option/debug-memoizer.py index 7d984de..709f2b1 100644 --- a/test/option/debug-memoizer.py +++ b/test/option/debug-memoizer.py @@ -30,8 +30,6 @@ Test calling the --debug=memoizer option. import os import new -import string - import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) @@ -85,14 +83,7 @@ if use_metaclass: def run_and_check(test, args, desc): test.run(arguments = args) - stdout = test.stdout() - missing = filter(lambda e, s=stdout: string.find(s, e) == -1, expect) - if missing: - print "Missing the following strings in the %s output:" % desc - print " " + string.join(missing, "\n ") - print "STDOUT ============" - print stdout - test.fail_test() + test.must_contain_any_line(test.stdout(), expect) else: @@ -104,14 +95,7 @@ scons: warning: memoization is not supported in this version of Python \\(%s\\) def run_and_check(test, args, desc): test.run(arguments = args, stderr = expect_no_metaclasses) - stdout = test.stdout() - present = filter(lambda e, s=stdout: string.find(s, e) != -1, expect) - if present: - print "The following unexpected strings are present in the %s output:" % desc - print " " + string.join(present, "\n ") - print "STDOUT ============" - print stdout - test.fail_test() + test.must_contain_not_contain_any_line(test.stdout(), expect) for args in ['-h --debug=memoizer', '--debug=memoizer']: diff --git a/test/option/debug-pdb.py b/test/option/debug-pdb.py index fa703d5..bd79d7f 100644 --- a/test/option/debug-pdb.py +++ b/test/option/debug-pdb.py @@ -24,8 +24,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import string - import TestSCons test = TestSCons.TestSCons() @@ -35,7 +33,6 @@ env = Environment() """) test.run(arguments = "--debug=pdb", stdin = "n\ns\nq\n") -test.fail_test(string.find(test.stdout(), "(Pdb)") == -1) -test.fail_test(string.find(test.stdout(), "SCons") == -1) +test.must_contain_all_lines(test.stdout(), ["(Pdb)", "SCons"]) test.pass_test() 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) diff --git a/test/option/h.py b/test/option/h.py index bf6a6ae..f921333 100644 --- a/test/option/h.py +++ b/test/option/h.py @@ -24,36 +24,34 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import string - import TestSCons test = TestSCons.TestSCons() test.run(arguments = '-h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.run(arguments = '-u -h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.run(arguments = '-U -h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.run(arguments = '-D -h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.write('SConstruct', "") test.run(arguments = '-h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.run(arguments = '-u -h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.run(arguments = '-U -h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.run(arguments = '-D -h') -test.fail_test(string.find(test.stdout(), '-h, --help') == -1) +test.must_contain_all_lines(test.stdout(), ['-h, --help']) test.pass_test() diff --git a/test/option/help-options.py b/test/option/help-options.py index 5f8270f..f33ae52 100644 --- a/test/option/help-options.py +++ b/test/option/help-options.py @@ -39,8 +39,11 @@ test.write('SConstruct', "") test.run(arguments = '-H') -test.fail_test(string.find(test.stdout(), '-H, --help-options') == -1) -test.fail_test(string.find(test.stdout(), '--debug=TYPE') == -1) +expect = [ + '-H, --help-options', + '--debug=TYPE', +] +test.must_contain_all_lines(test.stdout(), expect) # Validate that the help output lists the options in case-insensitive # alphabetical order. diff --git a/test/option/profile.py b/test/option/profile.py index d0c0ffc..aafebda 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -46,7 +46,7 @@ test.write('file.in', "file.in\n") scons_prof = test.workpath('scons.prof') test.run(arguments = "--profile=%s -h" % scons_prof) -test.fail_test(string.find(test.stdout(), 'usage: scons [OPTION]') == -1) +test.must_contain_all_lines(test.stdout(), ['usage: scons [OPTION]']) try: save_stdout = sys.stdout @@ -61,8 +61,7 @@ try: finally: sys.stdout = save_stdout -test.fail_test(string.find(s, 'Main.py') == -1) -test.fail_test(string.find(s, '_main') == -1) +test.must_contain_all_lines(s, ['Main.py', '_main']) @@ -83,17 +82,18 @@ try: finally: sys.stdout = save_stdout -test.fail_test(string.find(s, 'Main.py') == -1) -test.fail_test(string.find(s, '_main') == -1) -test.fail_test(string.find(s, 'FS.py') == -1) +test.must_contain_all_lines(s, ['Main.py', '_main', 'FS.py']) scons_prof = test.workpath('scons3.prof') test.run(arguments = "--profile %s --debug=memory -h" % scons_prof) -test.fail_test(string.find(test.stdout(), 'usage: scons [OPTION]') == -1) -test.fail_test(string.find(test.stdout(), 'Options:') == -1) +expect = [ + 'usage: scons [OPTION]', + 'Options:' +] +test.must_contain_all_lines(test.stdout(), expect) expect = 'Memory before reading SConscript files' lines = string.split(test.stdout(), '\n') diff --git a/test/option/tree-all.py b/test/option/tree-all.py index 0a0af7d..d569b31 100644 --- a/test/option/tree-all.py +++ b/test/option/tree-all.py @@ -134,10 +134,7 @@ tree2 = """ """ % locals() test.run(arguments = "--tree=all .") -if string.find(test.stdout(), tree2) == -1: - sys.stdout.write('Did not find expected tree in the following output:\n') - sys.stdout.write(test.stdout()) - test.fail_test() +test.must_contain_all_lines(test.stdout(), [tree2]) tree3 = """ +-. diff --git a/test/option/tree-derived.py b/test/option/tree-derived.py index 43735f8..3f7cb45 100644 --- a/test/option/tree-derived.py +++ b/test/option/tree-derived.py @@ -31,7 +31,6 @@ dependencies (sources or Depends()) of a target. import TestSCons import sys -import string import re import time @@ -80,7 +79,7 @@ dtree1 = """ """ test.run(arguments = "--tree=derived foo.xxx") -test.fail_test(string.find(test.stdout(), dtree1) == -1) +test.must_contain_all_lines(test.stdout(), [dtree1]) dtree2 = """ +-. @@ -92,7 +91,7 @@ dtree2 = """ """ test.run(arguments = "--tree=derived .") -test.fail_test(string.find(test.stdout(), dtree2) == -1) +test.must_contain_all_lines(test.stdout(), [dtree2]) dtree3 = """ +-. @@ -104,7 +103,7 @@ dtree3 = """ """ test.run(arguments = "--tree=derived,prune .") -test.fail_test(string.find(test.stdout(), dtree3) == -1) +test.must_contain_all_lines(test.stdout(), [dtree3]) dtree4 = """ E = exists @@ -126,7 +125,7 @@ dtree4 = """ test.run(arguments = '-c foo.xxx') test.run(arguments = "--no-exec --tree=derived,status foo.xxx") -test.fail_test(string.find(test.stdout(), dtree4) == -1) +test.must_contain_all_lines(test.stdout(), [dtree4]) # Make sure we print the debug stuff even if there's a build failure. test.write('bar.h', """ @@ -140,6 +139,6 @@ THIS SHOULD CAUSE A BUILD FAILURE test.run(arguments = "--tree=derived foo.xxx", status = 2, stderr = None) -test.fail_test(string.find(test.stdout(), dtree1) == -1) +test.must_contain_all_lines(test.stdout(), [dtree1]) test.pass_test() diff --git a/test/option/tree-lib.py b/test/option/tree-lib.py index 8858b74..d1fdcd2 100644 --- a/test/option/tree-lib.py +++ b/test/option/tree-lib.py @@ -33,7 +33,6 @@ on disk.) Issue 1363: http://scons.tigris.org/issues/show_bug.cgi?id=1363 """ -import string import sys import TestSCons @@ -78,10 +77,7 @@ expect = """ """ test.run(arguments = '--tree=derived foo.h') -if string.find(test.stdout(), expect) == -1: - sys.stdout.write('Did not find expected tree in the following output:\n') - sys.stdout.write(test.stdout()) - test.fail_test() +test.must_contain_all_lines(test.stdout(), [expect]) test.up_to_date(arguments = 'foo.h') diff --git a/test/packaging/rpm/tagging.py b/test/packaging/rpm/tagging.py index d0fce83..c08b4ef 100644 --- a/test/packaging/rpm/tagging.py +++ b/test/packaging/rpm/tagging.py @@ -29,7 +29,6 @@ Test the ability to add file tags """ import os -import string import TestSCons @@ -97,6 +96,6 @@ test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') expect = '(0755, root, users) /bin/main' -test.fail_test(string.find(test.read('foo-1.2.3.spec'), expect) == -1) +test.must_contain_all_lines(test.read('foo-1.2.3.spec'), [expect]) test.pass_test() diff --git a/test/scons-time/func/help.py b/test/scons-time/func/help.py index 7341ade..c451b33 100644 --- a/test/scons-time/func/help.py +++ b/test/scons-time/func/help.py @@ -40,18 +40,18 @@ expect = [ test.run(arguments = 'func -h') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'func -?') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'func --help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'help func') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/scons-time/help/all-subcommands.py b/test/scons-time/help/all-subcommands.py index 6fa0fac..52842ab 100644 --- a/test/scons-time/help/all-subcommands.py +++ b/test/scons-time/help/all-subcommands.py @@ -53,6 +53,6 @@ expect = map(lambda x: ' %s ' % x, subcommands) test.run(arguments = 'help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/scons-time/help/options.py b/test/scons-time/help/options.py index 942dfa6..43f4427 100644 --- a/test/scons-time/help/options.py +++ b/test/scons-time/help/options.py @@ -42,18 +42,18 @@ expect = [ test.run(arguments = 'help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = '-h') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = '-?') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = '--help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/scons-time/mem/help.py b/test/scons-time/mem/help.py index 0658d5b..3adb121 100644 --- a/test/scons-time/mem/help.py +++ b/test/scons-time/mem/help.py @@ -40,18 +40,18 @@ expect = [ test.run(arguments = 'mem -h') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'mem -?') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'mem --help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'help mem') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/scons-time/obj/help.py b/test/scons-time/obj/help.py index 95abad6..0f21f4d 100644 --- a/test/scons-time/obj/help.py +++ b/test/scons-time/obj/help.py @@ -40,18 +40,18 @@ expect = [ test.run(arguments = 'obj -h') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'obj -?') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'obj --help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'help obj') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/scons-time/run/aegis.py b/test/scons-time/run/aegis.py index 641f129..eebd933 100644 --- a/test/scons-time/run/aegis.py +++ b/test/scons-time/run/aegis.py @@ -66,6 +66,8 @@ expect = [ content = test.read(test.workpath('foo-321-2.log')) -test.must_contain_all_lines('foo-617-2.log', content, expect, re.search) +def re_find(content, line): + return re.search(line, content) +test.must_contain_all_lines(content, expect, 'foo-617-2.log', re_find) test.pass_test() diff --git a/test/scons-time/run/option/help.py b/test/scons-time/run/option/help.py index 304992f..00a4eb7 100644 --- a/test/scons-time/run/option/help.py +++ b/test/scons-time/run/option/help.py @@ -42,18 +42,18 @@ expect = [ test.run(arguments = 'run -h') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'run -?') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'run --help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'help run') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/scons-time/run/subversion.py b/test/scons-time/run/subversion.py index 757f6df..d265422 100644 --- a/test/scons-time/run/subversion.py +++ b/test/scons-time/run/subversion.py @@ -67,6 +67,8 @@ expect = [ content = test.read(test.workpath('foo-617-2.log'), mode='r') -test.must_contain_all_lines('foo-617-2.log', content, expect, re.search) +def re_find(content, line): + return re.search(line, content) +test.must_contain_all_lines(content, expect, 'foo-617-2.log', re_find) test.pass_test() diff --git a/test/scons-time/time/help.py b/test/scons-time/time/help.py index 2f7cb67..aec4c6f 100644 --- a/test/scons-time/time/help.py +++ b/test/scons-time/time/help.py @@ -40,18 +40,18 @@ expect = [ test.run(arguments = 'time -h') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'time -?') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'time --help') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.run(arguments = 'help time') -test.must_contain_all_lines('Standard output', test.stdout(), expect) +test.must_contain_all_lines(test.stdout(), expect) test.pass_test() diff --git a/test/up-to-date.py b/test/up-to-date.py index 366d017..41d892e 100644 --- a/test/up-to-date.py +++ b/test/up-to-date.py @@ -28,8 +28,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Verify appropriate printing of "is up to date" messages. """ -import string - import TestSCons _python_ = TestSCons._python_ @@ -79,19 +77,7 @@ expected_lines = [ ] test.run(options = '-j4 f1.out f2.out f3.out f4.out') -stdout = test.stdout() - -missing = [] -for line in expected_lines: - if string.find(stdout, line) == -1: - missing.append(line) -if missing: - print "Missing the following expected lines:" - for line in missing: - print line - print "STDOUT ==========" - print stdout - test.fail_test() +test.must_contain_all_lines(test.stdout(), expected_lines) test.pass_test() |