diff options
Diffstat (limited to 'test/Deprecated')
-rw-r--r-- | test/Deprecated/BuildDir.py | 277 | ||||
-rw-r--r-- | test/Deprecated/CacheDir/timestamp-content.py | 62 | ||||
-rw-r--r-- | test/Deprecated/CacheDir/timestamp-timestamp.py | 62 | ||||
-rw-r--r-- | test/Deprecated/Copy.py | 52 | ||||
-rw-r--r-- | test/Deprecated/SConscript-build_dir.py | 274 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/basic.py | 130 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/env.py | 101 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/implicit-cache.py | 98 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/no-csigs.py | 73 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/overrides.py | 59 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/switch-rebuild.py | 88 | ||||
-rw-r--r-- | test/Deprecated/TargetSignatures/build-content.py | 131 | ||||
-rw-r--r-- | test/Deprecated/TargetSignatures/content.py | 83 | ||||
-rw-r--r-- | test/Deprecated/TargetSignatures/overrides.py | 54 | ||||
-rw-r--r-- | test/Deprecated/debug-dtree.py | 118 | ||||
-rw-r--r-- | test/Deprecated/debug-nomemoizer.py | 52 | ||||
-rw-r--r-- | test/Deprecated/debug-stree.py | 137 | ||||
-rw-r--r-- | test/Deprecated/debug-tree.py | 167 |
18 files changed, 2018 insertions, 0 deletions
diff --git a/test/Deprecated/BuildDir.py b/test/Deprecated/BuildDir.py new file mode 100644 index 0000000..709ea8b --- /dev/null +++ b/test/Deprecated/BuildDir.py @@ -0,0 +1,277 @@ +#!/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__" + +""" +Verify that the deprecated BuildDir() function and method still +work to create a variant directory tree (by calling VariantDir() +under the covers). + +Note that using BuildDir() does not yet print a deprecation warning. +""" + +import os.path +import string +import sys +import time +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +foo11 = test.workpath('work1', 'build', 'var1', 'foo1' + _exe) +foo12 = test.workpath('work1', 'build', 'var1', 'foo2' + _exe) +foo21 = test.workpath('work1', 'build', 'var2', 'foo1' + _exe) +foo22 = test.workpath('work1', 'build', 'var2', 'foo2' + _exe) +foo31 = test.workpath('work1', 'build', 'var3', 'foo1' + _exe) +foo32 = test.workpath('work1', 'build', 'var3', 'foo2' + _exe) +foo41 = test.workpath('work1', 'build', 'var4', 'foo1' + _exe) +foo42 = test.workpath('work1', 'build', 'var4', 'foo2' + _exe) +foo51 = test.workpath('build', 'var5', 'foo1' + _exe) +foo52 = test.workpath('build', 'var5', 'foo2' + _exe) + +test.subdir('work1') + +test.write(['work1', 'SConstruct'], """ +src = Dir('src') +var2 = Dir('build/var2') +var3 = Dir('build/var3') +var4 = Dir('build/var4') +var5 = Dir('../build/var5') +var6 = Dir('../build/var6') + +env = Environment(BUILD = 'build', SRC = 'src') + +VariantDir('build/var1', src) +VariantDir(var2, src) +VariantDir(var3, src, duplicate=0) +env.VariantDir("$BUILD/var4", "$SRC", duplicate=0) +VariantDir(var5, src, duplicate=0) +VariantDir(var6, src) + +env = Environment(CPPPATH='#src', FORTRANPATH='#src') +SConscript('build/var1/SConscript', "env") +SConscript('build/var2/SConscript', "env") + +env = Environment(CPPPATH=src, FORTRANPATH=src) +SConscript('build/var3/SConscript', "env") +SConscript(File('SConscript', var4), "env") + +env = Environment(CPPPATH='.', FORTRANPATH='.') +SConscript('../build/var5/SConscript', "env") +SConscript('../build/var6/SConscript', "env") +""") + +test.subdir(['work1', 'src']) +test.write(['work1', 'src', 'SConscript'], """ +import os +import os.path + +def buildIt(target, source, env): + if not os.path.exists('build'): + os.mkdir('build') + f1=open(str(source[0]), 'r') + f2=open(str(target[0]), 'w') + f2.write(f1.read()) + f2.close() + f1.close() + return 0 +Import("env") +env.Command(target='f2.c', source='f2.in', action=buildIt) +env.Program(target='foo2', source='f2.c') +env.Program(target='foo1', source='f1.c') +env.Command(target='f3.h', source='f3h.in', action=buildIt) +env.Command(target='f4.h', source='f4h.in', action=buildIt) +env.Command(target='f4.c', source='f4.in', action=buildIt) + +env2=env.Clone(CPPPATH='.') +env2.Program(target='foo3', source='f3.c') +env2.Program(target='foo4', source='f4.c') +""") + +test.write(['work1', 'src', 'f1.c'], r""" +#include <stdio.h> +#include <stdlib.h> + +#include "f1.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F1_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f2.in'], r""" +#include <stdio.h> +#include <stdlib.h> + +#include "f2.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F2_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f3.c'], r""" +#include <stdio.h> +#include <stdlib.h> + +#include "f3.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F3_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f4.in'], r""" +#include <stdio.h> +#include <stdlib.h> + +#include "f4.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F4_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f1.h'], r""" +#define F1_STR "f1.c\n" +""") + +test.write(['work1', 'src', 'f2.h'], r""" +#define F2_STR "f2.c\n" +""") + +test.write(['work1', 'src', 'f3h.in'], r""" +#define F3_STR "f3.c\n" +""") + +test.write(['work1', 'src', 'f4h.in'], r""" +#define F4_STR "f4.c\n" +""") + +# Some releases of freeBSD seem to have library complaints about +# tempnam(). Filter out these annoying messages before checking for +# error output. +def blank_output(err): + if not err: + return 1 + stderrlines = filter(lambda l: l, string.split(err, '\n')) + msg = "warning: tempnam() possibly used unsafely" + stderrlines = filter(lambda l, msg=msg: string.find(l, msg) == -1, + stderrlines) + return len(stderrlines) == 0 + +test.run(chdir='work1', arguments = '. ../build', stderr=None) + +test.fail_test(not blank_output(test.stderr())) + +test.run(program = foo11, stdout = "f1.c\n") +test.run(program = foo12, stdout = "f2.c\n") +test.run(program = foo41, stdout = "f1.c\n") +test.run(program = foo42, stdout = "f2.c\n") + +test.run(chdir='work1', arguments='. ../build', stdout=test.wrap_stdout("""\ +scons: `.' is up to date. +scons: `%s' is up to date. +""" % test.workpath('build'))) + +import os +import stat +def equal_stats(x,y): + x = os.stat(x) + y = os.stat(y) + return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and + x[stat.ST_MTIME] == y[stat.ST_MTIME]) + +# Make sure we did duplicate the source files in build/var2, +# and that their stats are the same: +test.must_exist(['work1', 'build', 'var2', 'f1.c']) +test.must_exist(['work1', 'build', 'var2', 'f2.in']) +test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f1.c'), test.workpath('work1', 'src', 'f1.c'))) +test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f2.in'), test.workpath('work1', 'src', 'f2.in'))) + +# Make sure we didn't duplicate the source files in build/var3. +test.must_not_exist(['work1', 'build', 'var3', 'f1.c']) +test.must_not_exist(['work1', 'build', 'var3', 'f2.in']) +test.must_not_exist(['work1', 'build', 'var3', 'b1.f']) +test.must_not_exist(['work1', 'build', 'var3', 'b2.in']) + +# Make sure we didn't duplicate the source files in build/var4. +test.must_not_exist(['work1', 'build', 'var4', 'f1.c']) +test.must_not_exist(['work1', 'build', 'var4', 'f2.in']) +test.must_not_exist(['work1', 'build', 'var4', 'b1.f']) +test.must_not_exist(['work1', 'build', 'var4', 'b2.in']) + +# Make sure we didn't duplicate the source files in build/var5. +test.must_not_exist(['build', 'var5', 'f1.c']) +test.must_not_exist(['build', 'var5', 'f2.in']) +test.must_not_exist(['build', 'var5', 'b1.f']) +test.must_not_exist(['build', 'var5', 'b2.in']) + +# verify that header files in the source directory are scanned properly: +test.write(['work1', 'src', 'f1.h'], r""" +#define F1_STR "f1.c 2\n" +""") + +test.write(['work1', 'src', 'f3h.in'], r""" +#define F3_STR "f3.c 2\n" +""") + +test.write(['work1', 'src', 'f4h.in'], r""" +#define F4_STR "f4.c 2\n" +""") + +test.run(chdir='work1', arguments = '../build/var5', stderr=None) + +test.fail_test(not blank_output(test.stderr())) + +test.run(program = foo51, stdout = "f1.c 2\n") +test.run(program = test.workpath('build', 'var5', 'foo3' + _exe), + stdout = "f3.c 2\n") +test.run(program = test.workpath('build', 'var5', 'foo4' + _exe), + stdout = "f4.c 2\n") + +test.run(chdir='work1', arguments='../build/var5', stdout=test.wrap_stdout("""\ +scons: `%s' is up to date. +""" % test.workpath('build', 'var5'))) + +test.pass_test() diff --git a/test/Deprecated/CacheDir/timestamp-content.py b/test/Deprecated/CacheDir/timestamp-content.py new file mode 100644 index 0000000..850c369 --- /dev/null +++ b/test/Deprecated/CacheDir/timestamp-content.py @@ -0,0 +1,62 @@ +#!/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__" + +""" +Verify that CacheDir() works when using SourceSignatures('timestamp') +and TargetSignatures 'content'. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +SetOption('warn', 'no-deprecated') +SourceSignatures('timestamp') +TargetSignatures('content') +CacheDir('cache') +Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) +""") + +test.write('file.in', "file.in\n") + +test.run(arguments = '.') + +test.must_match('file.out', "file.in\n") + +test.up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.sleep() + +test.touch('file.in') + +test.not_up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.pass_test() diff --git a/test/Deprecated/CacheDir/timestamp-timestamp.py b/test/Deprecated/CacheDir/timestamp-timestamp.py new file mode 100644 index 0000000..73dce09 --- /dev/null +++ b/test/Deprecated/CacheDir/timestamp-timestamp.py @@ -0,0 +1,62 @@ +#!/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__" + +""" +Verify that CacheDir() works when using both SourceSignatures() +and TargetSignatures values of 'timestamp'. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write(['SConstruct'], """\ +SetOption('warn', 'no-deprecated') +SourceSignatures('timestamp') +TargetSignatures('timestamp') +CacheDir('cache') +Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) +""") + +test.write('file.in', "file.in\n") + +test.run(arguments = '--cache-show --debug=explain .') + +test.must_match('file.out', "file.in\n") + +test.up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.sleep() + +test.touch('file.in') + +test.not_up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.up_to_date(options = '--cache-show --debug=explain', arguments = '.') + +test.pass_test() diff --git a/test/Deprecated/Copy.py b/test/Deprecated/Copy.py new file mode 100644 index 0000000..f17fc9f --- /dev/null +++ b/test/Deprecated/Copy.py @@ -0,0 +1,52 @@ +#!/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__" + +""" +Verify the message about the deprecated env.Copy() message, and the +ability to suppress it. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """ +env = Environment().Copy() +env.Copy() +""") + +expect = """ +scons: warning: The env.Copy() method is deprecated; use the env.Clone() method instead. +""" + +test.run(arguments = '.', + stderr = TestSCons.re_escape(expect) + TestSCons.file_expr) + +test.run(arguments = '--warn=no-deprecated .') + +test.run(arguments = '--warn=no-deprecated-copy .') + +test.pass_test() diff --git a/test/Deprecated/SConscript-build_dir.py b/test/Deprecated/SConscript-build_dir.py new file mode 100644 index 0000000..1e623af --- /dev/null +++ b/test/Deprecated/SConscript-build_dir.py @@ -0,0 +1,274 @@ +#!/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__" + +""" +Verify that specifying a build_dir argument to SConscript still works. + +Note that the build_dir argument does not yet print a deprecation warning. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +all1 = test.workpath('test', 'build', 'var1', 'all') +all2 = test.workpath('test', 'build', 'var2', 'all') +all3 = test.workpath('test', 'build', 'var3', 'all') +all4 = test.workpath('test', 'build', 'var4', 'all') +all5 = test.workpath('build', 'var5', 'all') +all6 = test.workpath('build', 'var6', 'all') +all7 = test.workpath('build', 'var7', 'all') +all8 = test.workpath('build', 'var8', 'all') +all9 = test.workpath('test', 'build', 'var9', 'src', 'all') + +test.subdir('test') + +test.write(['test', 'SConstruct'], """ +src = Dir('src') +alt = Dir('alt') +var1 = Dir('build/var1') +var2 = Dir('build/var2') +var3 = Dir('build/var3') +var4 = Dir('build/var4') +var5 = Dir('../build/var5') +var6 = Dir('../build/var6') +var7 = Dir('../build/var7') +var8 = Dir('../build/var8') +var9 = Dir('../build/var9') + +def cat(env, source, target): + target = str(target[0]) + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() + +env = Environment(BUILDERS={'Cat':Builder(action=cat)}, + BUILD='build') + +Export("env") + +SConscript('src/SConscript', build_dir=var1) +SConscript('src/SConscript', build_dir='build/var2', src_dir=src) + +SConscript('src/SConscript', build_dir='build/var3', duplicate=0) + +#XXX We can't support var4 and var5 yet, because our VariantDir linkage +#XXX is to an entire source directory. We haven't yet generalized our +#XXX infrastructure to be able to take the SConscript file from one source +#XXX directory, but the rest of the files from a different one. +#XXX SConscript('src/SConscript', build_dir=var4, src_dir=alt, duplicate=0) + +#XXX SConscript('src/SConscript', build_dir='../build/var5', src_dir='alt') +SConscript('src/SConscript', build_dir=var6) + +SConscript('src/SConscript', build_dir=var7, src_dir=src, duplicate=0) +env.SConscript('src/SConscript', build_dir='../$BUILD/var8', duplicate=0) + +# This tests the fact that if you specify a src_dir that is above +# the dir a SConscript is in, that we do the intuitive thing, i.e., +# we set the path of the SConscript accordingly. The below is +# equivalent to saying: +# +# VariantDir('build/var9', '.') +# SConscript('build/var9/src/SConscript') +SConscript('src/SConscript', build_dir='build/var9', src_dir='.') +""") + +test.subdir(['test', 'src'], ['test', 'alt']) + +test.write(['test', 'src', 'SConscript'], """ +Import("env") +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +""") + +test.write('test/src/aaa.in', "test/src/aaa.in\n") +test.write('test/src/bbb.in', "test/src/bbb.in\n") +test.write('test/src/ccc.in', "test/src/ccc.in\n") + +test.write('test/alt/aaa.in', "test/alt/aaa.in\n") +test.write('test/alt/bbb.in', "test/alt/bbb.in\n") +test.write('test/alt/ccc.in', "test/alt/ccc.in\n") + +test.run(chdir='test', arguments = '. ../build') + +all_src = "test/src/aaa.in\ntest/src/bbb.in\ntest/src/ccc.in\n" +all_alt = "test/alt/aaa.in\ntest/alt/bbb.in\ntest/alt/ccc.in\n" + +test.must_match(all1, all_src) +test.must_match(all2, all_src) +test.must_match(all3, all_src) +#XXX We can't support var4 and var5 yet, because our VariantDir linkage +#XXX is to an entire source directory. We haven't yet generalized our +#XXX infrastructure to be able to take the SConscript file from one source +#XXX directory, but the rest of the files from a different one. +#XXX test.must_match(all4, all_alt) +#XXX test.must_match(all5, all_alt) +test.must_match(all6, all_src) +test.must_match(all7, all_src) +test.must_match(all8, all_src) +test.must_match(all9, all_src) + +import os +import stat +def equal_stats(x,y): + x = os.stat(x) + y = os.stat(y) + return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and + x[stat.ST_MTIME] == y[stat.ST_MTIME]) + +# Make sure we did duplicate the source files in build/var1, +# and that their stats are the same: +for file in ['aaa.in', 'bbb.in', 'ccc.in']: + test.must_exist(test.workpath('test', 'build', 'var1', file)) + test.fail_test(not equal_stats(test.workpath('test', 'build', 'var1', file), + test.workpath('test', 'src', file))) + +# Make sure we did duplicate the source files in build/var2, +# and that their stats are the same: +for file in ['aaa.in', 'bbb.in', 'ccc.in']: + test.must_exist(test.workpath('test', 'build', 'var2', file)) + test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', file), + test.workpath('test', 'src', file))) + +# Make sure we didn't duplicate the source files in build/var3. +test.must_not_exist(test.workpath('test', 'build', 'var3', 'aaa.in')) +test.must_not_exist(test.workpath('test', 'build', 'var3', 'bbb.in')) +test.must_not_exist(test.workpath('test', 'build', 'var3', 'ccc.in')) + +#XXX We can't support var4 and var5 yet, because our VariantDir linkage +#XXX is to an entire source directory. We haven't yet generalized our +#XXX infrastructure to be able to take the SConscript file from one source +#XXX directory, but the rest of the files from a different one. +#XXX Make sure we didn't duplicate the source files in build/var4. +#XXXtest.must_not_exist(test.workpath('test', 'build', 'var4', 'aaa.in')) +#XXXtest.must_not_exist(test.workpath('test', 'build', 'var4', 'bbb.in')) +#XXXtest.must_not_exist(test.workpath('test', 'build', 'var4', 'ccc.in')) + +#XXX We can't support var4 and var5 yet, because our VariantDir linkage +#XXX is to an entire source directory. We haven't yet generalized our +#XXX infrastructure to be able to take the SConscript file from one source +#XXX directory, but the rest of the files from a different one. +#XXX Make sure we did duplicate the source files in build/var5, +#XXX and that their stats are the same: +#XXXfor file in ['aaa.in', 'bbb.in', 'ccc.in']: +#XXX test.must_exist(test.workpath('build', 'var5', file)) +#XXX test.fail_test(not equal_stats(test.workpath('build', 'var5', file), +#XXX test.workpath('test', 'src', file))) + +# Make sure we did duplicate the source files in build/var6, +# and that their stats are the same: +for file in ['aaa.in', 'bbb.in', 'ccc.in']: + test.must_exist(test.workpath('build', 'var6', file)) + test.fail_test(not equal_stats(test.workpath('build', 'var6', file), + test.workpath('test', 'src', file))) + +# Make sure we didn't duplicate the source files in build/var7. +test.must_not_exist(test.workpath('build', 'var7', 'aaa.in')) +test.must_not_exist(test.workpath('build', 'var7', 'bbb.in')) +test.must_not_exist(test.workpath('build', 'var7', 'ccc.in')) + +# Make sure we didn't duplicate the source files in build/var8. +test.must_not_exist(test.workpath('build', 'var8', 'aaa.in')) +test.must_not_exist(test.workpath('build', 'var8', 'bbb.in')) +test.must_not_exist(test.workpath('build', 'var8', 'ccc.in')) + +################### +test.subdir('test2') + +test.write(['test2', 'SConstruct'], """\ +SConscript('SConscript', build_dir='Build', src_dir='.', duplicate=0) +""") + +test.write(['test2', 'SConscript'], """\ +env = Environment() +foo_obj = env.Object('foo.c') +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"); +} +""") + +test.write(['test2', 'foo.c'], r""" +#include <stdio.h> +#include <stdlib.h> + +extern void +bar(void); + +int +main(int argc, char *argv[]) { + bar(); + printf("foo.c\n"); +} +""") + +test.run(chdir="test2") + +_obj = TestSCons._obj + +test.must_not_exist(test.workpath('test2', 'foo' + _obj)) +test.must_not_exist(test.workpath('test2', 'bar' + _obj)) +test.must_exist(test.workpath('test2', 'Build', 'foo' + _obj)) +test.must_exist(test.workpath('test2', 'Build', 'bar' + _obj)) + +################### +# Make sure that directories for subsidiary SConscript() calls +# in a build_dir get created if they don't already exist. +test.subdir('test3') + +test.subdir(['test3', 'src'], ['test3', 'src', '_glscry']) + +test.write(['test3', 'SConstruct'], """\ +SConscript(dirs=['src'], build_dir='build', duplicate=0) +""") + +test.write(['test3', 'src', 'SConscript'], """\ +SConscript(dirs=['_glscry']) +""") + +test.write(['test3', 'src', '_glscry', 'SConscript'], """\ +""") + +test.write(['test3', 'src', 'file.in'], "file.in\n") + +test.write(['test3', 'src', '_glscry', 'file.in'], "file.in\n") + +test.run(chdir='test3') + + +test.pass_test() diff --git a/test/Deprecated/SourceSignatures/basic.py b/test/Deprecated/SourceSignatures/basic.py new file mode 100644 index 0000000..5012296 --- /dev/null +++ b/test/Deprecated/SourceSignatures/basic.py @@ -0,0 +1,130 @@ +#!/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__" + +import os +import os.path +import re + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + + +base_sconstruct_contents = """\ +SetOption('warn', 'no-deprecated-source-signatures') +def build(env, target, source): + open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read()) +B = Builder(action = build) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'f1.out', source = 'f1.in') +env.B(target = 'f2.out', source = 'f2.in') +env.B(target = 'f3.out', source = 'f3.in') +env.B(target = 'f4.out', source = 'f4.in') +""" + +def write_SConstruct(test, sigtype): + contents = base_sconstruct_contents + if sigtype: + contents = contents + ("\nSourceSignatures('%s')\n" % sigtype) + test.write('SConstruct', contents) + + + +write_SConstruct(test, 'timestamp') + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") +test.write('f4.in', "f4.in\n") + +test.run(arguments = 'f1.out f3.out', + stderr = TestSCons.deprecated_python_expr) + +test.run(arguments = 'f1.out f2.out f3.out f4.out', + stdout = re.escape(test.wrap_stdout("""\ +scons: `f1.out' is up to date. +build(["f2.out"], ["f2.in"]) +scons: `f3.out' is up to date. +build(["f4.out"], ["f4.in"]) +""")), + stderr = TestSCons.deprecated_python_expr) + + + +os.utime(test.workpath('f1.in'), + (os.path.getatime(test.workpath('f1.in')), + os.path.getmtime(test.workpath('f1.in'))+10)) +os.utime(test.workpath('f3.in'), + (os.path.getatime(test.workpath('f3.in')), + os.path.getmtime(test.workpath('f3.in'))+10)) + +test.run(arguments = 'f1.out f2.out f3.out f4.out', + stdout = re.escape(test.wrap_stdout("""\ +build(["f1.out"], ["f1.in"]) +scons: `f2.out' is up to date. +build(["f3.out"], ["f3.in"]) +scons: `f4.out' is up to date. +""")), + stderr = TestSCons.deprecated_python_expr) + + + +# Switching to content signatures from timestamps should rebuild, +# because we didn't record the content signatures last time. + +write_SConstruct(test, 'MD5') + +test.not_up_to_date(arguments = 'f1.out f2.out f3.out f4.out', + stderr = TestSCons.deprecated_python_expr) + + + +test.sleep() + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") +test.write('f4.in', "f4.in\n") + +test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None) + + + +test.touch('f1.in', os.path.getmtime(test.workpath('f1.in'))+10) +test.touch('f3.in', os.path.getmtime(test.workpath('f3.in'))+10) + +test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None) + + + +write_SConstruct(test, None) + +test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None) + + + +test.pass_test() diff --git a/test/Deprecated/SourceSignatures/env.py b/test/Deprecated/SourceSignatures/env.py new file mode 100644 index 0000000..ec6d3d2 --- /dev/null +++ b/test/Deprecated/SourceSignatures/env.py @@ -0,0 +1,101 @@ +#!/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 use of env.SourceSignatures() correctly overrides the +default behavior. +""" + +import os +import os.path +import re + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +base_sconstruct_contents = """\ +SetOption('warn', 'no-deprecated-source-signatures') +def build(env, target, source): + open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read()) +B = Builder(action = build) +env = Environment(BUILDERS = { 'B' : B }) +env2 = env.Clone() +env2.SourceSignatures('%s') +env.B(target = 'f1.out', source = 'f1.in') +env.B(target = 'f2.out', source = 'f2.in') +env2.B(target = 'f3.out', source = 'f3.in') +env2.B(target = 'f4.out', source = 'f4.in') + +SourceSignatures('%s') +""" + +def write_SConstruct(test, env_sigtype, default_sigtype): + contents = base_sconstruct_contents % (env_sigtype, default_sigtype) + test.write('SConstruct', contents) + + + +write_SConstruct(test, 'MD5', 'timestamp') + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") +test.write('f4.in', "f4.in\n") + +test.run(arguments = 'f1.out f3.out', + stderr = TestSCons.deprecated_python_expr) + +test.run(arguments = 'f1.out f2.out f3.out f4.out', + stdout = re.escape(test.wrap_stdout("""\ +scons: `f1.out' is up to date. +build(["f2.out"], ["f2.in"]) +scons: `f3.out' is up to date. +build(["f4.out"], ["f4.in"]) +""")), + stderr = TestSCons.deprecated_python_expr) + + + +test.sleep() + +test.touch('f1.in') +test.touch('f3.in') + +test.run(arguments = 'f1.out f2.out f3.out f4.out', + stdout = re.escape(test.wrap_stdout("""\ +build(["f1.out"], ["f1.in"]) +scons: `f2.out' is up to date. +scons: `f3.out' is up to date. +scons: `f4.out' is up to date. +""")), + stderr = TestSCons.deprecated_python_expr) + +test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None) + + + +test.pass_test() diff --git a/test/Deprecated/SourceSignatures/implicit-cache.py b/test/Deprecated/SourceSignatures/implicit-cache.py new file mode 100644 index 0000000..44c30ce --- /dev/null +++ b/test/Deprecated/SourceSignatures/implicit-cache.py @@ -0,0 +1,98 @@ +#!/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 the simultaneous use of implicit_cache and +SourceSignatures('timestamp') +""" + +import re + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +SetOption('warn', 'no-deprecated-source-signatures') +SetOption('implicit_cache', 1) +SourceSignatures('timestamp') + +def build(env, target, source): + open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read()) +B = Builder(action = build) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'both.out', source = 'both.in') +""") + +both_out_both_in = re.escape(test.wrap_stdout('build(["both.out"], ["both.in"])\n')) + + + +test.write('both.in', "both.in 1\n") + +test.run(arguments = 'both.out', + stdout = both_out_both_in, + stderr = TestSCons.deprecated_python_expr) + + + +test.sleep(2) + +test.write('both.in', "both.in 2\n") + +test.run(arguments = 'both.out', + stdout = both_out_both_in, + stderr = TestSCons.deprecated_python_expr) + + + +test.sleep(2) + +test.write('both.in', "both.in 3\n") + +test.run(arguments = 'both.out', + stdout = both_out_both_in, + stderr = TestSCons.deprecated_python_expr) + + + +test.sleep(2) + +test.write('both.in', "both.in 4\n") + +test.run(arguments = 'both.out', + stdout = both_out_both_in, + stderr = TestSCons.deprecated_python_expr) + + + +test.sleep(2) + +test.up_to_date(arguments = 'both.out', stderr = None) + + + +test.pass_test() diff --git a/test/Deprecated/SourceSignatures/no-csigs.py b/test/Deprecated/SourceSignatures/no-csigs.py new file mode 100644 index 0000000..01d05da --- /dev/null +++ b/test/Deprecated/SourceSignatures/no-csigs.py @@ -0,0 +1,73 @@ + +#!/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__" + +import os +import os.path + +import TestSCons +import TestSConsign + +test = TestSConsign.TestSConsign(match = TestSConsign.match_re) + + +test.write('SConstruct', """\ +SetOption('warn', 'no-deprecated-source-signatures') +def build(env, target, source): + open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read()) +B = Builder(action = build) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'f1.out', source = 'f1.in') +env.B(target = 'f2.out', source = 'f2.in') +SourceSignatures('timestamp') +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") + +test.run(arguments = '.', + stderr = TestSCons.deprecated_python_expr) + + + +expect = r"""=== .: +SConstruct: None \d+ \d+ +f1.in: None \d+ \d+ +f1.out: \S+ \d+ \d+ + f1.in: None \d+ \d+ + \S+ \[build\(target, source, env\)\] +f2.in: None \d+ \d+ +f2.out: \S+ \d+ \d+ + f2.in: None \d+ \d+ + \S+ \[build\(target, source, env\)\] +""" + +test.run_sconsign(arguments = test.workpath('.sconsign'), + stdout = expect) + + + +test.pass_test() diff --git a/test/Deprecated/SourceSignatures/overrides.py b/test/Deprecated/SourceSignatures/overrides.py new file mode 100644 index 0000000..de1cc95 --- /dev/null +++ b/test/Deprecated/SourceSignatures/overrides.py @@ -0,0 +1,59 @@ +#!/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__" + +""" +Make sure that SourceSignatures() works when overrides are used on a +Builder call. (Previous implementations used methods that would stay +bound to the underlying construction environment, which in this case +meant ignoring the 'timestamp' setting and still using the underlying +content signature.) +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +SetOption('warn', 'no-deprecated-source-signatures') +DefaultEnvironment().SourceSignatures('MD5') +env = Environment() +env.SourceSignatures('timestamp') +env.Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE'), FOO=1) +""") + +test.write('foo.in', "foo.in 1\n") + +test.run(arguments = 'foo.out', + stderr = TestSCons.deprecated_python_expr) + +test.sleep() + +test.write('foo.in', "foo.in 1\n") + +test.not_up_to_date(arguments = 'foo.out', + stderr = TestSCons.deprecated_python_expr) + +test.pass_test() diff --git a/test/Deprecated/SourceSignatures/switch-rebuild.py b/test/Deprecated/SourceSignatures/switch-rebuild.py new file mode 100644 index 0000000..07b59fb --- /dev/null +++ b/test/Deprecated/SourceSignatures/switch-rebuild.py @@ -0,0 +1,88 @@ +#!/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 switching SourceSignature() types no longer causes rebuilds. +""" + +import re + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + +base_sconstruct_contents = """\ +SetOption('warn', 'no-deprecated-source-signatures') +SourceSignatures('%s') + +def build(env, target, source): + open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read()) +B = Builder(action = build) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'switch.out', source = 'switch.in') +""" + +def write_SConstruct(test, sig_type): + contents = base_sconstruct_contents % sig_type + test.write('SConstruct', contents) + + +write_SConstruct(test, 'MD5') + +test.write('switch.in', "switch.in\n") + +switch_out_switch_in = re.escape(test.wrap_stdout('build(["switch.out"], ["switch.in"])\n')) + +test.run(arguments = 'switch.out', + stdout = switch_out_switch_in, + stderr = TestSCons.deprecated_python_expr) + +test.up_to_date(arguments = 'switch.out', stderr = None) + + + +write_SConstruct(test, 'timestamp') + +test.up_to_date(arguments = 'switch.out', stderr = None) + + + +write_SConstruct(test, 'MD5') + +test.not_up_to_date(arguments = 'switch.out', stderr = None) + + + +test.write('switch.in', "switch.in 2\n") + +test.run(arguments = 'switch.out', + stdout = switch_out_switch_in, + stderr = TestSCons.deprecated_python_expr) + + + +test.pass_test() diff --git a/test/Deprecated/TargetSignatures/build-content.py b/test/Deprecated/TargetSignatures/build-content.py new file mode 100644 index 0000000..6fd031e --- /dev/null +++ b/test/Deprecated/TargetSignatures/build-content.py @@ -0,0 +1,131 @@ +#!/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__" + +""" +Verify basic interaction of the historic TargetSignatures('build') +and TargetSignatures('content') settings, overriding one with +the other in specific construction environments. +""" + +import re + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + + +sconstruct_contents = """\ +SetOption('warn', 'no-deprecated-target-signatures') +env = Environment() + +def copy1(env, source, target): + open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read()) + +def copy2(env, source, target): + %s + return copy1(env, source, target) + +env['BUILDERS']['Copy1'] = Builder(action=copy1) +env['BUILDERS']['Copy2'] = Builder(action=copy2) + +env.Copy2('foo.mid', 'foo.in') +env.Copy1('foo.out', 'foo.mid') + +env2 = env.Clone() +env2.TargetSignatures('%s') +env2.Copy2('bar.mid', 'bar.in') +env2.Copy1('bar.out', 'bar.mid') + +TargetSignatures('%s') +""" + +def write_SConstruct(test, *args): + contents = sconstruct_contents % args + test.write('SConstruct', contents) + + + +write_SConstruct(test, '', 'build', 'content') + +test.write('foo.in', 'foo.in') +test.write('bar.in', 'bar.in') + +test.run(arguments="bar.out foo.out", + stdout=re.escape(test.wrap_stdout("""\ +copy2(["bar.mid"], ["bar.in"]) +copy1(["bar.out"], ["bar.mid"]) +copy2(["foo.mid"], ["foo.in"]) +copy1(["foo.out"], ["foo.mid"]) +""")), + stderr = TestSCons.deprecated_python_expr) + +test.up_to_date(arguments='bar.out foo.out', stderr=None) + + + +# Change the code in the the copy2() function, which should change +# its content and trigger a rebuild of the targets built with it. + +write_SConstruct(test, 'x = 2 # added this line', 'build', 'content') + +test.run(arguments="bar.out foo.out", + stdout=re.escape(test.wrap_stdout("""\ +copy2(["bar.mid"], ["bar.in"]) +copy1(["bar.out"], ["bar.mid"]) +copy2(["foo.mid"], ["foo.in"]) +scons: `foo.out' is up to date. +""")), + stderr = TestSCons.deprecated_python_expr) + + + +# Swapping content and build signatures no longer causes a rebuild +# because we record the right underlying information regardless. + +write_SConstruct(test, 'x = 2 # added this line', 'content', 'build') + +test.up_to_date(arguments="bar.out foo.out", stderr=None) + + + +# Change the code in the the copy2() function back again, which should +# trigger another rebuild of the targets built with it. + +write_SConstruct(test, '', 'content', 'build') + +test.run(arguments='bar.out foo.out', + stdout=re.escape(test.wrap_stdout("""\ +copy2(["bar.mid"], ["bar.in"]) +scons: `bar.out' is up to date. +copy2(["foo.mid"], ["foo.in"]) +copy1(["foo.out"], ["foo.mid"]) +""")), + stderr = TestSCons.deprecated_python_expr) + + + +test.pass_test() diff --git a/test/Deprecated/TargetSignatures/content.py b/test/Deprecated/TargetSignatures/content.py new file mode 100644 index 0000000..4de1422 --- /dev/null +++ b/test/Deprecated/TargetSignatures/content.py @@ -0,0 +1,83 @@ +#!/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__" + +""" +Verify use of the TargetSignatures('content') setting to override +SourceSignatures('timestamp') settings. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + + +test.write('SConstruct', """\ +SetOption('warn', 'no-deprecated-source-signatures') +SetOption('warn', 'no-deprecated-target-signatures') +env = Environment() + +def copy(env, source, target): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +copyAction = Action(copy, "Copying $TARGET") + +SourceSignatures('timestamp') + +env['BUILDERS']['Copy'] = Builder(action=copyAction) + +env.Copy('foo.out', 'foo.in') + +env2 = env.Clone() +env2.TargetSignatures('content') +env2.Copy('bar.out', 'bar.in') +AlwaysBuild('bar.out') + +env.Copy('final', ['foo.out', 'bar.out', 'extra.in']) +env.Ignore('final', 'extra.in') +""") + +test.write('foo.in', "foo.in\n") +test.write('bar.in', "bar.in\n") +test.write('extra.in', "extra.in 1\n") + +test.run(stderr = TestSCons.deprecated_python_expr) + +test.must_match('final', "foo.in\nbar.in\nextra.in 1\n") + +test.sleep() +test.write('extra.in', "extra.in 2\n") + +test.run(stderr = TestSCons.deprecated_python_expr) + +test.must_match('final', "foo.in\nbar.in\nextra.in 1\n") + + + +test.pass_test() diff --git a/test/Deprecated/TargetSignatures/overrides.py b/test/Deprecated/TargetSignatures/overrides.py new file mode 100644 index 0000000..327218e --- /dev/null +++ b/test/Deprecated/TargetSignatures/overrides.py @@ -0,0 +1,54 @@ +#!/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__" + +""" +Make sure that TargetSignatures() works when overrides are used on a +Builder call. Previous implementations used methods that would stay +bound to the underlying construction environment and cause weird +behavior like infinite recursion. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +SetOption('warn', 'no-deprecated-target-signatures') +env = Environment() +env.TargetSignatures('content') +env.Command('foo.out', 'foo.mid', Copy('$TARGET', '$SOURCE'), FOO=1) +env.Command('foo.mid', 'foo.in', Copy('$TARGET', '$SOURCE'), FOO=2) +""") + +test.write('foo.in', "foo.in\n") + +test.run(arguments = '.', + stderr = TestSCons.deprecated_python_expr) + +test.must_match('foo.mid', "foo.in\n") +test.must_match('foo.out', "foo.in\n") + +test.pass_test() diff --git a/test/Deprecated/debug-dtree.py b/test/Deprecated/debug-dtree.py new file mode 100644 index 0000000..2aec880 --- /dev/null +++ b/test/Deprecated/debug-dtree.py @@ -0,0 +1,118 @@ +#!/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 the --debug=dtree option correctly prints just the explicit +dependencies (sources or Depends()) of a target. +""" + +import TestSCons +import sys +import string +import re +import time + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """ +env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx') +env.Program('foo', Split('foo.c bar.c')) +""") + +test.write('foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +#include "foo.h" +int main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f1.c\n"); + exit (0); +} +""") + +test.write('bar.c', """ +#include "bar.h" +int local = 1; +""") + +test.write('foo.h', """ +#ifndef FOO_H +#define FOO_H +#include "bar.h" +#endif +""") + +test.write('bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "foo.h" +#endif +""") + +expect = """ +scons: warning: The --debug=dtree option is deprecated; please use --tree=derived instead. +""" + +stderr = TestSCons.re_escape(expect) + TestSCons.file_expr + +dtree1 = """ ++-foo.xxx + +-foo.ooo + +-bar.ooo +""" + +test.run(arguments = "--debug=dtree foo.xxx", + stderr = stderr) +test.fail_test(string.find(test.stdout(), dtree1) == -1) + +dtree2 = """ ++-. + +-bar.ooo + +-foo.ooo + +-foo.xxx + +-foo.ooo + +-bar.ooo +""" +test.run(arguments = "--debug=dtree .", + stderr = stderr) +test.fail_test(string.find(test.stdout(), dtree2) == -1) + +# Make sure we print the debug stuff even if there's a build failure. +test.write('bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "foo.h" +#endif +THIS SHOULD CAUSE A BUILD FAILURE +""") + +test.run(arguments = "--debug=dtree foo.xxx", + status = 2, + stderr = None) +test.fail_test(string.find(test.stdout(), dtree1) == -1) + +test.pass_test() diff --git a/test/Deprecated/debug-nomemoizer.py b/test/Deprecated/debug-nomemoizer.py new file mode 100644 index 0000000..3a927e5 --- /dev/null +++ b/test/Deprecated/debug-nomemoizer.py @@ -0,0 +1,52 @@ +#!/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 calling the (deprecated) --debug=nomemoizer option. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re) + +test.write('SConstruct', """ +def cat(target, source, env): + open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read()) +env = Environment(BUILDERS={'Cat':Builder(action=Action(cat))}) +env.Cat('file.out', 'file.in') +""") + +test.write('file.in', "file.in\n") + +expect = """ +scons: warning: The --debug=nomemoizer option is deprecated and has no effect. +""" + TestSCons.file_expr + +test.run(arguments = "--debug=nomemoizer", stderr = expect) + +test.must_match('file.out', "file.in\n") + +test.pass_test() diff --git a/test/Deprecated/debug-stree.py b/test/Deprecated/debug-stree.py new file mode 100644 index 0000000..8907c6c --- /dev/null +++ b/test/Deprecated/debug-stree.py @@ -0,0 +1,137 @@ +#!/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 the --debug=stree option prints a dependency tree with output +that indicates the state of various Node status flags. +""" + +import TestSCons +import sys +import string +import re +import time + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +CC = test.detect('CC') +LINK = test.detect('LINK') +if LINK is None: LINK = CC + +test.write('SConstruct', """ +env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx') +env.Program('foo', Split('foo.c bar.c')) +""") + +test.write('foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +#include "foo.h" +int main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f1.c\n"); + exit (0); +} +""") + +test.write('bar.c', """ +#include "bar.h" +int local = 1; +""") + +test.write('foo.h', """ +#ifndef FOO_H +#define FOO_H +#include "bar.h" +#endif +""") + +test.write('bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "foo.h" +#endif +""") + +expect = """ +scons: warning: The --debug=stree option is deprecated; please use --tree=all,status instead. +""" + +stderr = TestSCons.re_escape(expect) + TestSCons.file_expr + +stree = """ +[E B C ]+-foo.xxx +[E B C ] +-foo.ooo +[E C ] | +-foo.c +[E C ] | +-foo.h +[E C ] | +-bar.h +[E C ] | +-%(CC)s +[E B C ] +-bar.ooo +[E C ] | +-bar.c +[E C ] | +-bar.h +[E C ] | +-foo.h +[E C ] | +-%(CC)s +[E C ] +-%(LINK)s +""" % locals() + +test.run(arguments = "--debug=stree foo.xxx", + stderr = stderr) +test.fail_test(string.find(test.stdout(), stree) == -1) + +stree2 = """ + E = exists + R = exists in repository only + b = implicit builder + B = explicit builder + S = side effect + P = precious + A = always build + C = current + N = no clean + H = no cache + +[ B ]+-foo.xxx +[ B ] +-foo.ooo +[E C ] | +-foo.c +[E C ] | +-foo.h +[E C ] | +-bar.h +[E C ] | +-%(CC)s +[ B ] +-bar.ooo +[E C ] | +-bar.c +[E C ] | +-bar.h +[E C ] | +-foo.h +[E C ] | +-%(CC)s +[E C ] +-%(LINK)s +""" % locals() + +test.run(arguments = '-c foo.xxx') + +test.run(arguments = "--no-exec --debug=stree foo.xxx", + stderr = stderr) +test.fail_test(string.find(test.stdout(), stree2) == -1) + +test.pass_test() diff --git a/test/Deprecated/debug-tree.py b/test/Deprecated/debug-tree.py new file mode 100644 index 0000000..0703a16 --- /dev/null +++ b/test/Deprecated/debug-tree.py @@ -0,0 +1,167 @@ +#!/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 the --debug=tree option prints a tree representation of the +complete dependencies of a target. +""" + +import TestSCons +import sys +import string +import re +import time + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +CC = test.detect('CC') +LINK = test.detect('LINK') +if LINK is None: LINK = CC + +test.write('SConstruct', """ +env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx') +env.Program('Foo', Split('Foo.c Bar.c')) +""") + +# N.B.: We use upper-case file names (Foo* and Bar*) so that the sorting +# order with our upper-case SConstruct file is the same on case-sensitive +# (UNIX/Linux) and case-insensitive (Windows) systems. + +test.write('Foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +#include "Foo.h" +int main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f1.c\n"); + exit (0); +} +""") + +test.write('Bar.c', """ +#include "Bar.h" +int local = 1; +""") + +test.write('Foo.h', """ +#ifndef FOO_H +#define FOO_H +#include "Bar.h" +#endif +""") + +test.write('Bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "Foo.h" +#endif +""") + +expect = """ +scons: warning: The --debug=tree option is deprecated; please use --tree=all instead. +""" + +stderr = TestSCons.re_escape(expect) + TestSCons.file_expr + +tree1 = """ ++-Foo.xxx + +-Foo.ooo + | +-Foo.c + | +-Foo.h + | +-Bar.h + | +-%(CC)s + +-Bar.ooo + | +-Bar.c + | +-Bar.h + | +-Foo.h + | +-%(CC)s + +-%(LINK)s +""" % locals() + +test.run(arguments = "--debug=tree Foo.xxx", + stderr = stderr) +if string.find(test.stdout(), tree1) == -1: + sys.stdout.write('Did not find expected tree in the following output:\n') + sys.stdout.write(test.stdout()) + test.fail_test() + +tree2 = """ ++-. + +-Bar.c + +-Bar.h + +-Bar.ooo + | +-Bar.c + | +-Bar.h + | +-Foo.h + | +-%(CC)s + +-Foo.c + +-Foo.h + +-Foo.ooo + | +-Foo.c + | +-Foo.h + | +-Bar.h + | +-%(CC)s + +-Foo.xxx + | +-Foo.ooo + | | +-Foo.c + | | +-Foo.h + | | +-Bar.h + | | +-%(CC)s + | +-Bar.ooo + | | +-Bar.c + | | +-Bar.h + | | +-Foo.h + | | +-%(CC)s + | +-%(LINK)s + +-SConstruct +""" % locals() + +test.run(arguments = "--debug=tree .", + stderr = stderr) +if string.find(test.stdout(), tree2) == -1: + sys.stdout.write('Did not find expected tree in the following output:\n') + sys.stdout.write(test.stdout()) + test.fail_test() + +# Make sure we print the debug stuff even if there's a build failure. +test.write('Bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "Foo.h" +#endif +THIS SHOULD CAUSE A BUILD FAILURE +""") + +test.run(arguments = "--debug=tree Foo.xxx", + status = 2, + stderr = None) +if string.find(test.stdout(), tree1) == -1: + sys.stdout.write('Did not find expected tree in the following output:\n') + sys.stdout.write(test.stdout()) + test.fail_test() + +test.pass_test() |