diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-05-26 16:17:09 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-05-26 16:17:09 (GMT) |
commit | 545d2a0a389e9eacdb1d92fbf5f26f2d981029ad (patch) | |
tree | 23f5cda5c621bd7bb657ef9fd1d07e4578d4a934 /test/Deprecated | |
parent | 5c2e07585593ee4994b8e7d79b3d181a56cd7f13 (diff) | |
download | SCons-545d2a0a389e9eacdb1d92fbf5f26f2d981029ad.zip SCons-545d2a0a389e9eacdb1d92fbf5f26f2d981029ad.tar.gz SCons-545d2a0a389e9eacdb1d92fbf5f26f2d981029ad.tar.bz2 |
Start the deprecation cycle for the BuildDir() method and the build_dir
keyword parameter.
Several existing tests were still using BuildDir() or build_dir; they were
converted to use VariantDir() and variant_dir.
New tests were added to validate that the --warn=deprecated-build-dir option
and the SetOption method did the right thing. This led to the discovery that
a commonly-used test pattern provided by the infrastructure gobbled up too
much, causing tests to succeed when they should have failed. Fixing the
pattern led to other tests needing to be fixed.
In the process, it was discovered that the SCONSFLAG environment variable was
not getting correctly reset to its original value. Fixing this also caused
additional tests to misbehave, requiring them to be updated.
And test/Sig.py, which tests the deprecated SCons.Sig module, was moved to
the test/Deprecated directory.
All in all, quite a lot of action for what was supposed to be a simple change.
Diffstat (limited to 'test/Deprecated')
-rw-r--r-- | test/Deprecated/BuildDir.py | 56 | ||||
-rw-r--r-- | test/Deprecated/Options/BoolOption.py | 3 | ||||
-rw-r--r-- | test/Deprecated/SConscript-build_dir.py | 24 | ||||
-rw-r--r-- | test/Deprecated/Sig.py | 68 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/basic.py | 2 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/env.py | 2 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/implicit-cache.py | 2 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/no-csigs.py | 2 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/overrides.py | 2 | ||||
-rw-r--r-- | test/Deprecated/SourceSignatures/switch-rebuild.py | 2 | ||||
-rw-r--r-- | test/Deprecated/TargetSignatures/build-content.py | 2 | ||||
-rw-r--r-- | test/Deprecated/TargetSignatures/content.py | 2 | ||||
-rw-r--r-- | test/Deprecated/TargetSignatures/overrides.py | 2 |
13 files changed, 135 insertions, 34 deletions
diff --git a/test/Deprecated/BuildDir.py b/test/Deprecated/BuildDir.py index 4918ac0..5fe10c0 100644 --- a/test/Deprecated/BuildDir.py +++ b/test/Deprecated/BuildDir.py @@ -27,8 +27,6 @@ __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 TestSCons @@ -37,6 +35,17 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.write('SConstruct', """ +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) @@ -51,6 +60,7 @@ 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') @@ -60,12 +70,12 @@ 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) +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") @@ -185,28 +195,33 @@ test.write(['work1', 'src', 'f4h.in'], r""" # 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): +def filter_tempnam(err): if not err: - return 1 - stderrlines = [l for l in err.split('\n') if l] + return '' msg = "warning: tempnam() possibly used unsafely" - stderrlines = [l for l in stderrlines if l.find(msg) == -1] - return len(stderrlines) == 0 + return '\n'.join([l for l in err.splitlines() if l.find(msg) == -1]) test.run(chdir='work1', arguments = '. ../build', stderr=None) -test.fail_test(not blank_output(test.stderr())) +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', stdout=test.wrap_stdout("""\ +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): @@ -255,7 +270,8 @@ test.write(['work1', 'src', 'f4h.in'], r""" test.run(chdir='work1', arguments = '../build/var5', stderr=None) -test.fail_test(not blank_output(test.stderr())) +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), @@ -263,10 +279,16 @@ test.run(program = test.workpath('build', 'var5', 'foo3' + _exe), 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("""\ +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: diff --git a/test/Deprecated/Options/BoolOption.py b/test/Deprecated/Options/BoolOption.py index ac2ecdc..563939b 100644 --- a/test/Deprecated/Options/BoolOption.py +++ b/test/Deprecated/Options/BoolOption.py @@ -39,8 +39,8 @@ def check(expect): assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) - test.write(SConstruct_path, """\ +SetOption('warn', 'deprecated-options') from SCons.Options.BoolOption import BoolOption BO = BoolOption @@ -83,7 +83,6 @@ Invalid value for boolean option: irgendwas test.run(arguments='warnings=irgendwas', stderr=expect_stderr, status=2) - test.pass_test() # Local Variables: diff --git a/test/Deprecated/SConscript-build_dir.py b/test/Deprecated/SConscript-build_dir.py index 41b5222..76ff688 100644 --- a/test/Deprecated/SConscript-build_dir.py +++ b/test/Deprecated/SConscript-build_dir.py @@ -26,13 +26,24 @@ __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() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """ +SConscript('SConscript', build_dir = 'build') +""") + +test.write('SConscript', """ +""") + +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') @@ -47,6 +58,7 @@ 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') @@ -116,7 +128,7 @@ 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') +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" @@ -236,7 +248,7 @@ main(int argc, char *argv[]) { } """) -test.run(chdir="test2") +test.run(chdir="test2", stderr = warning) _obj = TestSCons._obj @@ -267,7 +279,7 @@ test.write(['test3', 'src', 'file.in'], "file.in\n") test.write(['test3', 'src', '_glscry', 'file.in'], "file.in\n") -test.run(chdir='test3') +test.run(chdir='test3', stderr = warning) test.pass_test() diff --git a/test/Deprecated/Sig.py b/test/Deprecated/Sig.py new file mode 100644 index 0000000..1ae118b --- /dev/null +++ b/test/Deprecated/Sig.py @@ -0,0 +1,68 @@ +#!/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 we generate the proper warning, but don't die, when someone +tries to import the SCons.Sig module (which no longer exists) and +use the things we used to define therein. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct = test.workpath('SConstruct') + +test.write(SConstruct, """ +import SCons.Sig +x = SCons.Sig.default_calc +x = SCons.Sig.default_module +x = SCons.Sig.MD5.current() +x = SCons.Sig.MD5.collect() +x = SCons.Sig.MD5.signature() +x = SCons.Sig.MD5.to_string() +x = SCons.Sig.MD5.from_string() +x = SCons.Sig.TimeStamp.current() +x = SCons.Sig.TimeStamp.collect() +x = SCons.Sig.TimeStamp.signature() +x = SCons.Sig.TimeStamp.to_string() +x = SCons.Sig.TimeStamp.from_string() +""") + +expect = """ +scons: warning: The SCons.Sig module no longer exists. + Remove the following "import SCons.Sig" line to eliminate this warning: +""" + test.python_file_line(SConstruct, 2) + +test.run(arguments = '.', 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/Deprecated/SourceSignatures/basic.py b/test/Deprecated/SourceSignatures/basic.py index c762a73..52a2c5c 100644 --- a/test/Deprecated/SourceSignatures/basic.py +++ b/test/Deprecated/SourceSignatures/basic.py @@ -54,7 +54,7 @@ def write_SConstruct(test, sigtype): expect = TestSCons.re_escape(""" scons: warning: The env.SourceSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr write_SConstruct(test, 'timestamp') diff --git a/test/Deprecated/SourceSignatures/env.py b/test/Deprecated/SourceSignatures/env.py index 4851140..bb76ff4 100644 --- a/test/Deprecated/SourceSignatures/env.py +++ b/test/Deprecated/SourceSignatures/env.py @@ -60,7 +60,7 @@ def write_SConstruct(test, env_sigtype, default_sigtype): expect = TestSCons.re_escape(""" scons: warning: The env.SourceSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr write_SConstruct(test, 'MD5', 'timestamp') diff --git a/test/Deprecated/SourceSignatures/implicit-cache.py b/test/Deprecated/SourceSignatures/implicit-cache.py index ee43ae4..af6aa49 100644 --- a/test/Deprecated/SourceSignatures/implicit-cache.py +++ b/test/Deprecated/SourceSignatures/implicit-cache.py @@ -51,7 +51,7 @@ env.B(target = 'both.out', source = 'both.in') expect = TestSCons.re_escape(""" scons: warning: The env.SourceSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr both_out_both_in = re.escape(test.wrap_stdout('build(["both.out"], ["both.in"])\n')) diff --git a/test/Deprecated/SourceSignatures/no-csigs.py b/test/Deprecated/SourceSignatures/no-csigs.py index 93ad408..f815538 100644 --- a/test/Deprecated/SourceSignatures/no-csigs.py +++ b/test/Deprecated/SourceSignatures/no-csigs.py @@ -50,7 +50,7 @@ test.write('f2.in', "f2.in\n") expect = TestSCons.re_escape(""" scons: warning: The env.SourceSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr test.run(arguments = '.', stderr = expect) diff --git a/test/Deprecated/SourceSignatures/overrides.py b/test/Deprecated/SourceSignatures/overrides.py index 78e7bad..4303c0e 100644 --- a/test/Deprecated/SourceSignatures/overrides.py +++ b/test/Deprecated/SourceSignatures/overrides.py @@ -39,7 +39,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) expect = TestSCons.re_escape(""" scons: warning: The env.SourceSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr test.write('SConstruct', """\ SetOption('warn', 'deprecated-source-signatures') diff --git a/test/Deprecated/SourceSignatures/switch-rebuild.py b/test/Deprecated/SourceSignatures/switch-rebuild.py index 70ebfbe..e8af27a 100644 --- a/test/Deprecated/SourceSignatures/switch-rebuild.py +++ b/test/Deprecated/SourceSignatures/switch-rebuild.py @@ -37,7 +37,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) expect = TestSCons.re_escape(""" scons: warning: The env.SourceSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr base_sconstruct_contents = """\ diff --git a/test/Deprecated/TargetSignatures/build-content.py b/test/Deprecated/TargetSignatures/build-content.py index 6213ef6..6a5a8c4 100644 --- a/test/Deprecated/TargetSignatures/build-content.py +++ b/test/Deprecated/TargetSignatures/build-content.py @@ -39,7 +39,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) expect = TestSCons.re_escape(""" scons: warning: The env.TargetSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr sconstruct_contents = """\ diff --git a/test/Deprecated/TargetSignatures/content.py b/test/Deprecated/TargetSignatures/content.py index 5bd1a89..2cd90ec 100644 --- a/test/Deprecated/TargetSignatures/content.py +++ b/test/Deprecated/TargetSignatures/content.py @@ -39,7 +39,7 @@ scons: warning: The env.SourceSignatures() method is deprecated; """) + TestSCons.file_expr + TestSCons.re_escape(""" scons: warning: The env.TargetSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr test.write('SConstruct', """\ diff --git a/test/Deprecated/TargetSignatures/overrides.py b/test/Deprecated/TargetSignatures/overrides.py index bc8de34..54a66d4 100644 --- a/test/Deprecated/TargetSignatures/overrides.py +++ b/test/Deprecated/TargetSignatures/overrides.py @@ -48,7 +48,7 @@ test.write('foo.in', "foo.in\n") expect = TestSCons.re_escape(""" scons: warning: The env.TargetSignatures() method is deprecated; \tconvert your build to use the env.Decider() method instead. -""") + TestSCons.file_expr + TestSCons.deprecated_python_expr +""") + TestSCons.file_expr test.run(arguments = '.', stderr = expect) |