diff options
-rw-r--r-- | test/Parallel/ref_count.py | 8 | ||||
-rw-r--r-- | test/RANLIB/RANLIBFLAGS.py | 2 | ||||
-rw-r--r-- | test/Repository/Default.py | 14 | ||||
-rw-r--r-- | test/Repository/Install.py | 2 | ||||
-rw-r--r-- | test/Repository/InstallAs.py | 6 | ||||
-rw-r--r-- | test/Repository/LIBPATH.py | 14 | ||||
-rw-r--r-- | test/Repository/Local.py | 16 | ||||
-rw-r--r-- | test/Repository/SConscript.py | 12 | ||||
-rw-r--r-- | test/Repository/VariantDir.py | 28 | ||||
-rw-r--r-- | test/Repository/option-c.py | 66 | ||||
-rw-r--r-- | test/Repository/option-f.py | 10 | ||||
-rw-r--r-- | test/Repository/option-n.py | 6 | ||||
-rw-r--r-- | test/Repository/targets.py | 14 | ||||
-rw-r--r-- | test/Scanner/FindPathDirs.py | 6 | ||||
-rw-r--r-- | test/Scanner/Scanner.py | 8 | ||||
-rw-r--r-- | test/Scanner/generated.py | 2 | ||||
-rw-r--r-- | test/Scanner/no-Dir-node.py | 10 | ||||
-rw-r--r-- | test/TAR/TAR.py | 14 | ||||
-rw-r--r-- | test/TAR/TARFLAGS.py | 14 | ||||
-rw-r--r-- | test/TEX/LATEXFLAGS.py | 10 | ||||
-rw-r--r-- | test/Variables/Variables.py | 5 | ||||
-rw-r--r-- | test/VariantDir/Clean.py | 4 | ||||
-rw-r--r-- | test/VariantDir/File-create.py | 4 | ||||
-rw-r--r-- | test/VariantDir/errors.py | 6 | ||||
-rw-r--r-- | test/builderrors.py | 10 |
25 files changed, 141 insertions, 150 deletions
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.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 c95d29a..8b396fa 100644 --- a/test/Repository/LIBPATH.py +++ b/test/Repository/LIBPATH.py @@ -46,7 +46,7 @@ bbb_exe = env_yyy.Program('bbb', 'bbb.c') def write_LIBDIRFLAGS(env, target, source): pre = env.subst('$LIBDIRPREFIX') suf = env.subst('$LIBDIRSUFFIX') - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for arg in env.subst('$_LIBDIRFLAGS', target=target).split(): if arg[:len(pre)] == pre: arg = arg[len(pre):] @@ -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/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 d1e0bb8..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('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 725404c..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("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("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 d1490d4..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']) != "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', """ |