diff options
author | Steven Knight <knight@baldmt.com> | 2001-12-15 00:23:46 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-12-15 00:23:46 (GMT) |
commit | af3987ad4663708a4f9d10b661971fd7b29a9f0d (patch) | |
tree | 9de48645f9d229266078ede22a78fcd740f705b6 /test | |
parent | 0d14a2ff1774d42dc855aa9aab94791df3f55157 (diff) | |
download | SCons-af3987ad4663708a4f9d10b661971fd7b29a9f0d.zip SCons-af3987ad4663708a4f9d10b661971fd7b29a9f0d.tar.gz SCons-af3987ad4663708a4f9d10b661971fd7b29a9f0d.tar.bz2 |
Add BuildDir(), Export(), and Install() functionality (courtesy Charles Crain).
Diffstat (limited to 'test')
-rw-r--r-- | test/BuildDir.py | 111 | ||||
-rw-r--r-- | test/CPPPATH.py | 2 | ||||
-rw-r--r-- | test/Depends.py | 2 | ||||
-rw-r--r-- | test/Install.py | 96 | ||||
-rw-r--r-- | test/errors.py | 2 |
5 files changed, 210 insertions, 3 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py new file mode 100644 index 0000000..78d2afc --- /dev/null +++ b/test/BuildDir.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001 Steven Knight +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path +import sys +import time +import TestSCons + +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + +test = TestSCons.TestSCons() + +foo1 = test.workpath('build/var1/foo1' + _exe) +foo2 = test.workpath('build/var1/foo2' + _exe) +foo3 = test.workpath('build/var2/foo1' + _exe) +foo4 = test.workpath('build/var2/foo2' + _exe) + +test.write('SConstruct', """ +BuildDir('build/var1', 'src') +BuildDir('build/var2', 'src') +SConscript('build/var1/SConscript') +SConscript('build/var2/SConscript') +""") + +test.subdir('src') +test.write('src/SConscript', """ +import os +import os.path + +def buildIt(target, source, env): + if not os.path.exists('build'): + os.mkdir('build') + f1=open(source[0], 'r') + f2=open(target, 'w') + f2.write(f1.read()) + f2.close() + f1.close() + return 0 + +env = Environment() +env.Command(target='f2.c', source='f2.in', action=buildIt) +env.Program(target='foo2', source='f2.c') +env.Program(target='foo1', source='f1.c') +""") + +test.write('src/f1.c', r""" +#include "f1.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F1_STR); + exit (0); +} +""") + +test.write('src/f2.in', r""" +#include "f2.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F2_STR); + exit (0); +} +""") + +test.write('src/f1.h', """ +#define F1_STR "f1.c\n" +""") + +test.write('src/f2.h', """ +#define F2_STR "f2.c\n" +""") + +test.run(arguments = '.') + +test.run(program = foo1, stdout = "f1.c\n") +test.run(program = foo2, stdout = "f2.c\n") +test.run(program = foo3, stdout = "f1.c\n") +test.run(program = foo4, stdout = "f2.c\n") + +test.pass_test() diff --git a/test/CPPPATH.py b/test/CPPPATH.py index 52fbbfb..aa75019 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -46,7 +46,7 @@ test.write('SConstruct', """ env = Environment(CPPPATH = ['include']) obj = env.Object(target='prog', source='subdir/prog.c') env.Program(target='prog', source=obj) -SConscript('subdir/SConscript') +SConscript('subdir/SConscript', Export(env=env)) """) test.write(['subdir', 'SConscript'], """ diff --git a/test/Depends.py b/test/Depends.py index 822573a..ab045ae 100644 --- a/test/Depends.py +++ b/test/Depends.py @@ -52,7 +52,7 @@ env.Depends(target = 'f3.out', dependency = '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') +SConscript('subdir/SConscript', Export(env=env)) """ % (python, python)) test.write(['subdir', 'SConscript'], """ diff --git a/test/Install.py b/test/Install.py new file mode 100644 index 0000000..dce9990 --- /dev/null +++ b/test/Install.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001 Steven Knight +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path +import sys +import time +import TestSCons + +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + +test = TestSCons.TestSCons() + +foo1 = test.workpath('export/foo1' + _exe) +foo2 = test.workpath('export/foo2' + _exe) + +test.write('SConstruct', """ +env=Environment() +t=env.Program(target='foo1', source='f1.c') +env.Install(dir='export', source=t) +t=env.Program(target='foo2', source='f2.c') +env.Install(dir='export', source=t) +""") + +test.write('f1.c', """ +#include <stdio.h> + +int main(void) +{ + printf("f1.c\n"); + return 0; +} +""") + +test.write('f2.c', """ +#include <stdio.h> + +int main(void) +{ + printf("f2.c\n"); + return 0; +} +""") + +test.run(arguments = '.') + +test.run(program = foo1, stdout = "f1.c\n") +test.run(program = foo2, stdout = "f2.c\n") + +# make sure the programs didn't get rebuilt, because nothing changed: +oldtime1 = os.path.getmtime(foo1) +oldtime2 = os.path.getmtime(foo2) + +test.write('f1.c', """ +#include <stdio.h> + +int main(void) +{ + printf("f1.c again\n"); + return 0; +} +""") + +time.sleep(2) # introduce a small delay, to make the test valid + +test.run(arguments = '.') + +test.fail_test(oldtime1 == os.path.getmtime(foo1)) +test.fail_test(oldtime2 != os.path.getmtime(foo2)) + +test.pass_test() diff --git a/test/errors.py b/test/errors.py index abf2a28..5edd8f9 100644 --- a/test/errors.py +++ b/test/errors.py @@ -67,7 +67,7 @@ test.run(arguments='-f SConstruct3', File ".*Script.py", line \d+, in main _main\(\) File ".*Script.py", line \d+, in _main - exec file in globals\(\) + exec file in script_env File "SConstruct3", line \d+, in \? raise InternalError, 'error inside' InternalError: error inside |