diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-03-13 15:44:48 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-03-13 15:44:48 (GMT) |
commit | be76fd27e51c16589d9167e279d4bb3820a8e5c1 (patch) | |
tree | 047342f83193101c13413e92c33eceddaa484bc5 | |
parent | cbe2deee53fd4d29f3144ae40715301f29440730 (diff) | |
parent | 3b23df1f6b2135739b988a497d98d85dd8a806fa (diff) | |
download | SCons-be76fd27e51c16589d9167e279d4bb3820a8e5c1.zip SCons-be76fd27e51c16589d9167e279d4bb3820a8e5c1.tar.gz SCons-be76fd27e51c16589d9167e279d4bb3820a8e5c1.tar.bz2 |
fix mistaken head close
75 files changed, 425 insertions, 394 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 96e07a9..e76b2e3 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -499,7 +499,7 @@ def match_re(lines = None, res = None): msg = "Regular expression error in %s: %s" raise re.error(msg % (repr(s), e.args[0])) if not expr.search(lines[i]): - print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i,s,lines[i])) + print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i, s, lines[i])) return return 1 @@ -672,7 +672,7 @@ except AttributeError: PIPE = subprocess.PIPE -if sys.platform == 'win32' and subprocess.mswindows: +if sys.platform == 'win32':# and subprocess.mswindows: try: from win32file import ReadFile, WriteFile from win32pipe import PeekNamedPipe @@ -734,7 +734,7 @@ class Popen(subprocess.Popen): getattr(self, which).close() setattr(self, which, None) - if sys.platform == 'win32' and subprocess.mswindows: + if sys.platform == 'win32':# and subprocess.mswindows: def send(self, input): if not self.stdin: return None diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 018a776..6d7b0a7 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -271,6 +271,7 @@ def render_tree(root, child_func, prune=0, margin=[0], visited=None): IDX = lambda N: N and 1 or 0 + def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): """ Print a tree of nodes. This is like render_tree, except it prints @@ -307,7 +308,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(unicode(legend)) + sys.stdout.write(legend) tags = ['['] tags.append(' E'[IDX(root.exists())]) diff --git a/test/CPPSUFFIXES.py b/test/CPPSUFFIXES.py index 6aa5596..141df29 100644 --- a/test/CPPSUFFIXES.py +++ b/test/CPPSUFFIXES.py @@ -49,6 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment(CPPPATH = ['.'], CC = r'%(_python_)s mycc.py', CCFLAGS = [], @@ -94,7 +95,7 @@ test1.h 1 foo.h 1 test1.x 1 foo.h 1 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -112,7 +113,7 @@ test1.h 1 foo.h 2 test1.x 1 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -134,7 +135,7 @@ test1.h 1 foo.h 2 test1.x 2 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -156,7 +157,7 @@ test1.h 2 foo.h 2 test1.x 2 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index 1a07b09..83c4285 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -151,15 +151,15 @@ test.write('test5.C++', r"""This is a .C++ file. test.run(arguments = '.', stderr = None) -test.must_match('test1' + _exe, "This is a .cc file.\n") +test.must_match('test1' + _exe, "This is a .cc file.\n", mode='r') -test.must_match('test2' + _exe, "This is a .cpp file.\n") +test.must_match('test2' + _exe, "This is a .cpp file.\n", mode='r') -test.must_match('test3' + _exe, "This is a .cxx file.\n") +test.must_match('test3' + _exe, "This is a .cxx file.\n", mode='r') -test.must_match('test4' + _exe, "This is a .c++ file.\n") +test.must_match('test4' + _exe, "This is a .c++ file.\n", mode='r') -test.must_match('test5' + _exe, "This is a .C++ file.\n") +test.must_match('test5' + _exe, "This is a .C++ file.\n", mode='r') if TestSCons.case_sensitive_suffixes('.c', '.C'): diff --git a/test/CXX/SHCXX.py b/test/CXX/SHCXX.py index d6a314e..0d1ad36 100644 --- a/test/CXX/SHCXX.py +++ b/test/CXX/SHCXX.py @@ -73,7 +73,8 @@ test.fail_test(os.path.exists(test.workpath('wrapper.out'))) test.run(arguments = 'bar') -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') +# test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.pass_test() diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py index fe73cad..45c5db5 100644 --- a/test/CacheDir/CacheDir.py +++ b/test/CacheDir/CacheDir.py @@ -89,8 +89,8 @@ test.fail_test(os.listdir(cache) != ['config']) # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -130,7 +130,7 @@ test.must_not_exist(src_all) # even though it doesn't report anything. test.run(chdir = 'src', arguments = '-s .', stdout = "") -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(src_cat_out) test.up_to_date(chdir = 'src', arguments = '.') @@ -148,8 +148,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match(['src', 'cat.out'], "bbb.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py index 386b16a..2ddba31 100644 --- a/test/CacheDir/SideEffect.py +++ b/test/CacheDir/SideEffect.py @@ -69,7 +69,7 @@ f1.in -> f1.out f2.in -> f2.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') @@ -84,7 +84,7 @@ f2.in -> f2.out f3.in -> f3.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') @@ -100,7 +100,7 @@ f3.in -> f3.out f1.in -> f1.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') diff --git a/test/CacheDir/VariantDir.py b/test/CacheDir/VariantDir.py index 30325d2..d31b9ed 100644 --- a/test/CacheDir/VariantDir.py +++ b/test/CacheDir/VariantDir.py @@ -75,8 +75,8 @@ SConscript('build/SConscript') # This should populate the cache with our derived files. test.run() -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all)) +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all), mode='r') test.up_to_date(arguments = '.') @@ -116,7 +116,7 @@ test.must_not_exist(test.workpath('build', 'all')) # even though it doesn't report anything. test.run(arguments = '-s .', stdout = "") -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(cat_out) test.up_to_date(arguments = '.') @@ -137,8 +137,8 @@ cat(["%s"], ["%s", "%s", "%s"]) build_ccc_out, build_all, build_aaa_out, build_bbb_out, build_ccc_out))) -test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all)) +test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all), mode='r') test.up_to_date(arguments = '.') diff --git a/test/CacheDir/environment.py b/test/CacheDir/environment.py index eb28c19..e37b999 100644 --- a/test/CacheDir/environment.py +++ b/test/CacheDir/environment.py @@ -92,8 +92,8 @@ test.fail_test(os.listdir(cache) != ['config']) # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -109,7 +109,7 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -134,9 +134,9 @@ test.must_not_exist(src_all) # even though it doesn't report anything. test.run(chdir = 'src', arguments = '-s .', stdout = "") -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -154,8 +154,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cd.py b/test/CacheDir/option--cd.py index efcf843..fad5add 100644 --- a/test/CacheDir/option--cd.py +++ b/test/CacheDir/option--cd.py @@ -62,8 +62,8 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -79,7 +79,7 @@ Retrieved `ccc.out' from cache Retrieved `all' from cache """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src', 'cat.out')) test.up_to_date(chdir = 'src', arguments = '.') @@ -97,8 +97,8 @@ cat(["ccc.out"], ["ccc.in"]) cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -116,8 +116,8 @@ cat(["ccc.out"], ["ccc.in"]) cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cf.py b/test/CacheDir/option--cf.py index ace0df6..bb9d1cc 100644 --- a/test/CacheDir/option--cf.py +++ b/test/CacheDir/option--cf.py @@ -38,6 +38,7 @@ test = TestSCons.TestSCons() test.subdir('cache', 'src') test.write(['src', 'SConstruct'], """ +DefaultEnvironment(tools=[]) def cat(env, source, target): target = str(target[0]) open('cat.out', 'a').write(target + "\\n") @@ -61,8 +62,10 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") -test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src','all'],"aaa.in\nbbb.in\nccc.in\n", mode='r') +# test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src','cat.out'],"aaa.out\nbbb.out\nccc.out\nall\n", mode='r') +# test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cr.py b/test/CacheDir/option--cr.py index 165e049..792dede 100644 --- a/test/CacheDir/option--cr.py +++ b/test/CacheDir/option--cr.py @@ -62,8 +62,8 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -80,7 +80,7 @@ Retrieved `ccc.out' from cache Retrieved `all' from cache """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src', 'cat.out')) test.up_to_date(chdir = 'src', arguments = '.') @@ -100,9 +100,9 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n", mode='r') # cat.out contains only the things we built (not got from cache) -test.must_match(['src', 'cat.out'], "aaa.out\nall\n") +test.must_match(['src', 'cat.out'], "aaa.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -120,8 +120,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nall\n") +test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cs.py b/test/CacheDir/option--cs.py index bff585d..2e37e5a 100644 --- a/test/CacheDir/option--cs.py +++ b/test/CacheDir/option--cs.py @@ -79,9 +79,9 @@ test.write(['src1', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src1', arguments = '.') -test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(['src1', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src1', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src1', arguments = '.') @@ -145,7 +145,7 @@ test.run(chdir = 'src1', arguments = '--cache-show -s .', stdout = "") -test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src1', 'cat.out')) # diff --git a/test/CacheDir/symlink.py b/test/CacheDir/symlink.py index ca3bbe2..e23c25e 100644 --- a/test/CacheDir/symlink.py +++ b/test/CacheDir/symlink.py @@ -21,6 +21,10 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +import os +import sys + +import TestSCons __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -29,13 +33,13 @@ Verify that we push and retrieve a built symlink to/from a CacheDir() as an actualy symlink, not by copying the file contents. """ -import os -import TestSCons + test = TestSCons.TestSCons() -if not hasattr(os, 'symlink'): +if not hasattr(os, 'symlink') or sys.platform == 'win32': + # Skip test on windows as well, because this requires permissions which aren't default import sys test.skip_test('%s has no os.symlink() method; skipping test\n' % sys.executable) diff --git a/test/Command.py b/test/Command.py index 5f72c94..38aceb5 100644 --- a/test/Command.py +++ b/test/Command.py @@ -35,8 +35,8 @@ test.subdir('sub') test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() """) @@ -45,8 +45,8 @@ test.write('SConstruct', """ import os def buildIt(env, target, source): - contents = open(str(source[0]), 'rb').read() - file = open(str(target[0]), 'wb') + contents = open(str(source[0]), 'r').read() + file = open(str(target[0]), 'w') xyzzy = env.get('XYZZY', '') if xyzzy: file.write(xyzzy + '\\n') @@ -57,9 +57,9 @@ def buildIt(env, target, source): def sub(env, target, source): target = str(target[0]) source = str(source[0]) - t = open(target, 'wb') + t = open(target, 'w') for f in sorted(os.listdir(source)): - t.write(open(os.path.join(source, f), 'rb').read()) + t.write(open(os.path.join(source, f), 'r').read()) t.close() return 0 @@ -103,16 +103,16 @@ test.write('f10.in', "f10.in\n") test.run(arguments = '.') -test.must_match('f1.out', "f1.in\n") -test.must_match('f2.out', "f2.in\n") -test.must_match('f3.out', "f3.in\n") -test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n") -test.must_match('f5.out', "XYZZY is set\nf5.in\n") -test.must_match('f6.out', "f6.in\n") -test.must_match('f7.out', "f7.in\n") -test.must_match('f8.out', "f8.in\n") -test.must_match('f9.out', "f9.in\n") -test.must_match('f10.out', "f10.in\n") +test.must_match('f1.out', "f1.in\n", mode='r') +test.must_match('f2.out', "f2.in\n", mode='r') +test.must_match('f3.out', "f3.in\n", mode='r') +test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n", mode='r') +test.must_match('f5.out', "XYZZY is set\nf5.in\n", mode='r') +test.must_match('f6.out', "f6.in\n", mode='r') +test.must_match('f7.out', "f7.in\n", mode='r') +test.must_match('f8.out', "f8.in\n", mode='r') +test.must_match('f9.out', "f9.in\n", mode='r') +test.must_match('f10.out', "f10.in\n", mode='r') test.pass_test() diff --git a/test/CommandGenerator.py b/test/CommandGenerator.py index 063999d..a3a995b 100644 --- a/test/CommandGenerator.py +++ b/test/CommandGenerator.py @@ -34,8 +34,8 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() sys.exit(0) @@ -64,9 +64,9 @@ test.write('foo3.in', "foo3.in\n") test.run(arguments = 'foo1.out foo2.out foo3.out') -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match('foo1.out','foo1.in\n', mode='r') +test.must_match('foo2.out','foo2.in\n', mode='r') +test.must_match('foo3.out','foo3.in\n', mode='r') test.pass_test() diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py index 3704d60..30d0e4f 100644 --- a/test/DVIPDF/DVIPDFFLAGS.py +++ b/test/DVIPDF/DVIPDFFLAGS.py @@ -100,9 +100,9 @@ test.write('test2.tex', r"""This is a .tex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.pdf', " -x\nThis is a .dvi test.\n") +test.must_match('test1.pdf', " -x\nThis is a .dvi test.\n", mode='r') -test.must_match('test2.pdf', " -x\nThis is a .tex test.\n") +test.must_match('test2.pdf', " -x\nThis is a .tex test.\n", mode='r') @@ -149,21 +149,21 @@ This is the %s LaTeX file. test.write('bar.tex', tex % 'bar.tex') - test.run(arguments = 'foo.pdf', stderr = None) + test.run(arguments='foo.pdf', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_exist(test.workpath('foo.pdf')) - test.run(arguments = 'xxx.pdf', stderr = None) + test.run(arguments='xxx.pdf', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_not_exist(test.workpath('xxx.dvi')) - test.run(arguments = 'bar.pdf', stderr = None) + test.run(arguments='bar.pdf', stderr=None) - test.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n") + test.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n", mode='r') test.must_exist(test.workpath('bar.pdf')) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index 43b5be5..814c8aa 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -41,7 +41,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'r') out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:4] != b'#tex': + if l[:4] != '#tex': out_file.write(l) sys.exit(0) """) @@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'r') out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:6] != b'#latex': + if l[:6] != '#latex': out_file.write(l) sys.exit(0) """) @@ -112,13 +112,13 @@ test.write('test4.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.ps', " -x\nThis is a .dvi test.\n") +test.must_match('test1.ps', " -x\nThis is a .dvi test.\n", mode='r') -test.must_match('test2.ps', " -x\nThis is a .tex test.\n") +test.must_match('test2.ps', " -x\nThis is a .tex test.\n", mode='r') -test.must_match('test3.ps', " -x\nThis is a .ltx test.\n") +test.must_match('test3.ps', " -x\nThis is a .ltx test.\n", mode='r') -test.must_match('test4.ps', " -x\nThis is a .latex test.\n") +test.must_match('test4.ps', " -x\nThis is a .latex test.\n", mode='r') dvips = test.where_is('dvips') @@ -161,20 +161,20 @@ This is the %s LaTeX file. test.write('bar2.ltx', latex % 'bar2.ltx') test.write('bar3.latex', latex % 'bar3.latex') - test.run(arguments = 'foo.dvi', stderr = None) + test.run(arguments='foo.dvi', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_exist(test.workpath('foo.dvi')) - test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) + test.run(arguments='bar1.ps bar2.ps bar3.ps', stderr=None) expect = """dvips -o bar1.ps bar1.dvi dvips -o bar2.ps bar2.dvi dvips -o bar3.ps bar3.dvi """ - test.must_match('wrapper.out', expect) + test.must_match('wrapper.out', expect, mode='r') test.must_exist(test.workpath('bar1.ps')) test.must_exist(test.workpath('bar2.ps')) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index e435b9e..2a2d26c 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -29,6 +29,7 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment() print(env['CC']) print(" ".join(env['CCFLAGS'])) @@ -38,6 +39,7 @@ test.run() cc, ccflags = test.stdout().split('\n')[1:3] test.write('SConstruct', """ +DefaultEnvironment(tools=[]) # test validator. Change a key and add a new one to the environment def validator(key, value, environ): environ[key] = "v" @@ -208,6 +210,8 @@ Use scons -H for help about command-line options. # Test saving of options and multi loading # test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options(['custom.py', 'options.saved']) opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -259,6 +263,8 @@ checkSave('options.saved', {'DEBUG_BUILD':3, 'RELEASE_BUILD':1}) # Load no options from file(s) # Used to test for correct output in save option file test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options() opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -305,6 +311,8 @@ check(['0','0']) checkSave('options.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'}) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options('custom.py') opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -326,7 +334,10 @@ opts.Add('UNSPECIFIED', env = Environment(options=opts) -Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) +def compare(a,b): + return a < b + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) """) @@ -357,6 +368,8 @@ Use scons -H for help about command-line options. stderr=warnings) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + import SCons.Options env1 = Environment(options = Options()) env2 = Environment(options = SCons.Options.Options()) diff --git a/test/Dir/source.py b/test/Dir/source.py index 8e3bea6..c272c8f 100644 --- a/test/Dir/source.py +++ b/test/Dir/source.py @@ -43,8 +43,8 @@ test.subdir('tstamp', [ 'tstamp', 'subdir' ], test.write('SConstruct', """\ def writeTarget(target, source, env): - f=open(str(target[0]), 'wb') - f.write(b"stuff\\n") + f=open(str(target[0]), 'w') + f.write("stuff\\n") f.close() return 0 @@ -92,12 +92,12 @@ test.write([ 'cmd-content', 'subdir', '#hash.txt' ], 'hash.txt 1\n') test.write('junk.txt', 'junk.txt\n') test.run(arguments=".", stderr=None) -test.must_match('tstamp.out', 'stuff\n') -test.must_match('content.out', 'stuff\n') -test.must_match('cmd-tstamp.out', 'stuff\n') -test.must_match('cmd-content.out', 'stuff\n') -test.must_match('cmd-tstamp-noscan.out', 'stuff\n') -test.must_match('cmd-content-noscan.out', 'stuff\n') +test.must_match('tstamp.out', 'stuff\n', mode='r') +test.must_match('content.out', 'stuff\n', mode='r') +test.must_match('cmd-tstamp.out', 'stuff\n', mode='r') +test.must_match('cmd-content.out', 'stuff\n', mode='r') +test.must_match('cmd-tstamp-noscan.out', 'stuff\n', mode='r') +test.must_match('cmd-content-noscan.out', 'stuff\n', mode='r') test.up_to_date(arguments='tstamp.out') test.up_to_date(arguments='content.out') diff --git a/test/ENV.py b/test/ENV.py index 5cb2362..59b1cdb 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -50,16 +50,16 @@ test.write('build.py', r"""#!/usr/bin/env python import os import sys -contents = open(sys.argv[2], 'rb').read() -open(sys.argv[1], 'wb').write("build.py %s\n%s" % (os.environ['X'], contents)) +contents = open(sys.argv[2], 'r').read() +open(sys.argv[1], 'w').write("build.py %s\n%s" % (os.environ['X'], contents)) """) test.write('input', "input file\n") test.run(arguments = '.') -test.fail_test(test.read('env1.out') != "build.py env1\ninput file\n") -test.fail_test(test.read('env2.out') != "build.py env2\ninput file\n") +test.must_match('env1.out', "build.py env1\ninput file\n", mode='r') +test.must_match('env2.out', "build.py env2\ninput file\n", mode='r') test.write('SConstruct', """ diff --git a/test/Ghostscript/GS.py b/test/Ghostscript/GS.py index d7a7456..3f5aa58 100644 --- a/test/Ghostscript/GS.py +++ b/test/Ghostscript/GS.py @@ -38,10 +38,10 @@ test = TestSCons.TestSCons() test.write('mygs.py', r""" import os import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') +outfile = open(sys.argv[1], 'w') +infile = open(sys.argv[2], 'r') for l in infile.readlines(): - if l[:3] != b'#ps': + if l[:3] != '#ps': outfile.write(l) sys.exit(0) """) @@ -60,8 +60,8 @@ test.write('test1.ps', r"""This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != b"This is a .ps test.\n") -test.fail_test(test.read('test2.pdf') != b"This is a .ps test.\n") +test.must_match('test1.pdf', "This is a .ps test.\n", mode='r') +test.must_match('test2.pdf', "This is a .ps test.\n", mode='r') @@ -79,7 +79,7 @@ if gs: import os import sys cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) +open('%s', 'a').write("%%s\\n" %% cmd) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -110,7 +110,7 @@ bar.PDF(target = 'bar.pdf', source = 'bar.ps') test.run(arguments = 'bar.pdf', stderr = None) - test.fail_test(test.read('wrapper.out') != "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable) + test.must_match('wrapper.out', "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable, mode='r') test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py index 2e58ec1..e1471fa 100644 --- a/test/Ghostscript/GSFLAGS.py +++ b/test/Ghostscript/GSFLAGS.py @@ -44,13 +44,13 @@ opt_string = '' for opt, arg in cmd_opts: if opt == '-s': if arg[:11] == 'OutputFile=': - out_file = open(arg[11:], 'wb') + out_file = open(arg[11:], 'w') else: opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') -out_file.write(opt_string.encode("utf-8") + b"\n") +infile = open(args[0], 'r') +out_file.write(opt_string + "\n") for l in infile.readlines(): - if l[:3] != b'#ps': + if l[:3] != '#ps': out_file.write(l) sys.exit(0) """) @@ -68,7 +68,7 @@ This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != b" -x\nThis is a .ps test.\n") +test.must_match('test1.pdf', " -x\nThis is a .ps test.\n", mode='r') diff --git a/test/IDL/MIDLCOM.py b/test/IDL/MIDLCOM.py index 0525592..a478da0 100644 --- a/test/IDL/MIDLCOM.py +++ b/test/IDL/MIDLCOM.py @@ -39,12 +39,12 @@ test = TestSCons.TestSCons() test.write('mymidl.py', """ import os.path import sys -out_tlb = open(sys.argv[1], 'wb') +out_tlb = open(sys.argv[1], 'w') base = os.path.splitext(sys.argv[1])[0] -out_h = open(base + '.h', 'wb') -out_c = open(base + '_i.c', 'wb') +out_h = open(base + '.h', 'w') +out_c = open(base + '_i.c', 'w') for f in sys.argv[2:]: - infile = open(f, 'rb') + infile = open(f, 'r') for l in [l for l in infile.readlines() if l != '/*midl*/\\n']: out_tlb.write(l) out_h.write(l) @@ -62,9 +62,9 @@ test.write('aaa.idl', "aaa.idl\n/*midl*/\n") test.run(arguments = '.') -test.must_match('aaa.tlb', "aaa.idl\n") -test.must_match('aaa.h', "aaa.idl\n") -test.must_match('aaa_i.c', "aaa.idl\n") +test.must_match('aaa.tlb', "aaa.idl\n", mode='r') +test.must_match('aaa.h', "aaa.idl\n", mode='r') +test.must_match('aaa_i.c', "aaa.idl\n", mode='r') test.up_to_date(options = '--debug=explain', arguments = 'aaa.tlb') diff --git a/test/Install/Install.py b/test/Install/Install.py index 8c3bccd..d039d78 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -50,9 +50,9 @@ _SUBDIR_f4_out = os.path.join('$SUBDIR', 'f4.out') test.write(['work', 'SConstruct'], """\ def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() def my_install(dest, source, env): @@ -122,7 +122,7 @@ test.fail_test(oldtime1 == os.path.getmtime(f1_out)) test.fail_test(oldtime2 != os.path.getmtime(f2_out)) # Verify that we didn't link to the Installed file. -open(f2_out, 'wb').write(b"xyzzy\n") +open(f2_out, 'w').write("xyzzy\n") test.must_match(['work', 'f2.out'], "f2.in\n") # Verify that scons prints an error message diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 98dfa38..476bfcd 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -43,9 +43,9 @@ while args: else: break args = args[1:] -outfile = open(out, 'wb') +outfile = open(out, 'w') for file in args: - infile = open(file, 'rb') + infile = open(file, 'r') for l in infile.readlines(): if l[:7] != '/*jar*/': outfile.write(l) @@ -64,9 +64,9 @@ test1.class line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.jar', "test1.class\nline 3\n") +test.must_match('test1.jar', "test1.class\nline 3\n", mode='r') if os.path.normcase('.class') == os.path.normcase('.CLASS'): @@ -82,13 +82,13 @@ test2.CLASS line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.jar', "test2.CLASS\nline 3\n") + test.must_match('test2.jar', "test2.CLASS\nline 3\n", mode='r') test.write('myjar2.py', r""" import sys -f=open(sys.argv[2], 'wb') +f=open(sys.argv[2], 'w') f.write(" ".join(sys.argv[1:])) f.write("\n") f.close() @@ -106,7 +106,7 @@ env.Jar(target = 'classes.jar', source = [ 'testdir/bar.class', """ % locals()) test.subdir('testdir') -test.write([ 'testdir', 'bar.class' ], 'foo') +test.write(['testdir', 'bar.class'], 'foo') test.write('foo.mf', """Manifest-Version : 1.0 blah @@ -115,7 +115,7 @@ test.write('foo.mf', """) test.run(arguments='classes.jar') test.must_match('classes.jar', - 'cvfm classes.jar foo.mf -C testdir bar.class\n') + 'cvfm classes.jar foo.mf -C testdir bar.class\n', mode='r') @@ -124,14 +124,14 @@ where_jar = test.java_where_jar() -test.file_fixture('wrapper.py') +test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'jar'], JAVAC = r'%(where_javac)s', JAR = r'%(where_jar)s') jar = foo.Dictionary('JAR') -bar = foo.Clone(JAR = r'%(_python_)s wrapper.py ' + jar) +bar = foo.Clone(JAR = r'%(_python_)s wrapper_with_args.py ' + jar) foo.Java(target = 'classes', source = 'com/sub/foo') bar.Java(target = 'classes', source = 'com/sub/bar') foo.Jar(target = 'foo', source = 'classes/com/sub/foo') @@ -229,10 +229,10 @@ public class Example6 test.run(arguments = '.') -expected_wrapper_out = "wrapper.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" +expected_wrapper_out = "wrapper_with_args.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" expected_wrapper_out = expected_wrapper_out.replace('/', os.sep) test.must_match('wrapper.out', - expected_wrapper_out % locals()) + expected_wrapper_out % locals(), mode='r') test.must_exist('foo.jar') test.must_exist('bar.jar') diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py index 06b1969..aaaa8f5 100644 --- a/test/Java/JAVAC.py +++ b/test/Java/JAVAC.py @@ -51,8 +51,8 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') - outfile = open(file[:-5] + '.class', 'wb') + infile = open(file, 'r') + outfile = open(file[:-5] + '.class', 'w') for l in infile.readlines(): if l[:9] != '/*javac*/': outfile.write(l) @@ -71,9 +71,9 @@ test1.java line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.class', "test1.java\nline 3\n") +test.must_match('test1.class', "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -89,9 +89,9 @@ test2.JAVA line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.class', "test2.JAVA\nline 3\n") + test.must_match('test2.class', "test2.JAVA\nline 3\n", mode='r') diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index f647b03..f07ebb9 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -41,7 +41,7 @@ while args: outdir = args[1] args = args[1:] elif a == '-o': - outfile = open(args[1], 'wb') + outfile = open(args[1], 'w') args = args[1:] elif a == '-classpath': args = args[1:] @@ -51,7 +51,7 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') + infile = open(file, 'r') for l in infile.readlines(): if l[:9] != '/*javah*/': outfile.write(l) @@ -70,9 +70,9 @@ test1.java line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.h', "test1.java\nline 3\n") +test.must_match('test1.h', "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -88,9 +88,9 @@ test2.JAVA line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.h', "test2.JAVA\nline 3\n") + test.must_match('test2.h', "test2.JAVA\nline 3\n", mode='r') where_javac, java_version = test.java_where_javac() @@ -105,7 +105,7 @@ if java_version: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') -test.file_fixture('wrapper.py') +test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'javah', 'install'], @@ -115,7 +115,7 @@ jv = %(java_version)s if jv: foo['JAVAVERSION'] = jv javah = foo.Dictionary('JAVAH') -bar = foo.Clone(JAVAH = r'%(_python_)s wrapper.py ' + javah) +bar = foo.Clone(JAVAH = r'%(_python_)s wrapper_with_args.py ' + javah) foo.Java(target = 'class1', source = 'com/sub/foo') bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') foo_classes = foo.Java(target = 'class3', source = 'src') @@ -282,7 +282,8 @@ class Private { test.run(arguments = '.') -test.fail_test(test.read('wrapper.out') != "wrapper.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals()) +test.must_match('wrapper.out', "wrapper_with_args.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals(), + mode='r') test.must_exist(['outdir1', 'com_sub_foo_Example1.h']) test.must_exist(['outdir1', 'com_other_Example2.h']) diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 5f5decd..b29a466 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -49,8 +49,8 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') - outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'wb') + infile = open(file, 'r') + outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'w') for l in infile.readlines(): if l[:8] != '/*rmic*/': outfile.write(l) @@ -71,7 +71,7 @@ line 3 test.run(arguments = '.', stderr = None) -test.fail_test(test.read(['outdir', 'test1.class']) != "test1.java\nline 3\n") +test.must_match(['outdir', 'test1.class'], "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -89,7 +89,7 @@ line 3 test.run(arguments = '.', stderr = None) - test.fail_test(test.read(['outdir', 'test2.class']) != "test2.JAVA\nline 3\n") + test.must_match(['outdir', 'test2.class'], "test2.JAVA\nline 3\n", mode='r') where_javac, java_version = test.java_where_javac() where_rmic = test.java_where_rmic() @@ -111,7 +111,7 @@ if java_version.count('.') == 1: # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver < (1, 8): - test.file_fixture('wrapper.py') + test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'rmic'], @@ -124,7 +124,7 @@ foo.RMIC(target = 'outdir1', JAVACLASSDIR = 'class1') rmic = foo.Dictionary('RMIC') -bar = foo.Clone(RMIC = r'%(_python_)s wrapper.py ' + rmic) +bar = foo.Clone(RMIC = r'%(_python_)s wrapper_with_args.py ' + rmic) bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') # XXX This is kind of a Python brute-force way to do what Ant # does with its "excludes" attribute. We should probably find @@ -321,7 +321,9 @@ public class Example4 extends UnicastRemoteObject implements Hello { test.run(arguments = '.') - test.fail_test(test.read('wrapper.out') != "wrapper.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic) + test.must_match('wrapper.out', + "wrapper_with_args.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic, + mode='r') test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class')) test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Stub.class')) diff --git a/test/MSVC/batch.py b/test/MSVC/batch.py index 8648292..8b7945b 100644 --- a/test/MSVC/batch.py +++ b/test/MSVC/batch.py @@ -55,20 +55,20 @@ else: # Delay writing the .log output until here so any trailing slash or # backslash has been stripped, and the output comparisons later in this # script don't have to account for the difference. -open('fake_cl.log', 'ab').write(" ".join(sys.argv[1:]) + '\\n') +open('fake_cl.log', 'a').write(" ".join(sys.argv[1:]) + '\\n') for infile in input_files: if dir: outfile = os.path.join(dir, infile.replace('.c', '.obj')) else: outfile = output - open(outfile, 'wb').write(open(infile, 'rb').read()) + open(outfile, 'w').write(open(infile, 'r').read()) """) test.write('fake_link.py', """\ import sys -ofp = open(sys.argv[1], 'wb') +ofp = open(sys.argv[1], 'w') for infile in sys.argv[2:]: - ofp.write(open(infile, 'rb').read()) + ofp.write(open(infile, 'r').read()) """) test.write('SConstruct', """ @@ -94,10 +94,10 @@ test.write('f2.c', "f2.c\n") test.run(arguments = 'MSVC_BATCH=1 .') -test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fo. prog.c f1.c f2.c -""") +""", mode='r') test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') @@ -107,11 +107,11 @@ test.write('f1.c', "f1.c 2\n") test.run(arguments = 'MSVC_BATCH=1 .') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fo. prog.c f1.c f2.c /Fo. f1.c -""") +""", mode='r') test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') @@ -125,12 +125,12 @@ test.unlink('fake_cl.log') test.run(arguments = '. MSVC_BATCH=0') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c -""") +""", mode='r') test.run(arguments = '-c .') test.unlink('fake_cl.log') @@ -138,12 +138,12 @@ test.unlink('fake_cl.log') test.run(arguments = '. MSVC_BATCH=False') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c -""") +""", mode='r') @@ -151,13 +151,13 @@ test.write('f1.c', "f1.c 3\n") test.run(arguments = '. MSVC_BATCH=0') -test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c /Fof1.obj f1.c -""") +""", mode='r') diff --git a/test/MSVC/embed-manifest.py b/test/MSVC/embed-manifest.py index 13f1def..c0f8408 100644 --- a/test/MSVC/embed-manifest.py +++ b/test/MSVC/embed-manifest.py @@ -76,14 +76,14 @@ testdll(int argc, char *argv) }
""")
-test.run(arguments = '.')
+test.run(arguments='.')
test.must_exist('test%s' % _exe)
test.must_exist('test%s.manifest' % _exe)
-test.must_contain('exe-extracted.manifest', '</assembly>')
+test.must_contain('exe-extracted.manifest', '</assembly>', mode='r')
test.must_exist('testdll%s' % _dll)
test.must_exist('testdll%s.manifest' % _dll)
-test.must_contain('dll-extracted.manifest', '</assembly>')
+test.must_contain('dll-extracted.manifest', '</assembly>', mode='r')
test.pass_test()
diff --git a/test/MSVC/generate-rc.py b/test/MSVC/generate-rc.py index 40ef95e..00e9090 100644 --- a/test/MSVC/generate-rc.py +++ b/test/MSVC/generate-rc.py @@ -39,15 +39,15 @@ fake_rc = test.workpath('fake_rc.py') test.write(fake_rc, """\ import sys -contents = open(sys.argv[2], 'rb').read() -open(sys.argv[1], 'wb').write("fake_rc.py\\n" + contents) +contents = open(sys.argv[2], 'r').read() +open(sys.argv[1], 'w').write("fake_rc.py\\n" + contents) """) test.write('SConstruct', """ def generate_rc(target, source, env): t = str(target[0]) s = str(source[0]) - tfp = open(t, 'wb') + tfp = open(t, 'w') tfp.write('generate_rc\\n' + open(s, 'r').read()) env = Environment(tools=['msvc'], @@ -64,8 +64,8 @@ test.write('my.in', "my.in\n") test.run(arguments = '.') -test.must_match('my.rc', "generate_rc\nmy.in\n") -test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n") +test.must_match('my.rc', "generate_rc\nmy.in\n", mode='r') +test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n", mode='r') test.pass_test() diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index a70ed67..838922c 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -43,6 +43,7 @@ test.skip_if_not_msvc() test.write('SConstruct',""" import os +DefaultEnvironment(tools=[]) # TODO: this is order-dependent (putting 'mssdk' second or third breaks), # and ideally we shouldn't need to specify the tools= list anyway. env = Environment(tools=['mssdk', 'msvc', 'mslink']) @@ -179,6 +180,8 @@ start = time.time() test.run(arguments='slow.obj', stderr=None) slow = time.time() - start + +# TODO: Reevaluate if having this part of the test makes sense any longer # using precompiled headers should be faster limit = slow*0.90 if fast >= limit: diff --git a/test/Parallel/ref_count.py b/test/Parallel/ref_count.py index ce59668..7ce5910 100644 --- a/test/Parallel/ref_count.py +++ b/test/Parallel/ref_count.py @@ -74,9 +74,9 @@ while args: time.sleep(int(args.pop(0))) contents = '' for ifile in args: - contents = contents + open(ifile, 'rb').read() + contents = contents + open(ifile, 'r').read() for ofile in outputs: - ofp = open(ofile, 'wb') + ofp = open(ofile, 'w') ofp.write('%s: building from %s\\n' % (ofile, " ".join(args))) ofp.write(contents) ofp.close() @@ -136,7 +136,7 @@ test.run(arguments = '-j4 after.out') test.must_match('after.out', """\ after.out: building from after.in after.in -""") +""", mode='r') test.write('file5.c', "file5.c modified\n") @@ -147,7 +147,7 @@ test.run(arguments = '-j4 after.out') test.must_match('after.out', """\ after.out: building from after.in after.in modified -""") +""", mode='r') test.pass_test() diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index e13bac8..93a5abf 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -101,7 +101,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() diff --git a/test/Repository/Default.py b/test/Repository/Default.py index 44aecfb..bd9d5f8 100644 --- a/test/Repository/Default.py +++ b/test/Repository/Default.py @@ -47,7 +47,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -80,19 +80,19 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = '') test.fail_test(os.path.exists(work_aaa_out)) -test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n") +test.must_match(work_bbb_out, "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(work_ccc_out)) test.fail_test(os.path.exists(work_subdir_ddd_out)) -test.fail_test(test.read(work_subdir_eee_out) != "repository/subdir/eee.in\n") +test.must_match(work_subdir_eee_out, "repository/subdir/eee.in\n", mode='r') test.fail_test(os.path.exists(work_subdir_fff_out)) # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_ccc_out) != "repository/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_fff_out) != "repository/subdir/fff.in\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_ccc_out, "repository/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_fff_out, "repository/subdir/fff.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') diff --git a/test/Repository/Install-Local.py b/test/Repository/Install-Local.py index 3631043..fe64feb 100644 --- a/test/Repository/Install-Local.py +++ b/test/Repository/Install-Local.py @@ -51,8 +51,8 @@ test.write(['repository', 'file2'], "repository/file2\n") test.run(chdir = 'repository', options = opts, arguments = 'install') -test.fail_test(test.read(repository_install_file1) != "repository/file1\n") -test.fail_test(test.read(repository_install_file2) != "repository/file2\n") +test.must_match(repository_install_file1, "repository/file1\n", mode='r') +test.must_match(repository_install_file2, "repository/file2\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = 'install') @@ -62,8 +62,8 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = 'install') -test.fail_test(test.read(work_install_file1) != "repository/file1\n") -test.fail_test(test.read(work_install_file2) != "repository/file2\n") +test.must_match(work_install_file1, "repository/file1\n", mode='r') +test.must_match(work_install_file2, "repository/file2\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = 'install') @@ -73,8 +73,8 @@ test.write(['work', 'file2'], "work/file2\n") test.run(chdir = 'work', options = opts, arguments = 'install') -test.fail_test(test.read(work_install_file1) != "work/file1\n") -test.fail_test(test.read(work_install_file2) != "work/file2\n") +test.must_match(work_install_file1, "work/file1\n", mode='r') +test.must_match(work_install_file2, "work/file2\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = 'install') diff --git a/test/Repository/Install.py b/test/Repository/Install.py index 5e64d55..75052e7 100644 --- a/test/Repository/Install.py +++ b/test/Repository/Install.py @@ -51,7 +51,7 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = install) -test.fail_test(test.read(install_file) != "repository/file\n") +test.must_match(install_file, "repository/file\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = install) diff --git a/test/Repository/InstallAs.py b/test/Repository/InstallAs.py index 0923d88..d717254 100644 --- a/test/Repository/InstallAs.py +++ b/test/Repository/InstallAs.py @@ -56,9 +56,9 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = install) -test.fail_test(test.read(install_file1_out) != "repository/file1.in\n") -test.fail_test(test.read(install_file2_out) != "repository/file2.in\n") -test.fail_test(test.read(install_file3_out) != "repository/file3.in\n") +test.must_match(install_file1_out, "repository/file1.in\n", mode='r') +test.must_match(install_file2_out, "repository/file2.in\n", mode='r') +test.must_match(install_file3_out, "repository/file3.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = install) diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py index 166060e..8b396fa 100644 --- a/test/Repository/LIBPATH.py +++ b/test/Repository/LIBPATH.py @@ -97,14 +97,12 @@ test.run(chdir = 'work', options = opts, arguments = ".") #dirs = ['.', workpath_foo, workpath_bar, workpath_foo_zzz] dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz, workpath_bar_zzz] -test.fail_test(test.read(['work', 'zzz.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'zzz.out'],'\n'.join(dirs) + '\n', mode='r') #dirs = [workpath_bar_yyy, '.', workpath_foo, workpath_bar] dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy, '.', workpath_foo, workpath_bar] -test.fail_test(test.read(['work', 'yyy.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'yyy.out'], '\n'.join(dirs) + '\n', mode='r') # test.run(chdir = 'work', options = '-c', arguments = ".") @@ -117,14 +115,12 @@ test.run(chdir = 'work', options = opts, arguments = ".") #dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz] dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz, workpath_bar_zzz] -test.fail_test(test.read(['work', 'zzz.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'zzz.out'], '\n'.join(dirs) + '\n', mode='r') #dirs = ['yyy', workpath_bar_yyy, '.', workpath_foo, workpath_bar] dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy, '.', workpath_foo, workpath_bar] -test.fail_test(test.read(['work', 'yyy.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'yyy.out'], '\n'.join(dirs) + '\n', mode='r') # test.pass_test() diff --git a/test/Repository/Local.py b/test/Repository/Local.py index ea03281..95fd898 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -49,7 +49,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}, BBB='bbb') @@ -66,7 +66,7 @@ test.write(['repository', 'src', 'SConscript'], r""" def bbb_copy(env, source, target): target = str(target[0]) print('bbb_copy()') - open(target, "wb").write(open('build/bbb.1', "rb").read()) + open(target, "w").write(open('build/bbb.1', "r").read()) Import("env") env.Build('bbb.1', 'bbb.0') @@ -82,8 +82,8 @@ test.write(['repository', 'src', 'bbb.x'], "repository/src/bbb.x\n") # test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_build_bbb_2) != "repository/src/bbb.0\n") +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_build_bbb_2, "repository/src/bbb.0\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -95,8 +95,8 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = 'aaa.out build/bbb.2') test.fail_test(os.path.exists(work_aaa_mid)) -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_build_bbb_1) != "repository/src/bbb.0\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_build_bbb_1, "repository/src/bbb.0\n", mode='r') test.fail_test(os.path.exists(work_build_bbb_2)) # @@ -105,8 +105,8 @@ test.write(['work', 'aaa.in'], "work/aaa.in\n") # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_mid) != "work/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "work/aaa.in\n") +test.must_match(work_aaa_mid, "work/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "work/aaa.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py index 22956ac..1b67c07 100644 --- a/test/Repository/SConscript.py +++ b/test/Repository/SConscript.py @@ -61,9 +61,9 @@ SConscript('src/SConscript') test.write(['rep1', 'src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in']) @@ -79,11 +79,11 @@ test.writable('rep1', 0) test.run(chdir = 'work', arguments = ".") -test.fail_test(test.read(['work', 'src', 'foo']) != """\ +test.must_match(['work', 'src', 'foo'], """\ rep1/src/aaa.in rep1/src/bbb.in rep1/src/ccc.in -""") +""", mode='r') test.up_to_date(chdir = 'work', arguments = ".") @@ -115,11 +115,11 @@ test.write(['rep2', 'src', 'ccc.in'], "rep2/src/ccc.in\n") test.run(chdir = 'rep2/build', arguments = ".") -test.fail_test(test.read(['rep2', 'build', 'src', 'foo']) != """\ +test.must_match(['rep2', 'build', 'src', 'foo'], """\ rep2/src/aaa.in rep2/src/bbb.in rep2/src/ccc.in -""") +""", mode='r') # test.pass_test() diff --git a/test/Repository/VariantDir.py b/test/Repository/VariantDir.py index 0258ff5..8887f86 100644 --- a/test/Repository/VariantDir.py +++ b/test/Repository/VariantDir.py @@ -49,9 +49,9 @@ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) print('cat(%s) > %s' % (source, target)) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(src, "rb").read()) + f.write(open(src, "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}) @@ -72,11 +72,11 @@ test.writable('repository', 0) # test.run(chdir = 'work1', options = opts, arguments = '.') -test.fail_test(test.read(['work1', 'build0', 'output']) != +test.must_match(['work1', 'build0', 'output'], """repository/src/aaa.in repository/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work1/build0/aaa.in')) test.fail_test(os.path.exists('work1/build0/bbb.in')) @@ -85,11 +85,11 @@ test.fail_test(not os.path.exists('work1/build0/aaa.mid')) test.fail_test(not os.path.exists('work1/build0/bbb.mid')) test.fail_test(not os.path.exists('work1/build0/ccc.mid')) -test.fail_test(test.read(['work1', 'build1', 'output']) != +test.must_match(['work1', 'build1', 'output'], """repository/src/aaa.in repository/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work1/build1/aaa.in')) test.fail_test(not os.path.exists('work1/build1/bbb.in')) @@ -105,11 +105,11 @@ test.write(['work1', 'src', 'bbb.in'], "work1/src/bbb.in\n") test.run(chdir = 'work1', options = opts, arguments = '.') -test.fail_test(test.read(['work1', 'build0', 'output']) != +test.must_match(['work1', 'build0', 'output'], """repository/src/aaa.in work1/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work1/build0/aaa.in')) test.fail_test(os.path.exists('work1/build0/bbb.in')) @@ -118,11 +118,11 @@ test.fail_test(not os.path.exists('work1/build0/aaa.mid')) test.fail_test(not os.path.exists('work1/build0/bbb.mid')) test.fail_test(not os.path.exists('work1/build0/ccc.mid')) -test.fail_test(test.read(['work1', 'build1', 'output']) != +test.must_match(['work1', 'build1', 'output'], """repository/src/aaa.in work1/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work1/build1/aaa.in')) test.fail_test(not os.path.exists('work1/build1/bbb.in')) @@ -167,11 +167,11 @@ test.write(['work2', 'src', 'bbb.in'], "work2/src/bbb.in\n") test.run(chdir = 'work2', options = opts, arguments = '.') -test.fail_test(test.read(['work2', 'build0', 'output']) != +test.must_match(['work2', 'build0', 'output'], """repository/src/aaa.in work2/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work2/build0/aaa.in')) test.fail_test(os.path.exists('work2/build0/bbb.in')) @@ -180,11 +180,11 @@ test.fail_test(os.path.exists('work2/build0/aaa.mid')) test.fail_test(not os.path.exists('work2/build0/bbb.mid')) test.fail_test(os.path.exists('work2/build0/ccc.mid')) -test.fail_test(test.read(['work2', 'build1', 'output']) != +test.must_match(['work2', 'build1', 'output'], """repository/src/aaa.in work2/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work2/build1/aaa.in')) test.fail_test(not os.path.exists('work2/build1/bbb.in')) diff --git a/test/Repository/option-c.py b/test/Repository/option-c.py index c06c7d8..b0d8533 100644 --- a/test/Repository/option-c.py +++ b/test/Repository/option-c.py @@ -66,7 +66,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -100,14 +100,14 @@ test.writable('repository', 0) # copying them from the Repository. test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(work_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(work_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(work_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') @@ -117,14 +117,14 @@ test.writable('repository', 1) # Now build everything in the repository. test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(repository_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(repository_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(repository_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(repository_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(repository_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(repository_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(repository_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -135,20 +135,20 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts + ' -c', arguments = 'bbb.mid bbb.out') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(work_bbb_mid)) test.fail_test(os.path.exists(work_bbb_out)) -test.fail_test(test.read(work_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(work_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') # test.run(chdir = 'work', options = opts + ' -c', arguments = 'subdir') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(work_bbb_mid)) test.fail_test(os.path.exists(work_bbb_out)) test.fail_test(os.path.exists(work_subdir_ccc_mid)) @@ -169,14 +169,14 @@ test.fail_test(os.path.exists(work_subdir_ddd_mid)) test.fail_test(os.path.exists(work_subdir_ddd_out)) # Double-check that nothing in the repository got deleted. -test.fail_test(test.read(repository_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(repository_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(repository_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(repository_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(repository_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(repository_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(repository_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(repository_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/option-f.py b/test/Repository/option-f.py index 8511f6a..c990f2f 100644 --- a/test/Repository/option-f.py +++ b/test/Repository/option-f.py @@ -76,7 +76,7 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts, arguments = 'aaa.out') -test.fail_test(test.read(['work', 'aaa.out']) != "repository/aaa.in\n") +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'bbb.out'))) test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) test.fail_test(os.path.exists(test.workpath('work', 'src', 'xxx.out'))) @@ -84,15 +84,15 @@ test.fail_test(os.path.exists(test.workpath('work', 'src', 'yyy.out'))) test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') -test.fail_test(test.read(['work', 'bbb.out']) != "repository/bbb.in\n") +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) -test.fail_test(test.read(['work', 'src', 'xxx.out']) != "repository/src/xxx.in\n") -test.fail_test(test.read(['work', 'src', 'yyy.out']) != "repository/src/yyy.in\n") +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode='r') +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode='r') # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(['work', 'ccc.out']) != "repository/ccc.in\n") +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/option-n.py b/test/Repository/option-n.py index 2a0ae5d..d23a200 100644 --- a/test/Repository/option-n.py +++ b/test/Repository/option-n.py @@ -49,7 +49,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -62,7 +62,7 @@ test.write(['repository', 'aaa.in'], "repository/aaa.in\n") # test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") +test.must_match(repository_aaa_out,"repository/aaa.in\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -88,7 +88,7 @@ test.run(chdir = 'work', arguments = 'aaa.out', stdout = expect) -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/targets.py b/test/Repository/targets.py index 0fbc896..0bc625a 100644 --- a/test/Repository/targets.py +++ b/test/Repository/targets.py @@ -44,9 +44,9 @@ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) print('cat(%s) > %s' % (source, target)) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(src, "rb").read()) + f.write(open(src, "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}) @@ -77,7 +77,7 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts, arguments = 'aaa.out') -test.fail_test(test.read(['work', 'aaa.out']) != "repository/aaa.in\n") +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'bbb.out'))) test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) test.fail_test(os.path.exists(test.workpath('work', 'src', 'xxx.out'))) @@ -85,15 +85,15 @@ test.fail_test(os.path.exists(test.workpath('work', 'src', 'yyy.out'))) test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') -test.fail_test(test.read(['work', 'bbb.out']) != "repository/bbb.in\n") +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) -test.fail_test(test.read(['work', 'src', 'xxx.out']) != "repository/src/xxx.in\n") -test.fail_test(test.read(['work', 'src', 'yyy.out']) != "repository/src/yyy.in\n") +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode='r') +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode='r') # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(['work', 'ccc.out']) != "repository/ccc.in\n") +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode='r') # test.pass_test() diff --git a/test/Requires/eval-order.py b/test/Requires/eval-order.py index 8600221..696b5e9 100644 --- a/test/Requires/eval-order.py +++ b/test/Requires/eval-order.py @@ -53,10 +53,10 @@ test.write('prereq.in', "prereq.in 1\n") # not, we'll get an error when the build action tries to use it to # build file.out. -test.run(arguments = 'file.out') +test.run(arguments='file.out') -test.must_match('prereq.out', "prereq.in 1\n") -test.must_match('file.out', "file.in 1\n") +test.must_match('prereq.out', "prereq.in 1\n", mode='r') +test.must_match('file.out', "file.in 1\n", mode='r') test.pass_test() diff --git a/test/Rpcgen/RPCGEN.py b/test/Rpcgen/RPCGEN.py index f79e18e..2f793e2 100644 --- a/test/Rpcgen/RPCGEN.py +++ b/test/Rpcgen/RPCGEN.py @@ -26,10 +26,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -_python_ = TestSCons._python_ -_exe = TestSCons._exe +_python_=TestSCons._python_ +_exe=TestSCons._exe -test = TestSCons.TestSCons() +test=TestSCons.TestSCons() @@ -68,10 +68,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENCLIENTFLAGS.py b/test/Rpcgen/RPCGENCLIENTFLAGS.py index 9440d57..9612952 100644 --- a/test/Rpcgen/RPCGENCLIENTFLAGS.py +++ b/test/Rpcgen/RPCGENCLIENTFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENFLAGS.py b/test/Rpcgen/RPCGENFLAGS.py index b94ffe5..d4be92c 100644 --- a/test/Rpcgen/RPCGENFLAGS.py +++ b/test/Rpcgen/RPCGENFLAGS.py @@ -70,10 +70,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENHEADERFLAGS.py b/test/Rpcgen/RPCGENHEADERFLAGS.py index f65da8e..4beca64 100644 --- a/test/Rpcgen/RPCGENHEADERFLAGS.py +++ b/test/Rpcgen/RPCGENHEADERFLAGS.py @@ -71,10 +71,10 @@ expect_h = output_h % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENSERVICEFLAGS.py b/test/Rpcgen/RPCGENSERVICEFLAGS.py index a956d4f..7644485 100644 --- a/test/Rpcgen/RPCGENSERVICEFLAGS.py +++ b/test/Rpcgen/RPCGENSERVICEFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output_svc % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENXDRFLAGS.py b/test/Rpcgen/RPCGENXDRFLAGS.py index 0dc1366..41da70c 100644 --- a/test/Rpcgen/RPCGENXDRFLAGS.py +++ b/test/Rpcgen/RPCGENXDRFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output_xdr % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Scanner/FindPathDirs.py b/test/Scanner/FindPathDirs.py index ef3ea46..7f8b993 100644 --- a/test/Scanner/FindPathDirs.py +++ b/test/Scanner/FindPathDirs.py @@ -41,14 +41,14 @@ test.write('build.py', r""" import os.path import sys path = sys.argv[1].split() -input = open(sys.argv[2], 'rb') -output = open(sys.argv[3], 'wb') +input = open(sys.argv[2], 'r') +output = open(sys.argv[3], 'w') def find_file(f): for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index 8d48b73..625b372 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -32,14 +32,14 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -input = open(sys.argv[1], 'rb') -output = open(sys.argv[2], 'wb') +input = open(sys.argv[1], 'r') +output = open(sys.argv[2], 'w') def process(infp, outfp): for line in infp.readlines(): if line[:8] == 'include ': file = line[8:-1] - process(open(file, 'rb'), outfp) + process(open(file, 'r'), outfp) elif line[:8] == 'getfile ': outfp.write('include ') outfp.write(line[8:]) @@ -114,7 +114,7 @@ bar = env.BarBld(target='bar', source='bar.in') # automatically applied to targets generated from that Builder def blork(env, target, source): - open(str(target[0]), 'wb').write( + open(str(target[0]), 'w').write( source[0].get_text_contents().replace('getfile', 'MISSEDME')) kbld = Builder(action=r'%(_python_)s build.py $SOURCES $TARGET', diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 7246cbe..9dd2a86 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -301,7 +301,7 @@ import os Scanned = {} def write_out(file, dict): - f = open(file, 'wb') + f = open(file, 'w') for k in sorted(dict.keys()): file = os.path.split(k)[1] f.write(file + ": " + str(dict[k]) + "\\n") diff --git a/test/Scanner/no-Dir-node.py b/test/Scanner/no-Dir-node.py index 3a918bf..123764e 100644 --- a/test/Scanner/no-Dir-node.py +++ b/test/Scanner/no-Dir-node.py @@ -54,16 +54,16 @@ test.write('build.py', r""" import os.path import sys path = sys.argv[1].split() -input = open(sys.argv[2], 'rb') -output = open(sys.argv[3], 'wb') +input = open(sys.argv[2], 'r') +output = open(sys.argv[3], 'w') def find_file(f): if os.path.isabs(f): - return open(f, 'rb') + return open(f, 'r') for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): @@ -81,7 +81,7 @@ sys.exit(0) test.write('SConstruct', """\ def foo(target, source, env): - fp = open(str(target[0]), 'wb') + fp = open(str(target[0]), 'w') for c in sorted(source[0].children(), key=lambda t: t.name): fp.write('%s\\n' % c) fp.close() diff --git a/test/TAR/TAR.py b/test/TAR/TAR.py index 8aa2747..65e6182 100644 --- a/test/TAR/TAR.py +++ b/test/TAR/TAR.py @@ -44,15 +44,11 @@ for opt, arg in opts: if opt == '-f': out = arg def process(outfile, name): if os.path.isdir(name): - ## TODO 2.4: the next three lines can be replaced by - #for entry in sorted(os.listdir(name)): - list = os.listdir(name) - list.sort() - for entry in list: + for entry in sorted(os.listdir(name)): process(outfile, os.path.join(name, entry)) else: - outfile.write(open(name, 'rb').read()) -outfile = open(out, 'wb') + outfile.write(open(name, 'r').read()) +outfile = open(out, 'w') for infile in args: process(outfile, infile) outfile.close() @@ -77,11 +73,11 @@ test.write(['sub1', 'file6'], "sub1/file6\n") test.run(arguments = 'aaa.tar', stderr = None) -test.fail_test(test.read('aaa.tar') != "file1\nfile2\nfile3\n") +test.must_match('aaa.tar', "file1\nfile2\nfile3\n", mode='r') test.run(arguments = 'bbb.tar', stderr = None) -test.fail_test(test.read('bbb.tar') != "sub1/file5\nsub1/file6\nfile4\n") +test.must_match('bbb.tar', "sub1/file5\nsub1/file6\nfile4\n", mode='r') tar = test.detect('TAR', 'tar') diff --git a/test/TAR/TARFLAGS.py b/test/TAR/TARFLAGS.py index 034539c..e1eae0f 100644 --- a/test/TAR/TARFLAGS.py +++ b/test/TAR/TARFLAGS.py @@ -46,15 +46,11 @@ for opt, arg in cmd_opts: else: opt_string = opt_string + ' ' + opt def process(outfile, name): if os.path.isdir(name): - ## TODO 2.5: the next three lines can be replaced by - #for entry in sorted(os.listdir(name)): - entries = os.listdir(name) - entries.sort() - for entry in entries: + for entry in sorted(os.listdir(name)): process(outfile, os.path.join(name, entry)) else: - outfile.write(open(name, 'rb').read()) -outfile = open(out, 'wb') + outfile.write(open(name, 'r').read()) +outfile = open(out, 'w') outfile.write('options: %s\\n' % opt_string) for infile in args: process(outfile, infile) @@ -82,11 +78,11 @@ test.write(['sub1', 'file6'], "sub1/file6\n") test.run(arguments = 'aaa.tar', stderr = None) -test.fail_test(test.read('aaa.tar') != "options: -x\nfile1\nfile2\nfile3\n") +test.must_match('aaa.tar', "options: -x\nfile1\nfile2\nfile3\n", mode='r') test.run(arguments = 'bbb.tar', stderr = None) -test.fail_test(test.read('bbb.tar') != "options: -x\nsub1/file5\nsub1/file6\nfile4\n") +test.must_match('bbb.tar', "options: -x\nsub1/file5\nsub1/file6\nfile4\n", mode='r') diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py index 46e0479..48cfa9c 100644 --- a/test/TEX/LATEXFLAGS.py +++ b/test/TEX/LATEXFLAGS.py @@ -43,8 +43,8 @@ opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(args[0], 'r') +out_file = open(base_name+'.dvi', 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[0] != '\\': @@ -70,9 +70,9 @@ test.write('test2.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.dvi') != " -x\nThis is a .ltx test.\n") +test.must_match('test1.dvi', " -x\nThis is a .ltx test.\n", mode='r') -test.fail_test(test.read('test2.dvi') != " -t\nThis is a .latex test.\n") +test.must_match('test2.dvi', " -t\nThis is a .latex test.\n", mode='r') @@ -111,7 +111,7 @@ This is the %s LaTeX file. test.run(arguments = 'bar.dvi', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 1c60635..2f4f69e 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -320,7 +320,10 @@ opts.Add('UNSPECIFIED', env = Environment(variables=opts) -Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) +def compare(a,b): + return a < b + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) """) diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py index ca14738..b2e93a3 100644 --- a/test/VariantDir/Clean.py +++ b/test/VariantDir/Clean.py @@ -43,8 +43,8 @@ VariantDir('build1', '.', duplicate=1) def build_sample(target, source, env): targetdir = str(target[0].dir) target = str(target[0]) - open(target, 'wb').write(open(str(source[0]), 'rb').read()) - open(targetdir+'/sample.junk', 'wb').write(b'Side effect!\\n') + open(target, 'w').write(open(str(source[0]), 'r').read()) + open(targetdir+'/sample.junk', 'w').write('Side effect!\\n') t0 = Command("build0/sample.out", "sample.in", build_sample) t1 = Command("build1/sample.out", "sample.in", build_sample) diff --git a/test/VariantDir/File-create.py b/test/VariantDir/File-create.py index 1386020..50db618 100644 --- a/test/VariantDir/File-create.py +++ b/test/VariantDir/File-create.py @@ -49,12 +49,12 @@ SConscript('src/SConscript', variant_dir='build1', chdir=1, duplicate=1) test.write(['src', 'SConscript'], """\ #f1_in = File('f1.in') #Command('f1.out', f1_in, Copy('$TARGET', '$SOURCE')) -#open('f1.in', 'wb').write(b"f1.in\\n") +#open('f1.in', 'w').write("f1.in\\n") f2_in = File('f2.in') str(f2_in) Command('f2.out', f2_in, Copy('$TARGET', '$SOURCE')) -open('f2.in', 'wb').write(b"f2.in\\n") +open('f2.in', 'w').write("f2.in\\n") """) test.run(arguments = '--tree=all .') diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py index 256734e..c74d103 100644 --- a/test/VariantDir/errors.py +++ b/test/VariantDir/errors.py @@ -57,9 +57,9 @@ def fake_scan(node, env, target): def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}, @@ -77,7 +77,7 @@ env.Build('file.out', 'file.in') # Just verify that the normal case works fine. test.run(chdir = 'normal', arguments = ".") -test.fail_test(test.read(['normal', 'build', 'file.out']) != b"normal/src/file.in\n") +test.must_match(['normal', 'build', 'file.out'], "normal/src/file.in\n", mode='r') # Verify the error when the VariantDir itself is read-only. Don't bother # to test this on Windows, because the ACL (I think) still allows the diff --git a/test/builderrors.py b/test/builderrors.py index 88015f1..a3e2f4d 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -38,8 +38,8 @@ test.write('build.py', r""" import sys exitval = int(sys.argv[1]) if exitval == 0: - contents = open(sys.argv[3], 'rb').read() - file = open(sys.argv[2], 'wb') + contents = open(sys.argv[3], 'r').read() + file = open(sys.argv[2], 'w') file.write(contents) file.close() sys.exit(exitval) @@ -81,7 +81,7 @@ test.write(['two', 'f3.in'], "two/f3.in\n") test.run(chdir = 'two', arguments = "f1.out f2.out f3.out", stderr = "scons: *** [f2.out] Error 1\n", status = 2) -test.fail_test(test.read(['two', 'f1.out']) != "two/f1.in\n") +test.must_match(['two', 'f1.out'], "two/f1.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('f2.out'))) test.fail_test(os.path.exists(test.workpath('f3.out'))) @@ -101,8 +101,8 @@ test.write(['three', 'f3.in'], "three/f3.in\n") test.run(chdir = 'three', arguments = "f1.out f2.out f3.out", stderr = "scons: *** [f3.out] Error 1\n", status = 2) -test.fail_test(test.read(['three', 'f1.out']) != "three/f1.in\n") -test.fail_test(test.read(['three', 'f2.out']) != "three/f2.in\n") +test.must_match(['three', 'f1.out'], "three/f1.in\n", mode='r') +test.must_match(['three', 'f2.out'], "three/f2.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('f3.out'))) test.write('SConstruct', """ diff --git a/test/fixture/wrapper.py b/test/fixture/wrapper.py index f02ea03..bd8187c 100644 --- a/test/fixture/wrapper.py +++ b/test/fixture/wrapper.py @@ -2,5 +2,5 @@ import os import sys if '--version' not in sys.argv and '-dumpversion' not in sys.argv: path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') - open(path, 'wb').write(b"wrapper.py\n") + open(path, 'w').write("wrapper.py\n") os.system(" ".join(sys.argv[1:])) diff --git a/test/fixture/wrapper_with_args.py b/test/fixture/wrapper_with_args.py new file mode 100644 index 0000000..fccab72 --- /dev/null +++ b/test/fixture/wrapper_with_args.py @@ -0,0 +1,7 @@ +import os +import sys + +path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + +open(path, 'a').write("wrapper_with_args.py %s\n" % " ".join(sys.argv[1:])) +os.system(" ".join(sys.argv[1:])) diff --git a/test/option-i.py b/test/option-i.py index 3301bf5..9b5212d 100644 --- a/test/option-i.py +++ b/test/option-i.py @@ -73,22 +73,21 @@ test.run(arguments = '-i aaa.1 aaa.out bbb.1 bbb.out', 'scons: *** [bbb.1] Error 1\n') test.fail_test(os.path.exists(test.workpath('aaa.1'))) -test.fail_test(test.read('aaa.out') != "succeed.py: aaa.out\n") +test.fail_test(test.read('aaa.out',mode='r') != "succeed.py: aaa.out\n") test.fail_test(os.path.exists(test.workpath('bbb.1'))) -test.fail_test(test.read('bbb.out') != "succeed.py: bbb.out\n") +test.fail_test(test.read('bbb.out',mode='r') != "succeed.py: bbb.out\n") test.unlink("aaa.out") test.unlink("bbb.out") -test.run(arguments = '--ignore-errors aaa.1 aaa.out bbb.1 bbb.out', - stderr = - 'scons: *** [aaa.1] Error 1\n' +test.run(arguments='--ignore-errors aaa.1 aaa.out bbb.1 bbb.out', + stderr='scons: *** [aaa.1] Error 1\n' 'scons: *** [bbb.1] Error 1\n') test.fail_test(os.path.exists(test.workpath('aaa.1'))) -test.fail_test(test.read('aaa.out') != "succeed.py: aaa.out\n") +test.fail_test(test.read('aaa.out', mode='r') != "succeed.py: aaa.out\n") test.fail_test(os.path.exists(test.workpath('bbb.1'))) -test.fail_test(test.read('bbb.out') != "succeed.py: bbb.out\n") +test.fail_test(test.read('bbb.out', mode='r') != "succeed.py: bbb.out\n") test.pass_test() diff --git a/test/option-k.py b/test/option-k.py index 5cd9be9..7a01ed3 100644 --- a/test/option-k.py +++ b/test/option-k.py @@ -55,6 +55,7 @@ sys.exit(1) # test.write(['work1', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) @@ -82,7 +83,7 @@ test.run(chdir = 'work1', test.must_not_exist(test.workpath('work1', 'aaa.1')) test.must_not_exist(test.workpath('work1', 'aaa.out')) -test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n") +test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r') test.unlink(['work1', 'bbb.out']) @@ -93,7 +94,7 @@ test.run(chdir = 'work1', test.must_not_exist(test.workpath('work1', 'aaa.1')) test.must_not_exist(test.workpath('work1', 'aaa.out')) -test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n") +test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r') expect = """\ scons: Reading SConscript files ... @@ -118,6 +119,7 @@ test.must_not_exist(test.workpath('work1', 'bbb.out')) # test.write(['work2', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) @@ -146,8 +148,8 @@ scons: done building targets (errors occurred during build). test.must_not_exist(['work2', 'aaa.out']) test.must_not_exist(['work2', 'bbb.out']) -test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n") -test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n") +test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n", mode='r') +test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n", mode='r') @@ -173,6 +175,7 @@ test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n") # test.write(['work3', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 2660927..0734730 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -62,9 +62,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/config/scons.py b/test/scons-time/run/config/scons.py index 0c8b643..b782e83 100644 --- a/test/scons-time/run/config/scons.py +++ b/test/scons-time/run/config/scons.py @@ -58,9 +58,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index 70feb70..d0592b6 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -57,9 +57,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/option/scons.py b/test/scons-time/run/option/scons.py index 71d8ca2..e2479c3 100644 --- a/test/scons-time/run/option/scons.py +++ b/test/scons-time/run/option/scons.py @@ -52,9 +52,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/subdivide.py b/test/subdivide.py index 770870d..8c8eff0 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -80,6 +80,7 @@ test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', @@ -91,6 +92,7 @@ env.Object('foo.c') """ % locals()) test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', @@ -134,7 +136,7 @@ src/sub/bar.c if os.sep == '\\': expect = expect.replace('\\', '\\\\') -test.must_match(['src', 'prog.exe'], expect) +test.must_match(['src', 'prog.exe'], expect, mode='r') test.up_to_date(chdir='src', arguments = test.workpath()) |