From ac61e3fead14db2d61ac449d458c04f4bba4053f Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 15 Dec 2019 06:48:35 -0700 Subject: Remove deprecated BuildDir, build_dir Updates docs and code; moves tests to test/Removed/BuildDir/Old. New tests verify that these can no longer be used. Along the way a small cleanup in SConscript.py Signed-off-by: Mats Wichmann --- doc/user/separate.xml | 6 +- src/CHANGES.txt | 1 + src/engine/SCons/Environment.py | 8 - src/engine/SCons/Environment.xml | 22 -- src/engine/SCons/Script/SConscript.py | 24 +- src/engine/SCons/Script/__init__.py | 1 - src/engine/SCons/Warnings.py | 9 - test/Deprecated/BuildDir.py | 295 ---------------------- test/Deprecated/SConscript-build_dir.py | 291 --------------------- test/Removed/BuildDir/Old/BuildDir.py | 295 ++++++++++++++++++++++ test/Removed/BuildDir/Old/SConscript-build_dir.py | 291 +++++++++++++++++++++ test/Removed/BuildDir/README.md | 6 + test/Removed/BuildDir/SConstruct.global | 1 + test/Removed/BuildDir/SConstruct.kwarg | 1 + test/Removed/BuildDir/SConstruct.method | 3 + 15 files changed, 608 insertions(+), 646 deletions(-) delete mode 100644 test/Deprecated/BuildDir.py delete mode 100644 test/Deprecated/SConscript-build_dir.py create mode 100644 test/Removed/BuildDir/Old/BuildDir.py create mode 100644 test/Removed/BuildDir/Old/SConscript-build_dir.py create mode 100644 test/Removed/BuildDir/README.md create mode 100644 test/Removed/BuildDir/SConstruct.global create mode 100644 test/Removed/BuildDir/SConstruct.kwarg create mode 100644 test/Removed/BuildDir/SConstruct.method diff --git a/doc/user/separate.xml b/doc/user/separate.xml index c276545..748a124 100644 --- a/doc/user/separate.xml +++ b/doc/user/separate.xml @@ -149,10 +149,8 @@ program using the F path name. One historical note: the &VariantDir; function - used to be called &BuildDir;. - That name is still supported - but has been deprecated - because the &SCons; functionality + used to be called &BuildDir;, a name which was + removed because the &SCons; functionality differs from the model of a "build directory" implemented by other build systems like the GNU Autotools. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index dade5e0..28a4b43 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -66,6 +66,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Remove deprecated SourceSignatures, TargetSignatures - Remove deprecated Builder keywords: overrides and scanner - Remove deprecated env.Copy + - Remove deprecated BuildDir plus SConscript keyword build_dir - A number of documentation improvements. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 4535be9..27179c3 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -1929,14 +1929,6 @@ class Base(SubstitutionEnvironment): t.set_always_build() return tlist - def BuildDir(self, *args, **kw): - msg = """BuildDir() and the build_dir keyword have been deprecated;\n\tuse VariantDir() and the variant_dir keyword instead.""" - SCons.Warnings.warn(SCons.Warnings.DeprecatedBuildDirWarning, msg) - if 'build_dir' in kw: - kw['variant_dir'] = kw['build_dir'] - del kw['build_dir'] - return self.VariantDir(*args, **kw) - def Builder(self, **kw): nkw = self.subst_kw(kw) return SCons.Builder.Builder(**nkw) diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index 73c347e..6f263a4 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -613,28 +613,6 @@ env.AppendUnique(CCFLAGS = '-g', FOO = ['foo.yyy']) - - -(build_dir, src_dir, [duplicate]) - - - -Deprecated synonyms for -&f-VariantDir; -and -env.VariantDir(). -The -build_dir -argument becomes the -variant_dir -argument of -&f-VariantDir; -or -env.VariantDir(). - - - - (action, [arguments]) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index eabaddb..0298a69 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -42,7 +42,7 @@ import SCons.Platform import SCons.SConf import SCons.Script.Main import SCons.Tool -import SCons.Util +from SCons.Util import is_List, is_String, is_Dict, flatten from . import Main @@ -98,7 +98,7 @@ def compute_exports(exports): retval = {} try: for export in exports: - if SCons.Util.is_Dict(export): + if is_Dict(export): retval.update(export) else: try: @@ -133,7 +133,7 @@ call_stack = [] def Return(*vars, **kw): retval = [] try: - fvars = SCons.Util.flatten(vars) + fvars = flatten(vars) for var in fvars: for v in var.split(): retval.append(call_stack[-1].globals[v]) @@ -420,7 +420,7 @@ class SConsEnvironment(SCons.Environment.Base): except KeyError: raise SCons.Errors.UserError("Invalid SConscript usage - no parameters") - if not SCons.Util.is_List(dirs): + if not is_List(dirs): dirs = [ dirs ] dirs = list(map(str, dirs)) @@ -441,13 +441,13 @@ class SConsEnvironment(SCons.Environment.Base): raise SCons.Errors.UserError("Invalid SConscript() usage - too many arguments") - if not SCons.Util.is_List(files): + if not is_List(files): files = [ files ] if kw.get('exports'): exports.extend(self.Split(kw['exports'])) - variant_dir = kw.get('variant_dir') or kw.get('build_dir') + variant_dir = kw.get('variant_dir') if variant_dir: if len(files) != 1: raise SCons.Errors.UserError("Invalid SConscript() usage - can only specify one SConscript with a variant_dir") @@ -577,9 +577,6 @@ class SConsEnvironment(SCons.Environment.Base): UserError: a script is not found and such exceptions are enabled. """ - if 'build_dir' in kw: - msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead.""" - SCons.Warnings.warn(SCons.Warnings.DeprecatedBuildDirWarning, msg) def subst_element(x, subst=self.subst): if SCons.Util.is_List(x): x = list(map(subst, x)) @@ -589,15 +586,10 @@ class SConsEnvironment(SCons.Environment.Base): ls = list(map(subst_element, ls)) subst_kw = {} for key, val in kw.items(): - if SCons.Util.is_String(val): + if is_String(val): val = self.subst(val) elif SCons.Util.is_List(val): - result = [] - for v in val: - if SCons.Util.is_String(v): - v = self.subst(v) - result.append(v) - val = result + val = [self.subst(v) if is_String(v) else v for v in val] subst_kw[key] = val files, exports = self._get_SConscript_filenames(ls, subst_kw) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 24af73e..9947943 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -314,7 +314,6 @@ GlobalDefaultEnvironmentFunctions = [ 'AddPreAction', 'Alias', 'AlwaysBuild', - 'BuildDir', 'CacheDir', 'Clean', #The Command() method is handled separately, below. diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py index cd24b7c..fcec963 100644 --- a/src/engine/SCons/Warnings.py +++ b/src/engine/SCons/Warnings.py @@ -120,9 +120,6 @@ class PythonVersionWarning(DeprecatedWarning): class DeprecatedSourceCodeWarning(FutureDeprecatedWarning): pass -class DeprecatedBuildDirWarning(DeprecatedWarning): - pass - class TaskmasterNeedsExecuteWarning(DeprecatedWarning): pass @@ -132,12 +129,6 @@ class DeprecatedOptionsWarning(MandatoryDeprecatedWarning): class DeprecatedDebugOptionsWarning(MandatoryDeprecatedWarning): pass -class DeprecatedSigModuleWarning(MandatoryDeprecatedWarning): - pass - -class DeprecatedBuilderKeywordsWarning(MandatoryDeprecatedWarning): - pass - class DeprecatedMissingSConscriptWarning(DeprecatedWarning): pass diff --git a/test/Deprecated/BuildDir.py b/test/Deprecated/BuildDir.py deleted file mode 100644 index 1a1ba02..0000000 --- a/test/Deprecated/BuildDir.py +++ /dev/null @@ -1,295 +0,0 @@ -#!/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). -""" - -import TestSCons - -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -BuildDir('build', 'src') -""") - -msg = """BuildDir() and the build_dir keyword have been deprecated; -\tuse VariantDir() and the variant_dir keyword instead.""" -test.deprecated_warning('deprecated-build-dir', msg) - -warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \ - + '\n' + TestSCons.file_expr - -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'], """ -SetOption('warn', 'deprecated-build-dir') -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') - -BuildDir('build/var1', src) -BuildDir(var2, src) -BuildDir(var3, src, duplicate=0) -env.BuildDir("$BUILD/var4", "$SRC", duplicate=0) -BuildDir(var5, src, duplicate=0) -BuildDir(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.path - -def buildIt(target, source, env): - if not os.path.exists('build'): - os.mkdir('build') - with open(str(source[0]), 'r') as ifp, open(str(target[0]), 'w') as ofp: - ofp.write(ifp.read()) - 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 -#include - -#include "f1.h" - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf(F1_STR); - exit (0); -} -""") - -test.write(['work1', 'src', 'f2.in'], r""" -#include -#include - -#include "f2.h" - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf(F2_STR); - exit (0); -} -""") - -test.write(['work1', 'src', 'f3.c'], r""" -#include -#include - -#include "f3.h" - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf(F3_STR); - exit (0); -} -""") - -test.write(['work1', 'src', 'f4.in'], r""" -#include -#include - -#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 filter_tempnam(err): - if not err: - return '' - msg = "warning: tempnam() possibly used unsafely" - return '\n'.join([l for l in err.splitlines() if l.find(msg) == -1]) - -test.run(chdir='work1', arguments = '. ../build', stderr=None) - -stderr = filter_tempnam(test.stderr()) -test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) - -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', - stderr = None, - stdout=test.wrap_stdout("""\ -scons: `.' is up to date. -scons: `%s' is up to date. -""" % test.workpath('build'))) - -stderr = filter_tempnam(test.stderr()) -test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) - -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) - -stderr = filter_tempnam(test.stderr()) -test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) - -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', - stderr=None, - stdout=test.wrap_stdout("""\ -scons: `%s' is up to date. -""" % test.workpath('build', 'var5'))) - -stderr = filter_tempnam(test.stderr()) -test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SConscript-build_dir.py b/test/Deprecated/SConscript-build_dir.py deleted file mode 100644 index 0d1ba6a..0000000 --- a/test/Deprecated/SConscript-build_dir.py +++ /dev/null @@ -1,291 +0,0 @@ -#!/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. -""" - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -SConscript('DummyScript', build_dir = 'build') -""") - -test.write('DummyScript', """ -""") - -msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead.""" -test.deprecated_warning('deprecated-build-dir', msg) - -warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \ - + '\n' + TestSCons.file_expr - -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'], """ -SetOption('warn', 'deprecated-build-dir') -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]) - with open(target, "wb") as ofp: - for src in source: - with open(str(src), "rb") as ifp: - ofp.write(ifp.read()) - -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', stderr = 7*warning) - -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 -#include - -void -bar(void) { - printf("bar.c\n"); -} -""") - -test.write(['test2', 'foo.c'], r""" -#include -#include - -extern void -bar(void); - -int -main(int argc, char *argv[]) { - bar(); - printf("foo.c\n"); -} -""") - -test.run(chdir="test2", stderr = warning) - -_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', stderr = warning) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Removed/BuildDir/Old/BuildDir.py b/test/Removed/BuildDir/Old/BuildDir.py new file mode 100644 index 0000000..1a1ba02 --- /dev/null +++ b/test/Removed/BuildDir/Old/BuildDir.py @@ -0,0 +1,295 @@ +#!/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). +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.write('SConscript', """ +BuildDir('build', 'src') +""") + +msg = """BuildDir() and the build_dir keyword have been deprecated; +\tuse VariantDir() and the variant_dir keyword instead.""" +test.deprecated_warning('deprecated-build-dir', msg) + +warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \ + + '\n' + TestSCons.file_expr + +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'], """ +SetOption('warn', 'deprecated-build-dir') +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') + +BuildDir('build/var1', src) +BuildDir(var2, src) +BuildDir(var3, src, duplicate=0) +env.BuildDir("$BUILD/var4", "$SRC", duplicate=0) +BuildDir(var5, src, duplicate=0) +BuildDir(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.path + +def buildIt(target, source, env): + if not os.path.exists('build'): + os.mkdir('build') + with open(str(source[0]), 'r') as ifp, open(str(target[0]), 'w') as ofp: + ofp.write(ifp.read()) + 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 +#include + +#include "f1.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F1_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f2.in'], r""" +#include +#include + +#include "f2.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F2_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f3.c'], r""" +#include +#include + +#include "f3.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf(F3_STR); + exit (0); +} +""") + +test.write(['work1', 'src', 'f4.in'], r""" +#include +#include + +#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 filter_tempnam(err): + if not err: + return '' + msg = "warning: tempnam() possibly used unsafely" + return '\n'.join([l for l in err.splitlines() if l.find(msg) == -1]) + +test.run(chdir='work1', arguments = '. ../build', stderr=None) + +stderr = filter_tempnam(test.stderr()) +test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) + +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', + stderr = None, + stdout=test.wrap_stdout("""\ +scons: `.' is up to date. +scons: `%s' is up to date. +""" % test.workpath('build'))) + +stderr = filter_tempnam(test.stderr()) +test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) + +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) + +stderr = filter_tempnam(test.stderr()) +test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) + +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', + stderr=None, + stdout=test.wrap_stdout("""\ +scons: `%s' is up to date. +""" % test.workpath('build', 'var5'))) + +stderr = filter_tempnam(test.stderr()) +test.fail_test(TestSCons.match_re_dotall(stderr, 6*warning)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Removed/BuildDir/Old/SConscript-build_dir.py b/test/Removed/BuildDir/Old/SConscript-build_dir.py new file mode 100644 index 0000000..0d1ba6a --- /dev/null +++ b/test/Removed/BuildDir/Old/SConscript-build_dir.py @@ -0,0 +1,291 @@ +#!/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. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConscript', """ +SConscript('DummyScript', build_dir = 'build') +""") + +test.write('DummyScript', """ +""") + +msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead.""" +test.deprecated_warning('deprecated-build-dir', msg) + +warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \ + + '\n' + TestSCons.file_expr + +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'], """ +SetOption('warn', 'deprecated-build-dir') +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]) + with open(target, "wb") as ofp: + for src in source: + with open(str(src), "rb") as ifp: + ofp.write(ifp.read()) + +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', stderr = 7*warning) + +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 +#include + +void +bar(void) { + printf("bar.c\n"); +} +""") + +test.write(['test2', 'foo.c'], r""" +#include +#include + +extern void +bar(void); + +int +main(int argc, char *argv[]) { + bar(); + printf("foo.c\n"); +} +""") + +test.run(chdir="test2", stderr = warning) + +_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', stderr = warning) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Removed/BuildDir/README.md b/test/Removed/BuildDir/README.md new file mode 100644 index 0000000..c4fd879 --- /dev/null +++ b/test/Removed/BuildDir/README.md @@ -0,0 +1,6 @@ +BuildDir/Old contains old tests which used the now removed BuildDir +function, env.BuildDir method, and build_dir argument to SConscript, +preserved here for reference; the presence of an scontest.skip file +means they are never executed. + +The "new" tests verify failure using these symbols. diff --git a/test/Removed/BuildDir/SConstruct.global b/test/Removed/BuildDir/SConstruct.global new file mode 100644 index 0000000..086fbae --- /dev/null +++ b/test/Removed/BuildDir/SConstruct.global @@ -0,0 +1 @@ +BuildDir('build', 'src') diff --git a/test/Removed/BuildDir/SConstruct.kwarg b/test/Removed/BuildDir/SConstruct.kwarg new file mode 100644 index 0000000..a5c46fb --- /dev/null +++ b/test/Removed/BuildDir/SConstruct.kwarg @@ -0,0 +1 @@ +SConscript('src/SConscript', build_dir='build') diff --git a/test/Removed/BuildDir/SConstruct.method b/test/Removed/BuildDir/SConstruct.method new file mode 100644 index 0000000..afea459 --- /dev/null +++ b/test/Removed/BuildDir/SConstruct.method @@ -0,0 +1,3 @@ +env = Environment(BUILD='build', SRC='src') + +env.BuildDir('build', 'src') -- cgit v0.12 From 063a3281b4fe7f43a34c0e65dfd3a02446ba12f8 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 15 Dec 2019 09:08:10 -0700 Subject: [PR #3497] add the missing testcases forgot to add these to the initial commit Signed-off-by: Mats Wichmann --- test/Removed/BuildDir/BuildDir.py | 61 +++++++++++++++++++++++++++ test/Removed/BuildDir/SConscript-build_dir.py | 54 ++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 test/Removed/BuildDir/BuildDir.py create mode 100644 test/Removed/BuildDir/SConscript-build_dir.py diff --git a/test/Removed/BuildDir/BuildDir.py b/test/Removed/BuildDir/BuildDir.py new file mode 100644 index 0000000..43c8b8b --- /dev/null +++ b/test/Removed/BuildDir/BuildDir.py @@ -0,0 +1,61 @@ +#!/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 BuildDir function and method no longer work. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons(match=TestSCons.match_exact) + +test.subdir('src') + +test.file_fixture('SConstruct.global', 'SConstruct') +expect = """\ +NameError: name 'BuildDir' is not defined: + File "{}", line 1: + BuildDir('build', 'src') +""".format(test.workpath('SConstruct')) +test.run(arguments='-Q -s', status=2, stderr=expect) + +test.file_fixture('SConstruct.method', 'SConstruct') +expect = """\ +AttributeError: 'SConsEnvironment' object has no attribute 'BuildDir': + File "{}", line 3: + env.BuildDir('build', 'src') +""".format(test.workpath('SConstruct')) +test.run(arguments='-Q -s', status=2, stderr=expect) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Removed/BuildDir/SConscript-build_dir.py b/test/Removed/BuildDir/SConscript-build_dir.py new file mode 100644 index 0000000..55be7b1 --- /dev/null +++ b/test/Removed/BuildDir/SConscript-build_dir.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__" + +""" +Verify that specifying a build_dir argument to SConscript no longer works. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_exact) + +test.file_fixture('SConstruct.kwarg', 'SConstruct') +test.subdir('src') +test.write(['src', 'SConscript'], """ +""") + +# this doesn't work yet +expect = """\ +TypeError: SConscript() got an unexpected keyword argument 'build_dir': + File "{}", line 1: + SConscript('src/SConscript', build_dir='build') +""".format(test.workpath('SConstruct')) +test.run(arguments='-Q -s', status=2, stderr=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 81142e5249452a32a6b167709299ec45a92f0717 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 15 Dec 2019 12:23:36 -0700 Subject: [PR #3497] add missed sconstest.skip Signed-off-by: Mats Wichmann --- test/Removed/BuildDir/Old/sconstest.skip | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/Removed/BuildDir/Old/sconstest.skip diff --git a/test/Removed/BuildDir/Old/sconstest.skip b/test/Removed/BuildDir/Old/sconstest.skip new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 85b6c3efd79561dd9c9af71217ee8dff8b05c37a Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 16 Dec 2019 08:27:57 -0700 Subject: [PR #3497] skip test for build_dir kwarg Turns out cannot test for now-unknown build_dir arg because SConscript() doesn't error on such. Skip test for now, leaving a note (and and issue). Signed-off-by: Mats Wichmann --- test/Removed/BuildDir/SConscript-build_dir.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/Removed/BuildDir/SConscript-build_dir.py b/test/Removed/BuildDir/SConscript-build_dir.py index 55be7b1..5a8d1ca 100644 --- a/test/Removed/BuildDir/SConscript-build_dir.py +++ b/test/Removed/BuildDir/SConscript-build_dir.py @@ -32,6 +32,9 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_exact) +#TODO: fix #3500 and restore test, or drop entirly +test.skip_test('SConscript() does not error on unknown kwargs, see Issue #3500, skipping test\n') + test.file_fixture('SConstruct.kwarg', 'SConstruct') test.subdir('src') test.write(['src', 'SConscript'], """ -- cgit v0.12