diff options
Diffstat (limited to 'test/option')
-rw-r--r-- | test/option/debug-dtree.py | 110 | ||||
-rw-r--r-- | test/option/debug-memoizer.py | 2 | ||||
-rw-r--r-- | test/option/debug-stree.py | 129 | ||||
-rw-r--r-- | test/option/debug-tree.py | 159 | ||||
-rw-r--r-- | test/option/warn-dependency.py | 73 | ||||
-rw-r--r-- | test/option/warn-duplicate-environment.py | 80 | ||||
-rw-r--r-- | test/option/warn-misleading-keywords.py | 79 | ||||
-rw-r--r-- | test/option/warn-missing-sconscript.py (renamed from test/option/debug-nomemoizer.py) | 43 |
8 files changed, 263 insertions, 412 deletions
diff --git a/test/option/debug-dtree.py b/test/option/debug-dtree.py deleted file mode 100644 index 3ef396e..0000000 --- a/test/option/debug-dtree.py +++ /dev/null @@ -1,110 +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__" - -""" -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() - -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 -""") - -dtree1 = """ -+-foo.xxx - +-foo.ooo - +-bar.ooo -""" - -test.run(arguments = "--debug=dtree foo.xxx") -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 .") -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/option/debug-memoizer.py b/test/option/debug-memoizer.py index ad35b5d..7d984de 100644 --- a/test/option/debug-memoizer.py +++ b/test/option/debug-memoizer.py @@ -34,7 +34,7 @@ import string import TestSCons -test = TestSCons.TestSCons(match = TestSCons.match_re) +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) # Find out if we support metaclasses (Python 2.2 and later). diff --git a/test/option/debug-stree.py b/test/option/debug-stree.py deleted file mode 100644 index bf65dbb..0000000 --- a/test/option/debug-stree.py +++ /dev/null @@ -1,129 +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__" - -""" -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() - -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 -""") - -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") -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") -test.fail_test(string.find(test.stdout(), stree2) == -1) - -test.pass_test() diff --git a/test/option/debug-tree.py b/test/option/debug-tree.py deleted file mode 100644 index f581bc4..0000000 --- a/test/option/debug-tree.py +++ /dev/null @@ -1,159 +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__" - -""" -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() - -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 -""") - -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") -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 .") -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() diff --git a/test/option/warn-dependency.py b/test/option/warn-dependency.py new file mode 100644 index 0000000..b849bed --- /dev/null +++ b/test/option/warn-dependency.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__" + +""" +Verify use of the --warn=dependency option. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + + +test.write("SConstruct", """\ +import SCons.Defaults + +def build(target, source, env): + pass + +env=Environment() +env['BUILDERS']['test'] = Builder(action=build, + source_scanner=SCons.Defaults.ObjSourceScan) +env.test(target='foo', source='foo.c') +""") + +test.write("foo.c",""" +#include "not_there.h" +""") + + + +expect = r""" +scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found +""" + +test.run(arguments='--warn=dependency .', + stderr=expect + TestSCons.file_expr) + +test.run(arguments='--warn=dependency .', + stderr=expect + TestSCons.file_expr) + +test.run(arguments='--warn=all --warn=no-dependency .', + stderr=TestSCons.deprecated_python_expr) + +test.run(arguments='--warn=no-dependency --warn=all .', + stderr=TestSCons.deprecated_python_expr + expect + TestSCons.file_expr) + + + +test.pass_test() diff --git a/test/option/warn-duplicate-environment.py b/test/option/warn-duplicate-environment.py new file mode 100644 index 0000000..90a7506 --- /dev/null +++ b/test/option/warn-duplicate-environment.py @@ -0,0 +1,80 @@ +#!/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 --warn=duplicate-environment option. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + + +test.write('SConstruct', """ +def build(env, target, source): + file = open(str(target[0]), 'wb') + for s in source: + file.write(open(str(s), 'rb').read()) + +WARN = ARGUMENTS.get('WARN') +if WARN: + SetOption('warn', WARN) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env2 = env.Clone(DIFFERENT_VARIABLE = 'true') +env.B(target = 'file1.out', source = 'file1a.in') +env2.B(target = 'file1.out', source = 'file1b.in') +""") + +test.write('file1a.in', 'file1a.in\n') +test.write('file1b.in', 'file1b.in\n') + +expect = r""" +scons: warning: Two different environments were specified for target file1.out, +\tbut they appear to have the same action: build\(target, source, env\) +""" + +test.run(arguments='file1.out', + stderr=expect + TestSCons.file_expr) + +test.must_match('file1.out', "file1a.in\nfile1b.in\n") + +test.run(arguments='--warn=duplicate-environment file1.out', + stderr=expect + TestSCons.file_expr) + +test.run(arguments='--warn=no-duplicate-environment file1.out') + +test.run(arguments='WARN=duplicate-environment file1.out', + stderr=expect + TestSCons.file_expr) + +test.run(arguments='WARN=no-duplicate-environment file1.out', + stderr = TestSCons.deprecated_python_expr) + + + +test.pass_test() diff --git a/test/option/warn-misleading-keywords.py b/test/option/warn-misleading-keywords.py new file mode 100644 index 0000000..f92ccb0 --- /dev/null +++ b/test/option/warn-misleading-keywords.py @@ -0,0 +1,79 @@ +#!/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 --warn=misleading-keywords option. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + + + +test.write('SConstruct', """ +def build(env, target, source): + file = open(str(target[0]), 'wb') + for s in source: + file.write(open(str(s), 'rb').read()) + +WARN = ARGUMENTS.get('WARN') +if WARN: + SetOption('warn', WARN) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(targets = 'file3a.out', source = 'file3a.in') +env.B(target = 'file3b.out', sources = 'file3b.in') +""") + +test.write('file3a.in', 'file3a.in\n') +test.write('file3b.out', 'file3b.out\n') + +expect = r""" +scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? +""" + +test.run(arguments='.', + stderr=expect + TestSCons.file_expr + expect + TestSCons.file_expr) + +test.must_match(['file3a'], 'file3a.in\n') +test.must_match(['file3b'], 'file3b.out\n') + +test.run(arguments='--warn=misleading-keywords .', + stderr=expect + TestSCons.file_expr + expect + TestSCons.file_expr) + +test.run(arguments='--warn=no-misleading-keywords .') + +test.run(arguments='WARN=misleading-keywords .', + stderr=expect + TestSCons.file_expr + expect + TestSCons.file_expr) + +test.run(arguments='WARN=no-misleading-keywords .', + stderr = TestSCons.deprecated_python_expr) + + + +test.pass_test() diff --git a/test/option/debug-nomemoizer.py b/test/option/warn-missing-sconscript.py index 3a927e5..f0aab04 100644 --- a/test/option/debug-nomemoizer.py +++ b/test/option/warn-missing-sconscript.py @@ -25,28 +25,45 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Test calling the (deprecated) --debug=nomemoizer option. +Verify use of the --warn=missing-sconscript option. """ import TestSCons -test = TestSCons.TestSCons(match = TestSCons.match_re) +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) -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("SConstruct", """\ +def build(target, source, env): + pass + +env=Environment() +env['BUILDERS']['test'] = Builder(action=build) +env.test(target='foo', source='foo.c') +WARN = ARGUMENTS.get('WARN') +if WARN: + SetOption('warn', WARN) +SConscript('no_such_file') """) -test.write('file.in', "file.in\n") +test.write("foo.c",""" +#include "not_there.h" +""") + +test.run(arguments = '--warn=missing-sconscript .', stderr = r""" +scons: warning: Ignoring missing SConscript 'no_such_file' +""" + TestSCons.file_expr) + +test.run(arguments = '--warn=no-missing-sconscript .', stderr = "") + +test.run(arguments = 'WARN=missing-sconscript .', stderr = r""" +scons: warning: Ignoring missing SConscript 'no_such_file' +""" + TestSCons.file_expr) -expect = """ -scons: warning: The --debug=nomemoizer option is deprecated and has no effect. -""" + TestSCons.file_expr +test.run(arguments = 'WARN=no-missing-sconscript .', + stderr = TestSCons.deprecated_python_expr) -test.run(arguments = "--debug=nomemoizer", stderr = expect) -test.must_match('file.out', "file.in\n") test.pass_test() |