From 2a69a71894e681e7060e168b99fe7cc608ad7d33 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Sat, 29 Sep 2001 10:25:07 +0000 Subject: Don't use Program() on some tests that don't need it. --- test/Default.py | 73 +++++++++++++++++++++----------------------- test/option-c.py | 93 ++++++++++++++++++++++++-------------------------------- 2 files changed, 73 insertions(+), 93 deletions(-) diff --git a/test/Default.py b/test/Default.py index 916ad24..8a92910 100644 --- a/test/Default.py +++ b/test/Default.py @@ -9,61 +9,56 @@ test = TestSCons.TestSCons() test.subdir('one', 'two', 'three') +test.write('build.py', r""" +import sys +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') +file.write(contents) +file.close() +""") + test.write(['one', 'SConstruct'], """ -env = Environment() -env.Program(target = 'foo', source = 'foo.c') -env.Program(target = 'bar', source = 'bar.c') -Default('foo') +B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s") +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +env.B(target = 'bar.out', source = 'bar.in') +Default('foo.out') """) test.write(['two', 'SConstruct'], """ -env = Environment() -env.Program(target = 'foo', source = 'foo.c') -env.Program(target = 'bar', source = 'bar.c') -Default('foo', 'bar') +B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s") +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +env.B(target = 'bar.out', source = 'bar.in') +Default('foo.out', 'bar.out') """) test.write(['three', 'SConstruct'], """ -env = Environment() -env.Program(target = 'foo', source = 'foo.c') -env.Program(target = 'bar', source = 'bar.c') -Default('foo bar') +B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s") +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +env.B(target = 'bar.out', source = 'bar.in') +Default('foo.out bar.out') """) for dir in ['one', 'two', 'three']: - foo_c = os.path.join(dir, 'foo.c') - bar_c = os.path.join(dir, 'bar.c') - - test.write(foo_c, """ -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("%s\n"); - exit (0); -} -""" % foo_c) - - test.write(bar_c, """ -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("%s\n"); - exit (0); -} -""" % bar_c) + foo_in = os.path.join(dir, 'foo.in') + bar_in = os.path.join(dir, 'bar.in') + + test.write(foo_in, foo_in + "\n"); + + test.write(bar_in, bar_in + "\n"); test.run(chdir = dir) # no arguments, use the Default -test.run(program = test.workpath('one', 'foo'), stdout = "one/foo.c\n") +test.fail_test(test.read(test.workpath('one', 'foo.out')) != "one/foo.in\n") test.fail_test(os.path.exists(test.workpath('one', 'bar'))) -test.run(program = test.workpath('two', 'foo'), stdout = "two/foo.c\n") -test.run(program = test.workpath('two', 'bar'), stdout = "two/bar.c\n") +test.fail_test(test.read(test.workpath('two', 'foo.out')) != "two/foo.in\n") +test.fail_test(test.read(test.workpath('two', 'bar.out')) != "two/bar.in\n") -test.run(program = test.workpath('three', 'foo'), stdout = "three/foo.c\n") -test.run(program = test.workpath('three', 'bar'), stdout = "three/bar.c\n") +test.fail_test(test.read(test.workpath('three', 'foo.out')) != "three/foo.in\n") +test.fail_test(test.read(test.workpath('three', 'bar.out')) != "three/bar.in\n") test.pass_test() diff --git a/test/option-c.py b/test/option-c.py index 1098a03..0edcebb 100644 --- a/test/option-c.py +++ b/test/option-c.py @@ -9,78 +9,63 @@ test = TestSCons.TestSCons() test.pass_test() #XXX Short-circuit until this is implemented. -test.write('SConstruct', """ -env = Environment() -Program(target = 'foo1', source = 'foo1.c') -Program(target = 'foo2', source = 'foo2.c') -Program(target = 'foo3', source = 'foo3.c') +test.write('build.py', r""" +import sys +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') +file.write(contents) +file.close() """) -test.write('foo1.c', """ -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo1.c\n"); - exit (0); -} +test.write('SConstruct', """ +B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s") +env = Environment(BUILDERS = [B]) +env.B(target = 'foo1.out', source = 'foo1.in') +env.B(target = 'foo2.out', source = 'foo2.in') +env.B(target = 'foo3.out', source = 'foo3.in') """) -test.write('foo2.c', """ -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo2.c\n"); - exit (0); -} -""") +test.write('foo1.in', "foo1.in\n") -test.write('foo3.c', """ -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo3.c\n"); - exit (0); -} -""") +test.write('foo2.in', "foo2.in\n") + +test.write('foo3.in', "foo3.in\n") -test.run(arguments = 'foo1 foo2 foo3') +test.run(arguments = 'foo1.out foo2.out foo3.out') -test.run(program = test.workpath('foo1'), stdout = "foo1.c\n") -test.run(program = test.workpath('foo2'), stdout = "foo2.c\n") -test.run(program = test.workpath('foo3'), stdout = "foo3.c\n") +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.run(arguments = '-c foo1') +test.run(arguments = '-c foo1.out') -test.fail_test(os.path.exists(test.workpath('foo1'))) -test.fail_test(not os.path.exists(test.workpath('foo2'))) -test.fail_test(not os.path.exists(test.workpath('foo3'))) +test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(not os.path.exists(test.workpath('foo2.out'))) +test.fail_test(not os.path.exists(test.workpath('foo3.out'))) -test.run(arguments = '--clean foo2') +test.run(arguments = '--clean foo2.out') -test.fail_test(os.path.exists(test.workpath('foo1'))) -test.fail_test(os.path.exists(test.workpath('foo2'))) -test.fail_test(not os.path.exists(test.workpath('foo3'))) +test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(os.path.exists(test.workpath('foo2.out'))) +test.fail_test(not os.path.exists(test.workpath('foo3.out'))) -test.run(arguments = '--remove foo3') +test.run(arguments = '--remove foo3.out') -test.fail_test(os.path.exists(test.workpath('foo1'))) -test.fail_test(os.path.exists(test.workpath('foo2'))) -test.fail_test(os.path.exists(test.workpath('foo3'))) +test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(os.path.exists(test.workpath('foo2.out'))) +test.fail_test(os.path.exists(test.workpath('foo3.out'))) -test.run(arguments = 'foo1 foo2 foo3') +test.run(arguments = 'foo1.out foo2.out foo3.out') -test.run(program = test.workpath('foo1'), stdout = "foo1.c\n") -test.run(program = test.workpath('foo2'), stdout = "foo2.c\n") -test.run(program = test.workpath('foo3'), stdout = "foo3.c\n") +test.run(program = test.workpath('foo1.out'), stdout = "foo1.in\n") +test.run(program = test.workpath('foo2.out'), stdout = "foo2.in\n") +test.run(program = test.workpath('foo3.out'), stdout = "foo3.in\n") test.run(arguments = '-c .') -test.fail_test(os.path.exists(test.workpath('foo1'))) -test.fail_test(os.path.exists(test.workpath('foo2'))) -test.fail_test(os.path.exists(test.workpath('foo3'))) +test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(os.path.exists(test.workpath('foo2.out'))) +test.fail_test(os.path.exists(test.workpath('foo3.out'))) test.pass_test() -- cgit v0.12