diff options
Diffstat (limited to 'test/BuildDir')
-rw-r--r-- | test/BuildDir/BuildDir.py | 15 | ||||
-rw-r--r-- | test/BuildDir/Sconscript-build_dir.py | 6 | ||||
-rw-r--r-- | test/BuildDir/errors.py | 15 | ||||
-rw-r--r-- | test/BuildDir/nested-sconscripts.py | 64 | ||||
-rw-r--r-- | test/BuildDir/reflect.py | 28 |
5 files changed, 109 insertions, 19 deletions
diff --git a/test/BuildDir/BuildDir.py b/test/BuildDir/BuildDir.py index 0bae185..f655bf9 100644 --- a/test/BuildDir/BuildDir.py +++ b/test/BuildDir/BuildDir.py @@ -129,6 +129,9 @@ if fortran and env.Detect(fortran): """ % (fortran_runtime, fortran_runtime)) test.write(['work1', 'src', 'f1.c'], r""" +#include <stdio.h> +#include <stdlib.h> + #include "f1.h" int @@ -141,6 +144,9 @@ main(int argc, char *argv[]) """) test.write(['work1', 'src', 'f2.in'], r""" +#include <stdio.h> +#include <stdlib.h> + #include "f2.h" int @@ -153,6 +159,9 @@ main(int argc, char *argv[]) """) test.write(['work1', 'src', 'f3.c'], r""" +#include <stdio.h> +#include <stdlib.h> + #include "f3.h" int @@ -165,6 +174,9 @@ main(int argc, char *argv[]) """) test.write(['work1', 'src', 'f4.in'], r""" +#include <stdio.h> +#include <stdlib.h> + #include "f4.h" int @@ -325,6 +337,9 @@ env.Program('prog.c') """) test.write(['work2', 'prog.c'], r""" +#include <stdio.h> +#include <stdlib.h> + int main(int argc, char *argv[]) { diff --git a/test/BuildDir/Sconscript-build_dir.py b/test/BuildDir/Sconscript-build_dir.py index 298eb9b..685011d 100644 --- a/test/BuildDir/Sconscript-build_dir.py +++ b/test/BuildDir/Sconscript-build_dir.py @@ -212,6 +212,9 @@ env.Program('foo', [foo_obj, 'bar.c']) """) test.write(['test2', 'bar.c'], r""" +#include <stdio.h> +#include <stdlib.h> + void bar(void) { printf("bar.c\n"); @@ -219,6 +222,9 @@ bar(void) { """) test.write(['test2', 'foo.c'], r""" +#include <stdio.h> +#include <stdlib.h> + int main(int argc, char *argv[]) { bar(); diff --git a/test/BuildDir/errors.py b/test/BuildDir/errors.py index 285b996..4fcd625 100644 --- a/test/BuildDir/errors.py +++ b/test/BuildDir/errors.py @@ -155,17 +155,22 @@ f.close() # build directory results in an error message, rather # than just silently failing. test.subdir('duplicate', ['duplicate', 'src1'], ['duplicate', 'src2']) -test.write(['duplicate', 'SConstruct'], """\ + +duplicate_SConstruct_path = test.workpath('duplicate', 'SConstruct') + +test.write(duplicate_SConstruct_path, """\ BuildDir('build', 'src1') BuildDir('build', 'src2') """) +expect_stderr = """ +scons: *** 'build' already has a source directory: 'src1'. +File "%(duplicate_SConstruct_path)s", line 2, in ? +""" % locals() + test.run(chdir = 'duplicate', arguments = ".", status = 2, - stderr = """ -scons: *** 'build' already has a source directory: 'src1'. -File "SConstruct", line 2, in ? -""") + stderr = expect_stderr) test.pass_test() diff --git a/test/BuildDir/nested-sconscripts.py b/test/BuildDir/nested-sconscripts.py new file mode 100644 index 0000000..d9e110e --- /dev/null +++ b/test/BuildDir/nested-sconscripts.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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__" + +""" +Test that nested SConscript files in a BuildDir don't throw +an OSError exception looking for the wrong file. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir(['src'], + ['src', 'md'], + ['src', 'md', 'test']) + +test.write(['src', 'SConstruct'], """\ +BUILD_DIR = '../build' + +base_env = Environment() + +for flavor in ['prod', 'debug']: + build_env = base_env.Copy() + # In real life, we would modify build_env appropriately here + FLAVOR_DIR = BUILD_DIR + '/' + flavor + Export('build_env') + BuildDir(FLAVOR_DIR, 'md', duplicate=0) + SConscript(FLAVOR_DIR + '/SConscript') +""") + +test.write(['src', 'md', 'SConscript'], """\ +SConscript('test/SConscript') +""") + +test.write(['src', 'md', 'test', 'SConscript'], """\ +# empty +""") + +test.run(chdir='src') + +test.pass_test() diff --git a/test/BuildDir/reflect.py b/test/BuildDir/reflect.py index beb7df0..9a25029 100644 --- a/test/BuildDir/reflect.py +++ b/test/BuildDir/reflect.py @@ -39,8 +39,9 @@ import re import TestSCons test = TestSCons.TestSCons() -python = TestSCons.python -re_python = re.escape(python) + +_python_ = TestSCons._python_ +re_python = re.escape(TestSCons.python) test.write("mycc.py", """ print 'Compile' @@ -51,8 +52,8 @@ print 'Link' """) sconstruct = """ -env = Environment(CC = r'%(python)s mycc.py', - LINK = r'%(python)s mylink.py', +env = Environment(CC = r'%(_python_)s mycc.py', + LINK = r'%(_python_)s mylink.py', INCPREFIX = 'INC_', INCSUFFIX = '_CNI', CPPPATH='%(cpppath)s') # note no leading '#' @@ -86,17 +87,16 @@ test.write('SConstruct', sconstruct % locals() ) targets = re.escape(os.path.join('dir1', 'dir2')) INC_CNI = re.escape(os.path.join('INC_dir1', 'dir2', 'dir1', 'dir2_CNI')) -# The .* after mycc\\.py below handles /nologo flags from Visual C/C++. -test.run(arguments = '', - stdout=test.wrap_stdout("""\ +# The .+ after mycc\\.py below handles /nologo flags from Visual C/C++. +expect = test.wrap_stdout("""\ scons: building associated BuildDir targets: %(targets)s -%(re_python)s mycc\\.py.* %(INC_CNI)s .+ +"%(re_python)s" mycc\\.py.* %(INC_CNI)s .+ Compile -%(re_python)s mylink\\.py .+ +"%(re_python)s" mylink\\.py .+ Link -""" % locals()), - match=TestSCons.match_re, - ) +""" % locals()) + +test.run(arguments = '', match=TestSCons.match_re, stdout=expect) # Note that we don't check for the existence of dir1/dir2/foo.h, because # this bad cpppath will expand to dir1/dir2/dir1/dir2, which means it @@ -120,9 +120,9 @@ INC_CNI = re.escape(os.path.join('INC_dir1', 'dir2_CNI')) test.run(arguments = '', stdout=test.wrap_stdout("""\ scons: building associated BuildDir targets: %(targets)s -%(re_python)s mycc\\.py.* %(INC_CNI)s .+ +"%(re_python)s" mycc\\.py.* %(INC_CNI)s .+ Compile -%(re_python)s mylink\\.py .+ +"%(re_python)s" mylink\\.py .+ Link """ % locals()), match=TestSCons.match_re, |