diff options
-rw-r--r-- | test/AR/AR.py | 4 | ||||
-rw-r--r-- | test/AR/ARFLAGS.py | 4 | ||||
-rw-r--r-- | test/Actions/actions.py | 10 | ||||
-rw-r--r-- | test/Actions/addpost-link-fixture/.exclude_tests | 1 | ||||
-rw-r--r-- | test/Actions/addpost-link-fixture/strip.py | 2 | ||||
-rw-r--r-- | test/Actions/addpost-link-fixture/test1.c | 5 | ||||
-rw-r--r-- | test/Actions/addpost-link-fixture/test_lib.c | 5 | ||||
-rw-r--r-- | test/Actions/addpost-link.py | 21 | ||||
-rw-r--r-- | test/Actions/append-fixture/foo.c | 7 | ||||
-rw-r--r-- | test/Actions/append.py | 21 | ||||
-rw-r--r-- | test/Actions/pre-post-fixture/work1/bar.c | 7 | ||||
-rw-r--r-- | test/Actions/pre-post-fixture/work1/foo.c | 7 | ||||
-rw-r--r-- | test/Actions/pre-post-fixture/work2/SConstruct | 26 | ||||
-rw-r--r-- | test/Actions/pre-post-fixture/work3/SConstruct | 10 | ||||
-rw-r--r-- | test/Actions/pre-post-fixture/work4/.exclude_tests | 1 | ||||
-rw-r--r-- | test/Actions/pre-post-fixture/work4/file.in | 1 | ||||
-rw-r--r-- | test/Actions/pre-post.py | 98 | ||||
-rw-r--r-- | test/Actions/unicode-signature-fixture/SConstruct | 11 | ||||
-rw-r--r-- | test/Actions/unicode-signature.py | 14 |
19 files changed, 107 insertions, 148 deletions
diff --git a/test/AR/AR.py b/test/AR/AR.py index 573f2d9..eb4c507 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -94,13 +94,13 @@ test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") +test.must_match('wrapper.out', 'wrapper.py\n') test.pass_test() diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index fad9c19..0a9f36e 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -93,13 +93,13 @@ test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") +test.must_match('wrapper.out', 'wrapper.py\n') test.pass_test() diff --git a/test/Actions/actions.py b/test/Actions/actions.py index 785a0cb..e69cdd7 100644 --- a/test/Actions/actions.py +++ b/test/Actions/actions.py @@ -33,7 +33,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys file = open(sys.argv[1], 'wb') -file.write(sys.argv[2] + "\n") +file.write((sys.argv[2] + "\n").encode()) file.write(open(sys.argv[3], 'rb').read()) file.close sys.exit(0) @@ -49,7 +49,7 @@ test.write('foo.in', "foo.in\n") test.run(arguments = '.') -test.fail_test(test.read('foo.out') != "1\nfoo.in\n") +test.must_match('foo.out', '1\nfoo.in\n') test.up_to_date(arguments = '.') @@ -61,7 +61,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.run(arguments = '.') -test.fail_test(test.read('foo.out') != "2\nfoo.in\n") +test.must_match('foo.out', '2\nfoo.in\n') test.up_to_date(arguments = '.') @@ -79,7 +79,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.run(arguments = '.', stderr = None) -test.fail_test(test.read('foo.out') != "3\nfoo.in\n") +test.must_match('foo.out', '3\nfoo.in\n') test.up_to_date(arguments = '.') @@ -103,7 +103,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.run(arguments = '.') -test.fail_test(test.read('foo.out') != "4\nfoo.in\n") +test.must_match('foo.out', '4\nfoo.in\n') test.up_to_date(arguments = '.') diff --git a/test/Actions/addpost-link-fixture/.exclude_tests b/test/Actions/addpost-link-fixture/.exclude_tests new file mode 100644 index 0000000..03cc8e0 --- /dev/null +++ b/test/Actions/addpost-link-fixture/.exclude_tests @@ -0,0 +1 @@ +strip.py diff --git a/test/Actions/addpost-link-fixture/strip.py b/test/Actions/addpost-link-fixture/strip.py new file mode 100644 index 0000000..88242f2 --- /dev/null +++ b/test/Actions/addpost-link-fixture/strip.py @@ -0,0 +1,2 @@ +import sys +print("strip.py: %s" % " ".join(sys.argv[1:])) diff --git a/test/Actions/addpost-link-fixture/test1.c b/test/Actions/addpost-link-fixture/test1.c new file mode 100644 index 0000000..333f5c7 --- /dev/null +++ b/test/Actions/addpost-link-fixture/test1.c @@ -0,0 +1,5 @@ +extern void test_lib_fn(); +int main(int argc, char **argv) { + test_lib_fn(); + return 0; +} diff --git a/test/Actions/addpost-link-fixture/test_lib.c b/test/Actions/addpost-link-fixture/test_lib.c new file mode 100644 index 0000000..0ac1076 --- /dev/null +++ b/test/Actions/addpost-link-fixture/test_lib.c @@ -0,0 +1,5 @@ +#include <stdio.h> + +void test_lib_fn() { + printf("Hello world\n"); +} diff --git a/test/Actions/addpost-link.py b/test/Actions/addpost-link.py index 04cd68d..0a238e1 100644 --- a/test/Actions/addpost-link.py +++ b/test/Actions/addpost-link.py @@ -38,10 +38,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write('strip.py', """\ -import sys -print "strip.py: %s" % " ".join(sys.argv[1:]) -""") +test.dir_fixture('addpost-link-fixture') test.write('SConstruct', """\ env = Environment() @@ -57,22 +54,6 @@ if ARGUMENTS['case']=='2': AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].get_abspath())) """ % locals()) -test.write('test1.c', """\ -extern void test_lib_fn(); -int main(int argc, char **argv) { - test_lib_fn(); - return 0; -} -""") - -test.write('test_lib.c', r"""\ -#include <stdio.h> - -void test_lib_fn() { - printf("Hello world\n"); -} -""") - test.run(arguments="-Q case=1", stderr=None) test.run(arguments="-Q -c case=1") diff --git a/test/Actions/append-fixture/foo.c b/test/Actions/append-fixture/foo.c new file mode 100644 index 0000000..e6428b5 --- /dev/null +++ b/test/Actions/append-fixture/foo.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + printf("Foo\n"); + return 0; +} diff --git a/test/Actions/append.py b/test/Actions/append.py index f617280..68646b3 100644 --- a/test/Actions/append.py +++ b/test/Actions/append.py @@ -33,22 +33,11 @@ import stat import sys import TestSCons -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() -test.write('foo.c', r""" -#include <stdio.h> - -int main(void) -{ - printf("Foo\n"); - return 0; -} -""") +test.dir_fixture('append-fixture') test.write('SConstruct', """ @@ -56,10 +45,10 @@ env=Environment() def before(env, target, source): f=open(str(target[0]), "wb") - f.write("Foo\\n") + f.write(b"Foo\\n") f.close() f=open("before.txt", "wb") - f.write("Bar\\n") + f.write(b"Bar\\n") f.close() def after(env, target, source): @@ -77,7 +66,7 @@ env.Program(source='foo.c', target='foo') after_exe = test.workpath('after' + _exe) test.run(arguments='.') -test.fail_test(open('before.txt', 'rb').read() != "Bar\n") +test.must_match('before.txt', 'Bar\n') os.chmod(after_exe, os.stat(after_exe)[stat.ST_MODE] | stat.S_IXUSR) test.run(program=after_exe, stdout="Foo\n") test.pass_test() diff --git a/test/Actions/pre-post-fixture/work1/bar.c b/test/Actions/pre-post-fixture/work1/bar.c new file mode 100644 index 0000000..eb3fd78 --- /dev/null +++ b/test/Actions/pre-post-fixture/work1/bar.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + printf("bar.c\n"); + return 0; +} diff --git a/test/Actions/pre-post-fixture/work1/foo.c b/test/Actions/pre-post-fixture/work1/foo.c new file mode 100644 index 0000000..32f2a3e --- /dev/null +++ b/test/Actions/pre-post-fixture/work1/foo.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + printf("foo.c\n"); + return 0; +} diff --git a/test/Actions/pre-post-fixture/work2/SConstruct b/test/Actions/pre-post-fixture/work2/SConstruct new file mode 100644 index 0000000..61f739f --- /dev/null +++ b/test/Actions/pre-post-fixture/work2/SConstruct @@ -0,0 +1,26 @@ +def b(target, source, env): + open(str(target[0]), 'wb').write((env['X'] + '\n').encode()) +env1 = Environment(X='111') +env2 = Environment(X='222') +B = Builder(action = b, env = env1, multi=1) +print("B =", B) +print("B.env =", B.env) +env1.Append(BUILDERS = {'B' : B}) +env2.Append(BUILDERS = {'B' : B}) +env3 = env1.Clone(X='333') +print("env1 =", env1) +print("env2 =", env2) +print("env3 =", env3) +f1 = env1.B(File('file1.out'), []) +f2 = env2.B('file2.out', []) +f3 = env3.B('file3.out', []) +def do_nothing(env, target, source): + pass +AddPreAction(f2[0], do_nothing) +AddPostAction(f3[0], do_nothing) +print("f1[0].builder =", f1[0].builder) +print("f2[0].builder =", f2[0].builder) +print("f3[0].builder =", f3[0].builder) +print("f1[0].env =", f1[0].env) +print("f2[0].env =", f2[0].env) +print("f3[0].env =", f3[0].env) diff --git a/test/Actions/pre-post-fixture/work3/SConstruct b/test/Actions/pre-post-fixture/work3/SConstruct new file mode 100644 index 0000000..0e13fa2 --- /dev/null +++ b/test/Actions/pre-post-fixture/work3/SConstruct @@ -0,0 +1,10 @@ +def pre(target, source, env): + pass +def post(target, source, env): + pass +def build(target, source, env): + open(str(target[0]), 'wb').write(b'build()\n') +env = Environment() +AddPreAction('dir', pre) +AddPostAction('dir', post) +env.Command('dir/file', [], build) diff --git a/test/Actions/pre-post-fixture/work4/.exclude_tests b/test/Actions/pre-post-fixture/work4/.exclude_tests new file mode 100644 index 0000000..3fb299e --- /dev/null +++ b/test/Actions/pre-post-fixture/work4/.exclude_tests @@ -0,0 +1 @@ +build.py diff --git a/test/Actions/pre-post-fixture/work4/file.in b/test/Actions/pre-post-fixture/work4/file.in new file mode 100644 index 0000000..1912927 --- /dev/null +++ b/test/Actions/pre-post-fixture/work4/file.in @@ -0,0 +1 @@ +file.in diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index f6997e2..a5acbfb 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -37,9 +37,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.subdir('work1', 'work2', 'work3', 'work4') - - +test.dir_fixture('pre-post-fixture') test.write(['work1', 'SConstruct'], """ import os.path @@ -50,11 +48,11 @@ env = Environment(XXX='bar%(_exe)s') def before(env, target, source): a=str(target[0]) f=open(a, "wb") - f.write("Foo\\n") + f.write(b"Foo\\n") f.close() os.chmod(a, os.stat(a)[stat.ST_MODE] | stat.S_IXUSR) f=open("before.txt", "ab") - f.write(os.path.splitext(str(target[0]))[0] + "\\n") + f.write((os.path.splitext(str(target[0]))[0] + "\\n").encode()) f.close() def after(env, target, source): @@ -76,26 +74,6 @@ env.AddPreAction('$XXX', before) env.AddPostAction('$XXX', after) """ % locals()) -test.write(['work1', 'foo.c'], r""" -#include <stdio.h> - -int main(void) -{ - printf("foo.c\n"); - return 0; -} -""") - -test.write(['work1', 'bar.c'], r""" -#include <stdio.h> - -int main(void) -{ - printf("bar.c\n"); - return 0; -} -""") - test.run(chdir='work1', arguments='.') test.run(program=test.workpath('work1', 'foo'+ _exe), stdout="foo.c\n") @@ -109,59 +87,14 @@ test.run(program=after_foo_exe, stdout="foo.c\n") after_bar_exe = test.workpath('work1', 'after_bar' + _exe) test.run(program=after_bar_exe, stdout="bar.c\n") - - - -test.write(['work2', 'SConstruct'], """\ -def b(target, source, env): - open(str(target[0]), 'wb').write(env['X'] + '\\n') -env1 = Environment(X='111') -env2 = Environment(X='222') -B = Builder(action = b, env = env1, multi=1) -print("B =", B) -print("B.env =", B.env) -env1.Append(BUILDERS = {'B' : B}) -env2.Append(BUILDERS = {'B' : B}) -env3 = env1.Clone(X='333') -print("env1 =", env1) -print("env2 =", env2) -print("env3 =", env3) -f1 = env1.B(File('file1.out'), []) -f2 = env2.B('file2.out', []) -f3 = env3.B('file3.out', []) -def do_nothing(env, target, source): - pass -AddPreAction(f2[0], do_nothing) -AddPostAction(f3[0], do_nothing) -print("f1[0].builder =", f1[0].builder) -print("f2[0].builder =", f2[0].builder) -print("f3[0].builder =", f3[0].builder) -print("f1[0].env =", f1[0].env) -print("f2[0].env =", f2[0].env) -print("f3[0].env =", f3[0].env) -""") - +# work2 start test.run(chdir='work2', arguments = '.') test.must_match(['work2', 'file1.out'], "111\n") test.must_match(['work2', 'file2.out'], "222\n") test.must_match(['work2', 'file3.out'], "333\n") - - -test.write(['work3', 'SConstruct'], """\ -def pre(target, source, env): - pass -def post(target, source, env): - pass -def build(target, source, env): - open(str(target[0]), 'wb').write('build()\\n') -env = Environment() -AddPreAction('dir', pre) -AddPostAction('dir', post) -env.Command('dir/file', [], build) -""") - +# work3 start test.run(chdir = 'work3', arguments = 'dir/file', stdout=test.wrap_stdout("""\ pre(["dir"], []) post(["dir"], []) @@ -170,21 +103,12 @@ build(["%s"], []) test.must_match(['work3', 'dir', 'file'], "build()\n") - - -test.write(['work4', 'build.py'], """\ -import sys -outfp = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - outfp.write(open(f, 'rb').read()) -outfp.close() -""") - +# work4 start test.write(['work4', 'SConstruct'], """\ def pre_action(target, source, env): - open(str(target[0]), 'ab').write('pre %%s\\n' %% source[0]) + open(str(target[0]), 'ab').write(('pre %%s\\n' %% source[0]).encode()) def post_action(target, source, env): - open(str(target[0]), 'ab').write('post %%s\\n' %% source[0]) + open(str(target[0]), 'ab').write(('post %%s\\n' %% source[0]).encode()) env = Environment() o = env.Command(['pre-post', 'file.out'], 'file.in', @@ -193,8 +117,6 @@ env.AddPreAction(o, pre_action) env.AddPostAction(o, post_action) """ % locals()) -test.write(['work4', 'file.in'], "file.in\n") - test.run(chdir='work4', arguments='.') test.must_match(['work4', 'file.out'], "file.in\n") @@ -202,10 +124,6 @@ test.must_match(['work4', 'pre-post'], "pre file.in\npost file.in\n") test.pass_test() - - -test.pass_test() - # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/test/Actions/unicode-signature-fixture/SConstruct b/test/Actions/unicode-signature-fixture/SConstruct new file mode 100644 index 0000000..9c0f03d --- /dev/null +++ b/test/Actions/unicode-signature-fixture/SConstruct @@ -0,0 +1,11 @@ +fnode = File(u'foo.txt') + +def funcact(target, source, env): + open(str(target[0]), 'wb').write(b"funcact\n") + for i in range(300): + pass + return 0 + +env = Environment() + +env.Command(fnode, [], ["echo $TARGET", funcact]) diff --git a/test/Actions/unicode-signature.py b/test/Actions/unicode-signature.py index d91bfa8..ef8c888 100644 --- a/test/Actions/unicode-signature.py +++ b/test/Actions/unicode-signature.py @@ -42,19 +42,7 @@ test = TestSCons.TestSCons() ## msg = "Unicode not supported by Python version %s; skipping test\n" ## test.skip_test(msg % sys.version[:3]) -test.write('SConstruct', """ -fnode = File(u'foo.txt') - -def funcact(target, source, env): - open(str(target[0]), 'wb').write("funcact\\n") - for i in range(300): - pass - return 0 - -env = Environment() - -env.Command(fnode, [], ["echo $TARGET", funcact]) -""") +test.dir_fixture('unicode-signature-fixture') test.run(arguments = '.') |