diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CPPPATH.py | 37 | ||||
-rw-r--r-- | test/LIBPATH.py | 31 | ||||
-rw-r--r-- | test/Library.py | 11 |
3 files changed, 67 insertions, 12 deletions
diff --git a/test/CPPPATH.py b/test/CPPPATH.py index dec523d..32c00b6 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -28,11 +28,44 @@ import TestSCons test = TestSCons.TestSCons() -test.pass_test() #XXX Short-circuit until this is implemented. +test.write('foo.c', +"""#include "include/foo.h" +#include <stdio.h> + +int main(void) +{ + printf(TEST_STRING); + return 0; +} +""") + +test.subdir('include') + +test.write('include/foo.h', +""" +#define TEST_STRING "Bad news\n" +""") test.write('SConstruct', """ +env = Environment() +env.Program(target='prog', source='foo.c') +#env.Depends(target='foo.c', dependency='include/foo.h') """) -test.run(arguments = '.') +test.run(arguments = 'prog') + +test.run(program = test.workpath('prog'), + stdout = "Bad news\n") + +test.unlink('include/foo.h') +test.write('include/foo.h', +""" +#define TEST_STRING "Good news\n" +""") + +test.run(arguments = 'prog') + +test.run(program = test.workpath('prog'), + stdout = "Good news\n") test.pass_test() diff --git a/test/LIBPATH.py b/test/LIBPATH.py index dec523d..2efd236 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -28,11 +28,36 @@ import TestSCons test = TestSCons.TestSCons() -test.pass_test() #XXX Short-circuit until this is implemented. - test.write('SConstruct', """ +env = Environment(LIBS = [ 'foo1' ], + LIBPATH = [ './libs' ]) +env.Program(target = 'prog', source = 'prog.c') +env.Library(target = './libs/foo1', source = 'f1.c') +""") + +test.write('f1.c', """ +void +f1(void) +{ + printf("f1.c\n"); +} """) -test.run(arguments = '.') +test.write('prog.c', """ +void f1(void); +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + f1(); + printf("prog.c\n"); + return 0; +} +""") + +test.run(arguments = 'prog') + +test.run(program = test.workpath('prog'), + stdout = "f1.c\nprog.c\n") test.pass_test() diff --git a/test/Library.py b/test/Library.py index 3c50f3d..f5e9edb 100644 --- a/test/Library.py +++ b/test/Library.py @@ -28,16 +28,13 @@ import TestSCons test = TestSCons.TestSCons() -#XXX Need to switch TestBld to Program() when LIBS variable is working. test.write('SConstruct', """ -TestBld = Builder(name='TestBld', - action='cc -o $TARGET $SOURCES -L./ -lfoo1 -lfoo2 -lfoo3') -env = Environment(BUILDERS=[ TestBld, Library ]) +env = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ], + LIBPATH = [ './' ]) 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.TestBld(target = 'prog', source = 'prog.c') -env.Depends(target = 'prog', dependency = 'libfoo1.a libfoo2.a libfoo3.a') +env.Program(target = 'prog', source = 'prog.c') """) test.write('f1.c', """ @@ -119,7 +116,7 @@ main(int argc, char *argv[]) } """) -test.run(arguments = 'libfoo1.a libfoo2.a libfoo3.a prog') +test.run(arguments = 'prog') test.run(program = test.workpath('prog'), stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n") |