From c8bbea81460524f6469fa4b6afc2be5a6f338edc Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 21 Sep 2001 01:30:38 +0000 Subject: Add additional tests to provide more examples. --- test/CC.py | 16 +++++++++ test/CCFLAGS.py | 39 ++++++++++++++++++++ test/CPPPATH.py | 16 +++++++++ test/Command.py | 44 +++++++++++++++++++++++ test/Depends.py | 80 +++++++++++++++++++++++++++++++++++++++++ test/LIBPATH.py | 16 +++++++++ test/LIBPREFIX.py | 16 +++++++++ test/LIBS.py | 16 +++++++++ test/LIBSUFFIX.py | 16 +++++++++ test/LINK.py | 16 +++++++++ test/LINKFLAGS.py | 16 +++++++++ test/Library.py | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test/Object.py | 69 +++++++++++++++++++++++++++++++++++ test/Program.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++--- test/README | 71 ++++++++++++++++++++++++++++++++++++ test/option-c.py | 81 ++++++++++++++++++++++++++++++++++++----- test/option-d.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++--- test/option-i.py | 54 ++++++++++++++++++++++++---- test/option-k.py | 49 +++++++++++++++++++++---- 19 files changed, 894 insertions(+), 33 deletions(-) create mode 100644 test/CC.py create mode 100644 test/CCFLAGS.py create mode 100644 test/CPPPATH.py create mode 100644 test/Command.py create mode 100644 test/Depends.py create mode 100644 test/LIBPATH.py create mode 100644 test/LIBPREFIX.py create mode 100644 test/LIBS.py create mode 100644 test/LIBSUFFIX.py create mode 100644 test/LINK.py create mode 100644 test/LINKFLAGS.py create mode 100644 test/Library.py create mode 100644 test/Object.py create mode 100644 test/README diff --git a/test/CC.py b/test/CC.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/CC.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/CCFLAGS.py b/test/CCFLAGS.py new file mode 100644 index 0000000..356fc84 --- /dev/null +++ b/test/CCFLAGS.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +foo = Environment(CCFLAGS = '-DFOO') +bar = Environment(CCFLAGS = '-DBAR') +foo.Program(target = 'progfoo', source = 'prog.c') +bar.Program(target = 'progbar', source = 'prog.c') +""") + +test.write('prog.c', """ +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; +#ifdef FOO + printf("prog.c: FOO\n"); +#endif +#ifdef BAR + printf("prog.c: BAR\n"); +#endif + exit (0); +} +""") + + +test.run(arguments = 'progfoo progbar') + +test.run(program = test.workpath('progfoo'), stdout = "prog.c: FOO\n") +test.run(program = test.workpath('progbar'), stdout = "prog.c: BAR\n") + +test.pass_test() diff --git a/test/CPPPATH.py b/test/CPPPATH.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/CPPPATH.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/Command.py b/test/Command.py new file mode 100644 index 0000000..abe060e --- /dev/null +++ b/test/Command.py @@ -0,0 +1,44 @@ + +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('build.py', r""" +import sys +contents = open(sys.argv[2], 'r').read() + open(sys.argv[3], 'r').read() +file = open(sys.argv[1], 'w') +file.write(contents) +file.close() +""") + +test.write('SConstruct', """ +env = Environment() +env.Command(target = 'f1.out', source = 'f1.in', + action = "python build.py %(target)s %(source)s") +env.Command(target = 'f2.out', source = 'f2.in', + action = "python build.py temp2 %(source)s\npython build.py %(target)s temp2") +env.Command(target = 'f3.out', source = 'f3.in', + action = ["python build.py temp3 %(source)s", + "python build.py %(target)s temp3"]) +# Eventually, add ability to do execute Python code. +""") + +test.write('f1.in', "f1.in\n") + +test.write('f2.in', "f2.in\n") + +test.write('f3.in', "f3.in\n") + +test.run(arguments = '.') + +test.fail_test(test.read('f1.out') != "f1.in\n") +test.fail_test(test.read('f2.out') != "f2.in\n") +test.fail_test(test.read('f3.out') != "f3.in\n") + +test.pass_test() diff --git a/test/Depends.py b/test/Depends.py new file mode 100644 index 0000000..5c6c4f1 --- /dev/null +++ b/test/Depends.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.subdir('subdir') + +test.write('build.py', r""" +import sys +contents = open(sys.argv[2], 'r').read() + open(sys.argv[3], 'r').read() +file = open(sys.argv[1], 'w') +file.write(contents) +file.close() +""") + +test.write('SConstruct', """ +Foo = Builder(name = "Foo", + action = "python build.py %(target)s %(source)s subdir/foo.dep") +Bar = Builder(name = "Bar", + action = "python build.py %(target)s %(source)s subdir/bar.dep") +env = Environment(BUILDERS = [Foo, Bar]) +env.Depends(target = ['f1.out', 'f2.out'], source = 'subdir/foo.dep') +env.Depends(target = 'f3.out', source = 'subdir/bar.dep') +env.Foo(target = 'f1.out', source = 'f1.in') +env.Foo(target = 'f2.out', source = 'f2.in') +env.Bar(target = 'f3.out', source = 'f3.in') +SConscript('subdir/SConscript') +""") + +test.write(['subdir', 'SConscript'], """ +env.Depends(target = 'f4.out', source = 'bar.dep') +env.Foo(target = 'f4.out', source = 'f4.in') +""") + +test.write('f1.in', "f1.in\n") + +test.write('f2.in', "f2.in\n") + +test.write(['subdir', 'f4.in'], "subdir/f4.in\n") + +test.write(['subdir', 'foo.dep'], "subdir/foo.dep 1\n") + +test.write(['subdir', 'bar.dep'], "subdir/bar.dep 1\n") + +test.run(arguments = '.') + +test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 1\n") +test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 1\n") +test.fail_test(test.read('f3.out') != "f3.in\nsubdir/bar.dep 1\n") +test.fail_test(test.read('subdir', 'f4.out') != + "subdir/f4.in\nsubdir/bar.dep 1\n") + +test.write(['subdir', 'foo.dep'], "subdir/foo.dep 2\n") + +test.write(['subdir', 'bar.dep'], "subdir/bar.dep 2\n") + +test.run(arguments = '.') + +test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 2\n") +test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 2\n") +test.fail_test(test.read('f3.out') != "f3.in\nsubdir/bar.dep 2\n") +test.fail_test(test.read('subdir', 'f4.out') != + "subdir/f4.in\nsubdir/bar.dep 2\n") + +test.write(['subdir', 'bar.dep'], "subdir/bar.dep 3\n") + +test.run(arguments = '.') + +test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 2\n") +test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 2\n") +test.fail_test(test.read('f3.out') != "f3.in\nsubdir/bar.dep 2\n") +test.fail_test(test.read('subdir', 'f4.out') != + "subdir/f4.in\nsubdir/bar.dep 3\n") + +test.pass_test() diff --git a/test/LIBPATH.py b/test/LIBPATH.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/LIBPATH.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/LIBPREFIX.py b/test/LIBPREFIX.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/LIBPREFIX.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/LIBS.py b/test/LIBS.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/LIBS.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/LIBSUFFIX.py b/test/LIBSUFFIX.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/LIBSUFFIX.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/LINK.py b/test/LINK.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/LINK.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/LINKFLAGS.py b/test/LINKFLAGS.py new file mode 100644 index 0000000..a3ad79f --- /dev/null +++ b/test/LINKFLAGS.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +""") + +test.run(arguments = '.') + +test.pass_test() diff --git a/test/Library.py b/test/Library.py new file mode 100644 index 0000000..78bf414 --- /dev/null +++ b/test/Library.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is implemented. + +test.write('SConstruct', """ +env = Environment(LIBS = 'foo1 foo2 foo3') +env.Library(target = 'foo1', source = 'f1.c') +env.Library(target = 'foo2', source = 'f2a.c f2b.c f2c.c') +env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) +env.Program(target = 'prog', source = 'prog.c') +""") + +test.write('f1.c', """ +void +f1(void) +{ + printf("f1.c\n"); +} +""") + +test.write('f2a.c', """ +void +f2a(void) +{ + printf("f2a.c\n"); +} +""") + +test.write('f2b.c', """ +void +f2b(void) +{ + printf("f2b.c\n"); +} +""") + +test.write('f2c.c', """ +void +f2c(void) +{ + printf("f2c.c\n"); +} +""") + +test.write('f3a.c', """ +void +f3a(void) +{ + printf("f3a.c\n"); +} +""") + +test.write('f3b.c', """ +void +f3b(void) +{ + printf("f3b.c\n"); +} +""") + +test.write('f3c.c', """ +f3c(void) +{ + printf("f3c.c\n"); +} +""") + +test.write('prog.c', """ +void f1(void); +void f2a(void); +void f2b(void); +void f2c(void); +void f3a(void); +void f3b(void); +void f3c(void); +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + f1(); + f2a(); + f2b(); + f2c(); + f3a(); + f3b(); + f3c(); + printf("prog.c\n"); +} +""") + +test.run(arguments = 'libfoo1.a libfoo2.a libfoo3.a') + +test.run(program = test.workpath('prog'), + stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n") + +test.pass_test() diff --git a/test/Object.py b/test/Object.py new file mode 100644 index 0000000..781e460 --- /dev/null +++ b/test/Object.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.pass_test() #XXX Short-circuit until this is supported. + +test.write('SConstruct', """ +f1 = env.Object(target = 'f1', source = 'f1.c') +f2 = env.Object(target = 'f2', source = 'f2.c') +f3 = env.Object(target = 'f3', source = 'f3.c') +env.Program(target = 'prog1', source = 'f1.o f2.o f3.o prog.c') +env.Program(target = 'prog2', source = [f1, f2, f3, 'prog.c']) +env.Program(target = 'prog3', source = ['f1.o', f2, 'f3.o prog.c']) +""") + +test.write('f1.c', """ +void +f1(void) +{ + printf("f1.c\n"); +} +""") + +test.write('f2.c', """ +void +f2(void) +{ + printf("f2.c\n"); +} +""") + +test.write('f3.c', """ +void +f3(void) +{ + printf("f3.c\n"); +} +""") + +test.write('prog.c', """ +extern void f1(void); +extern void f2(void); +extern void f3(void); +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + f1(); + f2(); + f3(); + printf("prog.c\n"); +} +""") + +stdout = "f1.c\nf2.c\nf3.c\nprog.c\n" + +test.run(arguments = 'prog1 prog2 prog3') + +test.run(program = test.workpath('prog1'), stdout = stdout) + +test.run(program = test.workpath('prog2'), stdout = stdout) + +test.run(program = test.workpath('prog3'), stdout = stdout) + +test.pass_test() diff --git a/test/Program.py b/test/Program.py index a2b0e4b..d517808 100644 --- a/test/Program.py +++ b/test/Program.py @@ -4,25 +4,121 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +#XXX Future: be able to interpolate + test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment() -env.Program(target = 'foo', source = 'foo.c') +env.Program(target = 'foo1', source = 'f1.c') +env.Program(target = 'foo2', source = 'f2a.c f2b.c f2c.c') +#XXXenv.Program(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) """) -test.write('foo.c', """ +test.write('f1.c', """ int main(int argc, char *argv[]) { argv[argc++] = "--"; - printf("foo.c\n"); + printf("f1.c\n"); exit (0); } """) -test.run(arguments = 'foo') +test.write('f2a.c', """ +void +f2a(void) +{ + printf("f2a.c\n"); +} +""") + +test.write('f2b.c', """ +void +f2b(void) +{ + printf("f2b.c\n"); +} +""") + +test.write('f2c.c', """ +extern void f2a(void); +extern void f2b(void); +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + f2a(); + f2b(); + printf("f2c.c\n"); + exit (0); +} +""") + +test.write('f3a.c', """ +void +f3a(void) +{ + printf("f3a.c\n"); +} +""") + +test.write('f3b.c', """ +void +f3b(void) +{ + printf("f3b.c\n"); +} +""") + +test.write('f3c.c', """ +extern void f3a(void); +extern void f3b(void); +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + f3a(); + f3b(); + printf("f3c.c\n"); + exit (0); +} +""") + +#XXXtest.run(arguments = '.') +test.run(arguments = 'foo1 foo2') + +test.run(program = test.workpath('foo1'), stdout = "f1.c\n") +test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") +#XXXtest.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c\nf3c.c\n") + +#XXXtest.up_to_date(arguments = '.') + +test.write('f1.c', """ +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f1.c X\n"); + exit (0); +} +""") + +test.write('f3b.c', """ +void +f3b(void) +{ + printf("f3b.c X\n"); +} +""") + +#XXXtest.run(arguments = '.') +test.run(arguments = 'foo1 foo2') + +test.run(program = test.workpath('foo1'), stdout = "f1.c X\n") +test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") +#XXXtest.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c X\nf3c.c\n") -test.run(program = test.workpath('foo'), stdout = "foo.c\n") +#XXXtest.up_to_date(arguments = '.') test.pass_test() diff --git a/test/README b/test/README new file mode 100644 index 0000000..4834f5b --- /dev/null +++ b/test/README @@ -0,0 +1,71 @@ +This directory contains our end-to-end SCons tests. + +They are all meant to be run essentially standalone, with the exception +of the TestSCons.py module (and the TestCmd.py module it imports) that +is imported by each test. These modules are in the etc/ subdirectory, +and PYTHONPATH needs to be set up correctly so that the test script can +find them, and so that the SCons script itself can find the build engine +modules. + +There is a wrapper script, runtest.py, that takes care of this for you, +so the canonical invocation of a test is: + + python runtest.py test/option-x.py + +There is also a "runtest.py -a" option that will search the tree for +all tests, and execute them. + +Many of these tests have code for features that are not yet supported, +but which will be part of SCons IN THE CURRENT PLANNED RELEASE. These +are either: + + commented out with a "#XXX" at the beginning of the line; + + short-circuited entirely by having the test pass via an + early call to test.pass_test(), which has a "#XXX" comment + at the end of the line + +The upshot is that you should be able to: + + egrep -l '#XXX' test/*.c + +and see a list of the tests we still have to make work in order to get +the next release out the door. + +If you're trying to implement one of these features, DO NOT BLINDLY +ASSUME THAT THE NEW CODE IN THE TEST IS CORRECT. It may have problems +that have gone undiscovered due to the fact that the code testing the +future feature couldn't be run yet! + +We're not going to be dogmatic about it, but so that there's some +semblance of uniformity, here are the naming conventions for tests: + + -- All tests end with a .py suffix. + + -- General form: + + Feature.py test of specified feature; try to + keep this description reasonably + short + + Feature-01.py additional tests of specified + Feature-02.py feature + Feature-03.py + + Feature-x.py test of specified feature using + option x + + Feature-x-01.py additional tests of specified + Feature-x-02.py feature using option x + Feature-x-03.py + + -- Command line option tests take the form: + + option-x.py lower-case single-letter option + + option--X.py upper-case single-letter option + (extra hyphen so the file names will + be unique on case-insensitive systems) + + option--lo.py long option; abbreviate the long + option name to a few characters diff --git a/test/option-c.py b/test/option-c.py index ac84d05..1098a03 100644 --- a/test/option-c.py +++ b/test/option-c.py @@ -2,22 +2,85 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os.path import TestSCons -import string -import sys test = TestSCons.TestSCons() -test.write('SConstruct', "") +test.pass_test() #XXX Short-circuit until this is implemented. -test.run(arguments = '-c', - stderr = "Warning: the -c option is not yet implemented\n") +test.write('SConstruct', """ +env = Environment() +Program(target = 'foo1', source = 'foo1.c') +Program(target = 'foo2', source = 'foo2.c') +Program(target = 'foo3', source = 'foo3.c') +""") -test.run(arguments = '--clean', - stderr = "Warning: the --clean option is not yet implemented\n") +test.write('foo1.c', """ +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo1.c\n"); + exit (0); +} +""") -test.run(arguments = '--remove', - stderr = "Warning: the --remove option is not yet implemented\n") +test.write('foo2.c', """ +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo2.c\n"); + exit (0); +} +""") + +test.write('foo3.c', """ +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo3.c\n"); + exit (0); +} +""") + +test.run(arguments = 'foo1 foo2 foo3') + +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(arguments = '-c foo1') + +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.run(arguments = '--clean foo2') + +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.run(arguments = '--remove foo3') + +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.run(arguments = 'foo1 foo2 foo3') + +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(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.pass_test() diff --git a/test/option-d.py b/test/option-d.py index a9bc1e8..e5efcbc 100644 --- a/test/option-d.py +++ b/test/option-d.py @@ -3,15 +3,109 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -import string -import sys test = TestSCons.TestSCons() -test.write('SConstruct', "") +test.pass_test() #XXX Short-circuit until this is supported. -test.run(arguments = '-d', - stderr = "Warning: the -d option is not yet implemented\n") +test.subdir('subdir') + +test.write('SConstruct', """ +env = Environment() +env.Program(target = 'aaa', source = 'aaa.c') +env.Program(target = 'bbb', source = 'bbb.c') +SConscript('subdir/SConscript') +""") + +test.write(['subdir', 'SConscript'], """ +env = Environment() +env.Program(target = 'ccc', source = 'ccc.c') +env.Program(target = 'ddd', source = 'ddd.c') +""") + +test.write('aaa.c', """ +int +main(int argc, char *argv) +{ + argv[argc++] = "--"; + printf("aaa.c\n"); + exit (0); +} +""") + +test.write('bbb.c', """ +int +main(int argc, char *argv) +{ + argv[argc++] = "--"; + printf("bbb.c\n"); + exit (0); +} +""") + +test.write(['subdir', 'ccc.c'], """ +int +main(int argc, char *argv) +{ + argv[argc++] = "--"; + printf("subdir/ccc.c\n"); + exit (0); +} +""") + +test.write(['subdir', 'ddd.c'], """ +int +main(int argc, char *argv) +{ + argv[argc++] = "--"; + printf("subdir/ddd.c\n"); + exit (0); +} +""") + +test.run(arguments = '-d .', stdout = """ +Target aaa: aaa.o +Checking aaa + Checking aaa.o + Checking aaa.c + Rebuilding aaa.o: out of date. +cc -c -o aaa.o aaa.c +Rebuilding aaa: out of date. +cc -o aaa aaa.o +Target aaa.o: aaa.c +Target bbb: bbb.o +Checking bbb + Checking bbb.o + Checking bbb.c + Rebuilding bbb.o: out of date. +cc -c -o bbb.o bbb.c +Rebuilding bbb: out of date. +cc -o bbb bbb.o +Target bbb.o: bbb.c +Target subdir/ccc/g: subdir/ccc.o +Checking subdir/ccc/g + Checking subdir/ccc/g.o + Checking subdir/ccc/g.c + Rebuilding subdir/ccc/g.o: out of date. +cc -c -o subdir/ccc/g.o subdir/ccc.c +Rebuilding subdir/ccc/g: out of date. +cc -o subdir/ccc/g subdir/ccc.o +Target subdir/ccc/g.o: subdir/ccc.c +Target subdir/ddd/g: subdir/ddd.o +Checking subdir/ddd/g + Checking subdir/ddd/g.o + Checking subdir/ddd/g.c + Rebuilding subdir/ddd/g.o: out of date. +cc -c -o subdir/ddd/g.o subdir/ddd.c +Rebuilding subdir/ddd/g: out of date. +cc -o subdir/ddd/g subdir/ddd.o +Target subdir/ddd/g.o: subdir/ddd.c +""") + +test.run(program = test.workpath('aaa'), stdout = "aaa.c\n") +test.run(program = test.workpath('bbb'), stdout = "bbb.c\n") +test.run(program = test.workpath('subdir/ccc'), stdout = "subdir/ccc.c\n") +test.run(program = test.workpath('subdir/ddd'), stdout = "subdir/ddd.c\n") test.pass_test() diff --git a/test/option-i.py b/test/option-i.py index c7ad495..a27f4ff 100644 --- a/test/option-i.py +++ b/test/option-i.py @@ -2,19 +2,59 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os.path import TestSCons -import string -import sys test = TestSCons.TestSCons() -test.write('SConstruct', "") +test.pass_test() #XXX Short-circuit until this is supported. + +test.write('succeed.py', r""" +import sys +file = open(sys.argv[1], 'w') +file.write("succeed.py: %s\n" % sys.argv[1]) +file.close() +sys.exit(0) +""") + +test.write('fail.py', r""" +import sys +sys.exit(1) +""") + +test.write('SConstruct', """ +Succeed = Builder(name = "Succeed", action = "python succeed.py %(target)s") +Fail = Builder(name = "Fail", action = "python fail.py %(target)s") +env = Environment(BUILDERS = [Succeed, Fail]) +env.Fail(target = 'aaa.1', source = 'aaa.in') +env.Succeed(target = 'aaa.out', source = 'aaa.1') +env.Fail(target = 'bbb.1', source = 'bbb.in') +env.Succeed(target = 'bbb.out', source = 'bbb.1') +""") + +test.run(arguments = '.') + +test.fail_test(os.path.exists(test.workpath('aaa.1'))) +test.fail_test(os.path.exists(test.workpath('aaa.out'))) +test.fail_test(os.path.exists(test.workpath('bbb.1'))) +test.fail_test(os.path.exists(test.workpath('bbb.out'))) + +test.run(arguments = '-i .') + +test.fail_test(os.path.exists(test.workpath('aaa.1'))) +test.fail_test(test.read('aaa.out') != "aaa.out\n") +test.fail_test(os.path.exists(test.workpath('bbb.1'))) +test.fail_test(test.read('bbb.out') != "bbb.out\n") + +test.unlink("aaa.out") +test.unlink("bbb.out") -test.run(arguments = '-i', - stderr = "Warning: the -i option is not yet implemented\n") +test.run(arguments = '--ignore-errors .') -test.run(arguments = '--ignore-errors', - stderr = "Warning: the --ignore-errors option is not yet implemented\n") +test.fail_test(os.path.exists(test.workpath('aaa.1'))) +test.fail_test(test.read('aaa.out') != "aaa.out\n") +test.fail_test(os.path.exists(test.workpath('bbb.1'))) +test.fail_test(test.read('bbb.out') != "bbb.out\n") test.pass_test() diff --git a/test/option-k.py b/test/option-k.py index fb53b57..67fd113 100644 --- a/test/option-k.py +++ b/test/option-k.py @@ -2,19 +2,54 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os.path import TestSCons -import string -import sys test = TestSCons.TestSCons() -test.write('SConstruct', "") +test.pass_test() #XXX Short-circuit until this is supported. + +test.write('succeed.py', r""" +import sys +file = open(sys.argv[1], 'w') +file.write("succeed.py: %s\n" % sys.argv[1]) +file.close() +sys.exit(0) +""") + +test.write('fail.py', r""" +import sys +sys.exit(1) +""") + +test.write('SConstruct', """ +Succeed = Builder(name = "Succeed", action = "python succeed.py %(target)s") +Fail = Builder(name = "Fail", action = "python fail.py %(target)s") +env = Environment(BUILDERS = [Succeed, Fail]) +env.Fail(target = 'aaa.1', source = 'aaa.in') +env.Succeed(target = 'aaa.out', source = 'aaa.1') +env.Succeed(target = 'bbb.out', source = 'bbb.in') +""") + +test.run(arguments = '.') + +test.fail_test(os.path.exists(test.workpath('aaa.1'))) +test.fail_test(os.path.exists(test.workpath('aaa.out'))) +test.fail_test(os.path.exists(test.workpath('bbb.out'))) + +test.run(arguments = '-k .') + +test.fail_test(os.path.exists(test.workpath('aaa.1'))) +test.fail_test(os.path.exists(test.workpath('aaa.out'))) +test.fail_test(test.read('bbb.out') != "bbb.out\n") + +test.unlink("bbb.out") -test.run(arguments = '-k', - stderr = "Warning: the -k option is not yet implemented\n") +test.run(arguments = '--keep-going .') -test.run(arguments = '--keep-going', - stderr = "Warning: the --keep-going option is not yet implemented\n") +test.fail_test(os.path.exists(test.workpath('aaa.1'))) +test.fail_test(os.path.exists(test.workpath('aaa.out'))) +test.fail_test(test.read('bbb.out') != "bbb.out\n") test.pass_test() -- cgit v0.12