diff options
author | Steven Knight <knight@baldmt.com> | 2007-01-07 07:23:05 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2007-01-07 07:23:05 (GMT) |
commit | 8f79b64540d5c6b8c9ca36f1a4ebcaf4d9df3d98 (patch) | |
tree | 05e6aee9b46b530443e01bbb762b68775a6bb0ff /test | |
parent | c4d04b3b45e7b71a1b28053b90084bcf2fdf9c0e (diff) | |
download | SCons-8f79b64540d5c6b8c9ca36f1a4ebcaf4d9df3d98.zip SCons-8f79b64540d5c6b8c9ca36f1a4ebcaf4d9df3d98.tar.gz SCons-8f79b64540d5c6b8c9ca36f1a4ebcaf4d9df3d98.tar.bz2 |
Merged revisions 1738-1754,1756 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core
........
r1741 | stevenknight | 2006-12-16 22:51:07 -0600 (Sat, 16 Dec 2006) | 1 line
0.96.D527 - Give the f90 and f95 Tool modules knowledge of how to build source files of earlier Fortran versions.
........
r1742 | stevenknight | 2006-12-16 23:22:54 -0600 (Sat, 16 Dec 2006) | 1 line
0.96.D528 - Better handling of timestamp fallback if there's no md5 module.
........
r1743 | stevenknight | 2006-12-17 00:21:31 -0600 (Sun, 17 Dec 2006) | 1 line
0.96.D529 - Fix portability of new tests on systems that don't have TeX installed.
........
r1744 | stevenknight | 2006-12-19 15:30:16 -0600 (Tue, 19 Dec 2006) | 1 line
0.96.D530 - Eliminate the ListBuilder subclass in favor of using the Executor's target lists.
........
r1745 | stevenknight | 2006-12-19 18:54:26 -0600 (Tue, 19 Dec 2006) | 1 line
0.96.D531 - Eliminate of MultiStepBuilder as a separate Builder subclass.
........
r1746 | garyo | 2006-12-21 13:21:08 -0600 (Thu, 21 Dec 2006) | 1 line
Minor doc fix, thanks to Douglas Landgraf.
........
r1747 | stevenknight | 2006-12-21 17:13:55 -0600 (Thu, 21 Dec 2006) | 1 line
0.96.D533 - Add CFLAGS for options common to C/C++. (Gary Oberbrunner)
........
r1748 | stevenknight | 2007-01-03 19:48:05 -0600 (Wed, 03 Jan 2007) | 1 line
0.96.D534 - Fix signature storage when targets are retrieved from CacheDir().
........
r1749 | stevenknight | 2007-01-04 16:48:47 -0600 (Thu, 04 Jan 2007) | 1 line
0.96.D535 - Teach the lex and yacc tools about target files generated by different flex/bison options, and about Objective C suffixes. (Pupeno)
........
r1750 | stevenknight | 2007-01-04 17:14:38 -0600 (Thu, 04 Jan 2007) | 1 line
0.96.D536 - Refactor duplicate disambiguation logic in Entry.get_contents().
........
r1751 | stevenknight | 2007-01-05 13:00:54 -0600 (Fri, 05 Jan 2007) | 1 line
0.96.D537 - Fix lprof regression from 0.96.92.
........
r1752 | stevenknight | 2007-01-05 20:43:48 -0600 (Fri, 05 Jan 2007) | 1 line
0.96.D538 - Fix caching of Builder suffix matching (to fix lprof regression).
........
r1753 | stevenknight | 2007-01-06 00:03:16 -0600 (Sat, 06 Jan 2007) | 1 line
0.96.D539 - Fix --include-dir when using MinGW. (Paul)
........
r1754 | stevenknight | 2007-01-06 00:24:53 -0600 (Sat, 06 Jan 2007) | 1 line
0.96.D540 - Make bootstrap.py something useful to execute SCons out of a source directory.
........
r1756 | stevenknight | 2007-01-06 21:32:11 -0600 (Sat, 06 Jan 2007) | 1 line
0.96.D541 - Update the Copyright year string to include 2007. Automate updating the month+year string in man page title headers. Fix hard-coded __revision__ strings that crept into some older tests.
........
Diffstat (limited to 'test')
30 files changed, 1524 insertions, 775 deletions
diff --git a/test/Builder/multi/different-actions.py b/test/Builder/multi/different-actions.py new file mode 100644 index 0000000..ed1c676 --- /dev/null +++ b/test/Builder/multi/different-actions.py @@ -0,0 +1,60 @@ +#!/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 environments with actions that have different signatures +generate an error. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +B = Builder(action=Action(build, varlist=['XXX']), multi=1) +env = Environment(BUILDERS = { 'B' : B }, XXX = 'foo') +env2 = env.Clone(XXX = 'var') +env.B(target = 'file6.out', source = 'file6a.in') +env2.B(target = 'file6.out', source = 'file6b.in') +""") + +test.write('file6a.in', 'file6a.in\n') +test.write('file6b.in', 'file6b.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Two environments with different actions were specified for the same target: file6.out +""") + TestSCons.file_expr + +test.pass_test() + +test.run(arguments='file6.out', status=2, stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/different-environments.py b/test/Builder/multi/different-environments.py new file mode 100644 index 0000000..9d1dcc8 --- /dev/null +++ b/test/Builder/multi/different-environments.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that a warning is generated if the calls have different overrides +but the overrides don't appear to affect the build operation. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +_python_ = TestSCons._python_ + +test.write('build.py', r"""#!/usr/bin/env python +import sys +def build(num, target, source): + file = open(str(target), 'wb') + file.write('%s\n'%num) + for s in source: + file.write(open(str(s), 'rb').read()) +build(sys.argv[1],sys.argv[2],sys.argv[3:]) +""") + +test.write('SConstruct', """\ +B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'file03.out', source = 'file03a.in', foo=1) +env.B(target = 'file03.out', source = 'file03b.in', foo=2) +""" % locals()) + +test.write('file03a.in', 'file03a.in\n') +test.write('file03b.in', 'file03b.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Two environments with different actions were specified for the same target: file03.out +""") + TestSCons.file_expr + +test.run(arguments='file03.out', status=2, stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/different-multi.py b/test/Builder/multi/different-multi.py new file mode 100644 index 0000000..1f0ef2a --- /dev/null +++ b/test/Builder/multi/different-multi.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that trying to call a target with two different "multi" builders +generates an error. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +def build2(env, target, source): + build(env, target, source) + +# Put the names on the Builder objects and in the environment so +# the error output should be consistent regardless of Python version +# or how we mess with the Builder internals. +B = Builder(action=build, multi=1, name='B') +C = Builder(action=build2, multi=1, name='C') +env = Environment(BUILDERS = { 'B' : B, 'C' : C }) +env.B(target = 'file8.out', source = 'file8.in') +env.C(target = 'file8.out', source = 'file8.in') +""") + +test.write('file8a.in', 'file8a.in\n') +test.write('file8b.in', 'file8b.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Two different builders (B and C) were specified for the same target: file8.out +""") + TestSCons.file_expr + +test.run(arguments='file8.out', status=2, stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/different-order.py b/test/Builder/multi/different-order.py new file mode 100644 index 0000000..f4a6443 --- /dev/null +++ b/test/Builder/multi/different-order.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that a "multi" builder can NOT be called multiple times with +target lists that have different orders. This is intentional; the +order of the targets matter to the builder because the build command +can contain things like ${TARGET[0]}. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +def build(env, target, source): + for t in target: + file = open(str(target[0]), 'wb') + for s in source: + file.write(open(str(s), 'rb').read()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = ['file10a.out', 'file10b.out'], source = 'file10.in') +env.B(target = ['file10b.out', 'file10a.out'], source = 'file10.in') +""") + +test.write('file10.in', 'file10.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Two different target lists have a target in common: file10b.out (from ['file10a.out', 'file10b.out'] and from ['file10b.out', 'file10a.out']) +""") + TestSCons.file_expr + +test.run(arguments='file10.out', status=2, stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/different-overrides.py b/test/Builder/multi/different-overrides.py new file mode 100644 index 0000000..5420a49 --- /dev/null +++ b/test/Builder/multi/different-overrides.py @@ -0,0 +1,58 @@ +#!/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 a warning is generated if the calls have different overrides +but the overrides don't appear to affect the build operation. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'file3.out', source = 'file3a.in', foo=1) +env.B(target = 'file3.out', source = 'file3b.in', foo=2) +""") + +test.write('file3a.in', 'file3a.in\n') +test.write('file3b.in', 'file3b.in\n') + +expect = TestSCons.re_escape(""" +scons: warning: Two different environments were specified for target file3.out, +\tbut they appear to have the same action: build(target, source, env) +""") + TestSCons.file_expr + +test.run(arguments='file3.out', stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/different-target-lists.py b/test/Builder/multi/different-target-lists.py new file mode 100644 index 0000000..5822199 --- /dev/null +++ b/test/Builder/multi/different-target-lists.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that a target file can't be in two different target lists. +""" + +# XXX It would be nice if the following two tests could be made to work +# by executing the action once for each unique set of targets. This +# would make it simple to deal with PDB files on Windows like so: +# +# env.Object(['foo.obj', 'vc60.pdb'], 'foo.c') +# env.Object(['bar.obj', 'vc60.pdb'], 'bar.c') + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +def build(env, target, source): + for t in target: + file = open(str(target[0]), 'wb') + for s in source: + file.write(open(str(s), 'rb').read()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = ['file11a.out', 'file11b.out'], source = 'file11a.in') +env.B(target = ['file11b.out', 'file11c.out'], source = 'file11b.in') +""") + +test.write('file11a.in', 'file11a.in\n') +test.write('file11b.in', 'file11b.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Two different target lists have a target in common: file11b.out (from ['file11a.out', 'file11b.out'] and from ['file11b.out', 'file11c.out']) +""") + TestSCons.file_expr + +test.run(arguments='file11.out', status=2, stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/error.py b/test/Builder/multi/error.py new file mode 100644 index 0000000..4201cfc --- /dev/null +++ b/test/Builder/multi/error.py @@ -0,0 +1,57 @@ +#!/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 a builder with "multi" not set generates an error on the +second call. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +B = Builder(action=build, multi=0) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'file2.out', source = 'file2a.in') +env.B(target = 'file2.out', source = 'file2b.in') +""") + +test.write('file2a.in', 'file2a.in\n') +test.write('file2b.in', 'file2b.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Multiple ways to build the same target were specified for: file2.out (from ['file2a.in'] and from ['file2b.in']) +""") + TestSCons.file_expr + +test.run(arguments='file2.out', status=2, stderr=expect) + +test.pass_test() diff --git a/test/Builder/multi/lone-target-list.py b/test/Builder/multi/lone-target-list.py new file mode 100644 index 0000000..a305b54 --- /dev/null +++ b/test/Builder/multi/lone-target-list.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that a target file can't be a lone target and in a list. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +def build(env, target, source): + for t in target: + file = open(str(target[0]), 'wb') + for s in source: + file.write(open(str(s), 'rb').read()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = ['file12a.out', 'file12b.out'], source = 'file12a.in') +env.B(target = 'file12a.out', source = 'file12b.in') +""") + +test.write('file12a.in', 'file12a.in\n') +test.write('file12b.in', 'file12b.in\n') + +expect = TestSCons.re_escape(""" +scons: *** Two different target lists have a target in common: file12a.out (from ['file12a.out', 'file12b.out'] and from ['file12a.out']) +""") + TestSCons.file_expr + +test.run(arguments='file12.out', status=2, stderr=expect) + + + +test.pass_test() diff --git a/test/Builder/multi/multi.py b/test/Builder/multi/multi.py new file mode 100644 index 0000000..315599b --- /dev/null +++ b/test/Builder/multi/multi.py @@ -0,0 +1,55 @@ +#!/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 a builder with "multi" set can be called multiple times +and the source files are added to the list. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'file1.out', source = 'file1a.in') +env.B(target = 'file1.out', source = 'file1b.in') +""") + +test.write('file1a.in', 'file1a.in\n') +test.write('file1b.in', 'file1b.in\n') + +test.run(arguments='file1.out') + +test.must_match('file1.out', "file1a.in\nfile1b.in\n") + +test.pass_test() diff --git a/test/Builder/multi/same-actions.py b/test/Builder/multi/same-actions.py new file mode 100644 index 0000000..afccb65 --- /dev/null +++ b/test/Builder/multi/same-actions.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 two different environments can be used for the same target, +so long as the actions have the same signature; a warning is generated. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env2 = env.Clone(DIFFERENT_VARIABLE = 'true') +env.B(target = 'file5.out', source = 'file5a.in') +env2.B(target = 'file5.out', source = 'file5b.in') +""") + +test.write('file5a.in', 'file5a.in\n') +test.write('file5b.in', 'file5b.in\n') + +expect = TestSCons.re_escape(""" +scons: warning: Two different environments were specified for target file5.out, +\tbut they appear to have the same action: build(target, source, env) +""") + TestSCons.file_expr + +test.run(arguments='file5.out', stderr=expect) + +test.must_match('file5.out', "file5a.in\nfile5b.in\n") + +test.pass_test() diff --git a/test/Builder/multi/same-overrides.py b/test/Builder/multi/same-overrides.py new file mode 100644 index 0000000..d12af21 --- /dev/null +++ b/test/Builder/multi/same-overrides.py @@ -0,0 +1,71 @@ +#!/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 everything works if two multi calls have the same overrides. +""" + +import string + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +_python_ = TestSCons._python_ + +test.write('build.py', r"""#!/usr/bin/env python +import sys +def build(num, target, source): + file = open(str(target), 'wb') + file.write('%s\n'%num) + for s in source: + file.write(open(str(s), 'rb').read()) +build(sys.argv[1],sys.argv[2],sys.argv[3:]) +""") + +test.write('SConstruct', """\ +B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'file4.out', source = 'file4a.in', foo=3) +env.B(target = 'file4.out', source = 'file4b.in', foo=3) +""" % locals()) + +test.write('file4a.in', 'file4a.in\n') +test.write('file4b.in', 'file4b.in\n') + +python_expr = string.replace(TestSCons.python, '\\', '\\\\') +act = TestSCons.re_escape('"%s" build.py \$foo \$TARGET \$SOURCES' % python_expr) + +expect = (""" +scons: warning: Two different environments were specified for target file4.out, +\tbut they appear to have the same action: %s +""" % act) + TestSCons.file_expr + +test.run(arguments='file4.out', stderr=expect) + +test.must_match('file4.out', "3\nfile4a.in\nfile4b.in\n") + +test.pass_test() diff --git a/test/Builder/multi/same-targets.py b/test/Builder/multi/same-targets.py new file mode 100644 index 0000000..19efff7 --- /dev/null +++ b/test/Builder/multi/same-targets.py @@ -0,0 +1,57 @@ +#!/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 a "multi" builder can be called multiple times with the same +target list if everything is identical. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +def build(env, target, source): + for t in target: + file = open(str(t), 'wb') + for s in source: + file.write(open(str(s), 'rb').read()) + +B = Builder(action=build, multi=1) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = ['file9a.out', 'file9b.out'], source = 'file9a.in') +env.B(target = ['file9a.out', 'file9b.out'], source = 'file9b.in') +""") + +test.write('file9a.in', 'file9a.in\n') +test.write('file9b.in', 'file9b.in\n') + +test.run(arguments='file9b.out') + +test.must_match('file9a.out', "file9a.in\nfile9b.in\n") +test.must_match('file9b.out', "file9a.in\nfile9b.in\n") + +test.pass_test() diff --git a/test/Builder/non-multi.py b/test/Builder/non-multi.py new file mode 100644 index 0000000..1d5822e --- /dev/null +++ b/test/Builder/non-multi.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 a builder without "multi" set can still be called multiple +times if the calls are the same. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +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()) + +B = Builder(action=build, multi=0) +env = Environment(BUILDERS = { 'B' : B }) +env.B(target = 'file7.out', source = 'file7.in') +env.B(target = 'file7.out', source = 'file7.in') +""") + +test.write('file7.in', 'file7.in\n') + +test.run(arguments='file7.out') + +test.must_match('file7.out', "file7.in\n") + +test.pass_test() diff --git a/test/CC/CFLAGS.py b/test/CC/CFLAGS.py new file mode 100644 index 0000000..f14fcc5 --- /dev/null +++ b/test/CC/CFLAGS.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import sys, string +import TestSCons + +test = TestSCons.TestSCons() + +# Make sure CFLAGS is not passed to CXX by just expanding CXXCOM +test.write('SConstruct', """ +env = Environment(CFLAGS='-xyz', CCFLAGS='-abc') +print env.subst('$CXXCOM') +print env.subst('$CXXCOMSTR') +print env.subst('$SHCXXCOM') +print env.subst('$SHCXXCOMSTR') +""") +test.run(arguments = '.') +test.fail_test(string.find(test.stdout(), "-xyz") != -1) +test.fail_test(string.find(test.stdout(), "-abc") == -1) + + +# Test passing CFLAGS to C compiler by actually compiling programs +if sys.platform == 'win32': + _obj = '.obj' + fooflags = '/nologo -DFOO' + barflags = '/nologo -DBAR' +else: + _obj = '.o' + fooflags = '-DFOO' + barflags = '-DBAR' + + +test.write('SConstruct', """ +foo = Environment(CFLAGS = '%s') +bar = Environment(CFLAGS = '%s') +foo.Object(target = 'foo%s', source = 'prog.c') +bar.Object(target = 'bar%s', source = 'prog.c') +foo.Program(target = 'foo', source = 'foo%s') +bar.Program(target = 'bar', source = 'bar%s') +foo.Program(target = 'prog', source = 'prog.c', + CFLAGS = '$CFLAGS -DBAR $BAZ', BAZ = '-DBAZ') +""" % (fooflags, barflags, _obj, _obj, _obj, _obj)) + +test.write('prog.c', r""" +#include <stdio.h> +#include <stdlib.h> + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; +#ifdef FOO + printf("prog.c: FOO\n"); +#endif +#ifdef BAR + printf("prog.c: BAR\n"); +#endif +#ifdef BAZ + printf("prog.c: BAZ\n"); +#endif + exit (0); +} +""") + + + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('prog'), stdout = """\ +prog.c: FOO +prog.c: BAR +prog.c: BAZ +""") + +test.write('SConstruct', """ +bar = Environment(CFLAGS = '%s') +bar.Object(target = 'foo%s', source = 'prog.c') +bar.Object(target = 'bar%s', source = 'prog.c') +bar.Program(target = 'foo', source = 'foo%s') +bar.Program(target = 'bar', source = 'bar%s') +""" % (barflags, _obj, _obj, _obj, _obj)) + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") + +test.pass_test() diff --git a/test/CC/SHCFLAGS.py b/test/CC/SHCFLAGS.py new file mode 100644 index 0000000..ef20120 --- /dev/null +++ b/test/CC/SHCFLAGS.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import sys +import TestSCons +import os +import string + +test = TestSCons.TestSCons() + +e = test.Environment() +fooflags = e['SHCFLAGS'] + ' -DFOO' +barflags = e['SHCFLAGS'] + ' -DBAR' + +if os.name == 'posix': + os.environ['LD_LIBRARY_PATH'] = '.' +if string.find(sys.platform, 'irix') > -1: + os.environ['LD_LIBRARYN32_PATH'] = '.' + +test.write('SConstruct', """ +foo = Environment(SHCFLAGS = '%s', WINDOWS_INSERT_DEF=1) +bar = Environment(SHCFLAGS = '%s', WINDOWS_INSERT_DEF=1) + +foo_obj = foo.SharedObject(target = 'foo', source = 'prog.c') +foo.SharedLibrary(target = 'foo', source = foo_obj) + +bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c') +bar.SharedLibrary(target = 'bar', source = bar_obj) + +fooMain = foo.Clone(LIBS='foo', LIBPATH='.') +foomain_obj = fooMain.Object(target='foomain', source='main.c') +fooMain.Program(target='fooprog', source=foomain_obj) + +barMain = bar.Clone(LIBS='bar', LIBPATH='.') +barmain_obj = barMain.Object(target='barmain', source='main.c') +barMain.Program(target='barprog', source=barmain_obj) +""" % (fooflags, barflags)) + +test.write('foo.def', r""" +LIBRARY "foo" +DESCRIPTION "Foo Shared Library" + +EXPORTS + doIt +""") + +test.write('bar.def', r""" +LIBRARY "bar" +DESCRIPTION "Bar Shared Library" + +EXPORTS + doIt +""") + +test.write('prog.c', r""" +#include <stdio.h> + +void +doIt() +{ +#ifdef FOO + printf("prog.c: FOO\n"); +#endif +#ifdef BAR + printf("prog.c: BAR\n"); +#endif +} +""") + +test.write('main.c', r""" + +void doIt(); + +int +main(int argc, char* argv[]) +{ + doIt(); + return 0; +} +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('fooprog'), stdout = "prog.c: FOO\n") +test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n") + +test.write('SConstruct', """ +bar = Environment(SHCFLAGS = '%s', WINDOWS_INSERT_DEF=1) + +foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c') +bar.SharedLibrary(target = 'foo', source = foo_obj) + +bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c') +bar.SharedLibrary(target = 'bar', source = bar_obj) + +barMain = bar.Clone(LIBS='bar', LIBPATH='.') +foomain_obj = barMain.Object(target='foomain', source='main.c') +barmain_obj = barMain.Object(target='barmain', source='main.c') +barMain.Program(target='barprog', source=foomain_obj) +barMain.Program(target='fooprog', source=barmain_obj) +""" % (barflags)) + +test.run(arguments = '.') + +test.run(program = test.workpath('fooprog'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n") + +test.pass_test() diff --git a/test/CacheDir/up-to-date-q.py b/test/CacheDir/up-to-date-q.py new file mode 100644 index 0000000..07123c9 --- /dev/null +++ b/test/CacheDir/up-to-date-q.py @@ -0,0 +1,82 @@ +#!/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 targets retrieved from CacheDir() are reported as +up-to-date by the -q option. + +Thanks to dvitek for the test case. +""" + +# Demonstrate a regression between 0.96.1 and 0.96.93. +# +# SCons would incorrectly believe files are stale if they were retrieved +# from the cache in a previous invocation. +# +# What this script does: +# 1. Set up two identical C project directories called 'alpha' and +# 'beta', which use the same cache +# 2. Invoke scons on 'alpha' +# 3. Invoke scons on 'beta', which successfully draws output +# files from the cache +# 4. Invoke scons again, asserting (with -q) that 'beta' is up to date +# +# Step 4 failed in 0.96.93. In practice, this problem would lead to +# lots of unecessary fetches from the cache during incremental +# builds (because they behaved like non-incremental builds). + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('cache', 'alpha', 'beta') + +foo_c = """ +int main(){ return 0; } +""" + +sconstruct = """ +import os +CacheDir('%s') +Program('foo', 'foo.c') +""" % test.workpath('cache') + +test.write('alpha/foo.c', foo_c) +test.write('alpha/SConstruct', sconstruct) + +test.write('beta/foo.c', foo_c) +test.write('beta/SConstruct', sconstruct) + +# First build, populates the cache +test.run(chdir = 'alpha', arguments = '.') + +# Second build, everything is a cache hit +test.run(chdir = 'beta', arguments = '.') + +# Since we just built 'beta', it ought to be up to date. +test.run(chdir = 'beta', arguments = '. -q') + +test.pass_test() diff --git a/test/LEX/LEX.py b/test/LEX/LEX.py index 3fd4db3..91b4614 100644 --- a/test/LEX/LEX.py +++ b/test/LEX/LEX.py @@ -50,89 +50,26 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(LEX = r'%(_python_)s mylex.py', tools=['default', 'lex']) -env.Program(target = 'aaa', source = 'aaa.l') -env.Program(target = 'bbb', source = 'bbb.lex') +env.CFile(target = 'aaa', source = 'aaa.l') +env.CFile(target = 'bbb', source = 'bbb.lex') +env.CXXFile(target = 'ccc', source = 'ccc.ll') +env.CXXFile(target = 'ddd', source = 'ddd.lm') """ % locals()) -test.write('aaa.l', r""" -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("LEX\n"); - printf("aaa.l\n"); - exit (0); -} -""") - -test.write('bbb.lex', r""" -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("LEX\n"); - printf("bbb.lex\n"); - exit (0); -} -""") +test.write('aaa.l', "aaa.l\nLEX\n") +test.write('bbb.lex', "bbb.lex\nLEX\n") +test.write('ccc.ll', "ccc.ll\nLEX\n") +test.write('ddd.lm', "ddd.lm\nLEX\n") test.run(arguments = '.', stderr = None) -test.run(program = test.workpath('aaa' + _exe), stdout = "mylex.py\naaa.l\n") -test.run(program = test.workpath('bbb' + _exe), stdout = "mylex.py\nbbb.lex\n") - - - -lex = test.where_is('lex') - -if lex: - - test.write("wrapper.py", """import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment() -lex = foo.Dictionary('LEX') -bar = Environment(LEX = r'%(_python_)s wrapper.py ' + lex) -foo.Program(target = 'foo', source = 'foo.l') -bar.Program(target = 'bar', source = 'bar.l') -""" % locals()) - - lex = r""" -%%%% -a printf("A%sA"); -b printf("B%sB"); -%%%% -int -yywrap() -{ - return 1; -} - -main() -{ - yylex(); -} -""" - - test.write('foo.l', lex % ('foo.l', 'foo.l')) - - test.write('bar.l', lex % ('bar.l', 'bar.l')) - - test.run(arguments = 'foo' + _exe, stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "Afoo.lA\n") - - test.run(arguments = 'bar' + _exe) +# Read in with mode='r' because mylex.py implicitley wrote to stdout +# with mode='w'. +test.must_match('aaa.c', "aaa.l\nmylex.py\n", mode='r') +test.must_match('bbb.c', "bbb.lex\nmylex.py\n", mode='r') +test.must_match('ccc.cc', "ccc.ll\nmylex.py\n", mode='r') +test.must_match('ddd.m', "ddd.lm\nmylex.py\n", mode='r') - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "Bbar.lB\n") test.pass_test() diff --git a/test/LEX/LEXFLAGS.py b/test/LEX/LEXFLAGS.py index 5923934..b6a06fa 100644 --- a/test/LEX/LEXFLAGS.py +++ b/test/LEX/LEXFLAGS.py @@ -55,68 +55,17 @@ test.write('SConstruct', """ env = Environment(LEX = r'%(_python_)s mylex.py', LEXFLAGS = '-x', tools=['default', 'lex']) -env.Program(target = 'aaa', source = 'aaa.l') +env.CFile(target = 'aaa', source = 'aaa.l') """ % locals()) -test.write('aaa.l', r""" -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("LEXFLAGS\n"); - printf("aaa.l\n"); - exit (0); -} -""") - -test.run(arguments = 'aaa' + _exe, stderr = None) - -test.run(program = test.workpath('aaa' + _exe), stdout = " -x -t\naaa.l\n") - - - -lex = test.where_is('lex') - -if lex: - - test.write('SConstruct', """ -foo = Environment() -bar = Environment(LEXFLAGS = '-b') -foo.Program(target = 'foo', source = 'foo.l') -bar.Program(target = 'bar', source = 'bar.l') -""") - - lex = r""" -%%%% -a printf("A%sA"); -b printf("B%sB"); -%%%% -int -yywrap() -{ - return 1; -} - -main() -{ - yylex(); -} -""" - - test.write('foo.l', lex % ('foo.l', 'foo.l')) - - test.write('bar.l', lex % ('bar.l', 'bar.l')) - - test.run(arguments = 'foo' + _exe, stderr = None) - - test.fail_test(os.path.exists(test.workpath('lex.backup'))) +test.write('aaa.l', "aaa.l\nLEXFLAGS\n") - test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "Afoo.lA\n") +test.run('.', stderr = None) - test.run(arguments = 'bar' + _exe) +# Read in with mode='r' because mylex.py implicitley wrote to stdout +# with mode='w'. +test.must_match('aaa.c', "aaa.l\n -x -t\n", mode='r') - test.fail_test(not os.path.exists(test.workpath('lex.backup'))) - test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "Bbar.lB\n") test.pass_test() diff --git a/test/LEX/live.py b/test/LEX/live.py new file mode 100644 index 0000000..e917039 --- /dev/null +++ b/test/LEX/live.py @@ -0,0 +1,103 @@ +#!/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 LEX and LEXFLAGS with a live lex. +""" + +import string + +import TestSCons + +_exe = TestSCons._exe +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +lex = test.where_is('lex') or test.where_is('flex') + +if not lex: + test.skip_test('No lex or flex found; skipping test.\n') + + + +test.write("wrapper.py", """import os +import string +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment() +lex = foo.Dictionary('LEX') +bar = Environment(LEX = r'%(_python_)s wrapper.py ' + lex, + LEXFLAGS = '-b') +foo.Program(target = 'foo', source = 'foo.l') +bar.Program(target = 'bar', source = 'bar.l') +""" % locals()) + +lex = r""" +%%%% +a printf("A%sA"); +b printf("B%sB"); +%%%% +int +yywrap() +{ + return 1; +} + +main() +{ + yylex(); +} +""" + +test.write('foo.l', lex % ('foo.l', 'foo.l')) + +test.write('bar.l', lex % ('bar.l', 'bar.l')) + +test.run(arguments = 'foo' + _exe, stderr = None) + +test.must_not_exist(test.workpath('wrapper.out')) +test.must_not_exist(test.workpath('lex.backup')) + +test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "Afoo.lA\n") + + + + +test.run(arguments = 'bar' + _exe) + +test.must_match(test.workpath('wrapper.out'), "wrapper.py\n") +test.must_exist(test.workpath('lex.backup')) + +test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "Bbar.lB\n") + + + +test.pass_test() diff --git a/test/TEX/build_dir.py b/test/TEX/build_dir.py index 146f6e1..4967533 100644 --- a/test/TEX/build_dir.py +++ b/test/TEX/build_dir.py @@ -35,13 +35,18 @@ import TestSCons test = TestSCons.TestSCons() +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + test.subdir(['docs']) test.write(['SConstruct'], """\ import os -env = Environment(ENV = { 'PATH' : os.environ['PATH'] }) +env = Environment(ENV = { 'PATH' : os.environ['PATH'] }, + TOOLS = ['tex', 'latex', 'dvipdf']) Export(['env']) SConscript(os.path.join('docs', 'SConscript'), diff --git a/test/TEX/subdir-input.py b/test/TEX/subdir-input.py index b92ab73..d16ba5f 100644 --- a/test/TEX/subdir-input.py +++ b/test/TEX/subdir-input.py @@ -38,11 +38,20 @@ import TestSCons test = TestSCons.TestSCons() +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +pdflatex = test.where_is('pdflatex') +if not pdflatex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + test.subdir('sub') test.write('SConstruct', """\ -PDF( 'sub/x.tex' ) -DVI( 'sub/x.tex' ) +env = Environment(TOOLS = ['tex', 'pdftex']) +env.PDF( 'sub/x.tex' ) +env.DVI( 'sub/x.tex' ) """) test.write(['sub', 'x.tex'], diff --git a/test/YACC/YACC.py b/test/YACC/YACC.py index d3bc679..bef959f 100644 --- a/test/YACC/YACC.py +++ b/test/YACC/YACC.py @@ -65,155 +65,25 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(YACC = r'%(_python_)s myyacc.py', tools=['default', 'yacc']) -env.Program(target = 'aaa', source = 'aaa.y') -env.Program(target = 'bbb', source = 'bbb.yacc') +env.CFile(target = 'aaa', source = 'aaa.y') +env.CFile(target = 'bbb', source = 'bbb.yacc') +env.CXXFile(target = 'ccc', source = 'ccc.yy') +env.CFile(target = 'ddd', source = 'ddd.ym') """ % locals()) -test.write('aaa.y', r""" -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("YACC\n"); - printf("aaa.y\n"); - exit (0); -} -""") - -test.write('bbb.yacc', r""" -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("YACC\n"); - printf("bbb.yacc\n"); - exit (0); -} -""") +test.write('aaa.y', "aaa.y\nYACC\n") +test.write('bbb.yacc', "bbb.yacc\nYACC\n") +test.write('ccc.yy', "ccc.yacc\nYACC\n") +test.write('ddd.ym', "ddd.yacc\nYACC\n") test.run(arguments = '.', stderr = None) -test.run(program = test.workpath('aaa' + _exe), stdout = "myyacc.py\naaa.y\n") -test.run(program = test.workpath('bbb' + _exe), stdout = "myyacc.py\nbbb.yacc\n") - - - -yacc = test.where_is('yacc') - -if yacc: - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(YACCFLAGS='-d') -yacc = foo.Dictionary('YACC') -bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc) -foo.Program(target = 'foo', source = 'foo.y') -bar.Program(target = 'bar', source = 'bar.y') -foo.Program(target = 'hello', source = ['hello.cpp']) -foo.CXXFile(target = 'file.cpp', source = ['file.yy'], YACCFLAGS='-d') -foo.CFile(target = 'not_foo', source = 'foo.y') -""" % locals()) - - yacc = r""" -%%{ -#include <stdio.h> - -main() -{ - yyparse(); -} - -yyerror(s) -char *s; -{ - fprintf(stderr, "%%s\n", s); - return 0; -} - -yylex() -{ - int c; - - c = fgetc(stdin); - return (c == EOF) ? 0 : c; -} -%%} -%%%% -input: letter newline { printf("%s\n"); }; -letter: 'a' | 'b'; -newline: '\n'; -""" - - test.write("file.yy", """\ -%token GRAPH_T NODE_T EDGE_T DIGRAPH_T EDGEOP_T SUBGRAPH_T - -%pure_parser - -%% -graph: GRAPH_T - ; - -%% -""") - - test.write("hello.cpp", """\ -#include "file.hpp" - -int main() -{ -} -""") - - test.write('foo.y', yacc % 'foo.y') - - test.write('bar.y', yacc % 'bar.y') - - # Build the foo program - test.run(arguments = 'foo' + _exe, stderr = None) - - test.up_to_date(arguments = 'foo' + _exe) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "foo.y\n") - - test.fail_test(not os.path.exists(test.workpath('foo.h'))) - - test.run(arguments = '-c .') - - test.fail_test(os.path.exists(test.workpath('foo.h'))) - - # - test.run(arguments = 'not_foo.c') - - test.up_to_date(arguments = 'not_foo.c') - - test.fail_test(os.path.exists(test.workpath('foo.h'))) - test.fail_test(not os.path.exists(test.workpath('not_foo.h'))) - - test.run(arguments = '-c .') - - test.fail_test(os.path.exists(test.workpath('not_foo.h'))) - - # - test.run(arguments = 'bar' + _exe) - - test.up_to_date(arguments = 'bar' + _exe) - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('aaa.c', "aaa.y\nmyyacc.py\n") +test.must_match('bbb.c', "bbb.yacc\nmyyacc.py\n") +test.must_match('ccc.cc', "ccc.yacc\nmyyacc.py\n") +test.must_match('ddd.m', "ddd.yacc\nmyyacc.py\n") - test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "bar.y\n") - # - test.run(arguments = '.') - test.up_to_date(arguments = '.') test.pass_test() diff --git a/test/YACC/YACCFLAGS.py b/test/YACC/YACCFLAGS.py index a94bc8f..b7e2167 100644 --- a/test/YACC/YACCFLAGS.py +++ b/test/YACC/YACCFLAGS.py @@ -65,83 +65,15 @@ test.write('SConstruct', """ env = Environment(YACC = r'%(_python_)s myyacc.py', YACCFLAGS = '-x', tools=['yacc', '%(linker)s', '%(compiler)s']) -env.Program(target = 'aaa', source = 'aaa.y') +env.CFile(target = 'aaa', source = 'aaa.y') """ % locals()) -test.write('aaa.y', r""" -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("YACCFLAGS\n"); - printf("aaa.y\n"); - exit (0); -} -""") - -test.run(arguments = 'aaa' + _exe, stderr = None) - -test.run(program = test.workpath('aaa' + _exe), stdout = " -x\naaa.y\n") - - - -yacc = test.where_is('yacc') - -if yacc: - - test.write('SConstruct', """ -foo = Environment() -bar = Environment(YACCFLAGS = '-v') -foo.Program(target = 'foo', source = 'foo.y') -bar.Program(target = 'bar', source = 'bar.y') -""") - - yacc = r""" -%%{ -#include <stdio.h> - -main() -{ - yyparse(); -} - -yyerror(s) -char *s; -{ - fprintf(stderr, "%%s\n", s); - return 0; -} - -yylex() -{ - int c; - - c = fgetc(stdin); - return (c == EOF) ? 0 : c; -} -%%} -%%%% -input: letter newline { printf("%s\n"); }; -letter: 'a' | 'b'; -newline: '\n'; -""" - - test.write('foo.y', yacc % 'foo.y') - - test.write('bar.y', yacc % 'bar.y') - - test.run(arguments = 'foo' + _exe, stderr = None) - - test.fail_test(os.path.exists(test.workpath('foo.output')) - or os.path.exists(test.workpath('y.output'))) +test.write('aaa.y', "aaa.y\nYACCFLAGS\n") - test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "foo.y\n") +test.run('.', stderr = None) - test.run(arguments = 'bar' + _exe) +test.must_match('aaa.c', "aaa.y\n -x\n") - test.fail_test(not os.path.exists(test.workpath('bar.output')) - and not os.path.exists(test.workpath('y.output'))) - test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "bar.y\n") test.pass_test() diff --git a/test/YACC/YACCVCGFILESUFFIX.py b/test/YACC/YACCVCGFILESUFFIX.py new file mode 100644 index 0000000..b05471a --- /dev/null +++ b/test/YACC/YACCVCGFILESUFFIX.py @@ -0,0 +1,87 @@ +#!/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 setting the YACCVCGFILESUFFIX variable. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('myyacc.py', """\ +import getopt +import os.path +import string +import sys +vcg = None +opts, args = getopt.getopt(sys.argv[1:], 'go:') +for o, a in opts: + if o == '-g': + vcg = 1 + elif o == '-o': + outfile = open(a, 'wb') +for f in args: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*yacc*/\\n', infile.readlines()): + outfile.write(l) +outfile.close() +if vcg: + base, ext = os.path.splitext(args[0]) + open(base+'.vcgsuffix', 'wb').write(string.join(sys.argv)+'\\n') +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'yacc'], + YACC = r'%(_python_)s myyacc.py', + YACCVCGFILESUFFIX = '.vcgsuffix') +env.CXXFile(target = 'aaa', source = 'aaa.yy') +env.CXXFile(target = 'bbb', source = 'bbb.yy', YACCFLAGS = '-g') +""" % locals()) + +test.write('aaa.yy', "aaa.yy\n/*yacc*/\n") +test.write('bbb.yy', "bbb.yy\n/*yacc*/\n") + +test.run(arguments = '.') + +test.must_match('aaa.cc', "aaa.yy\n") +test.must_not_exist('aaa.vcg') +test.must_not_exist('aaa.vcgsuffix') + +test.must_match('bbb.cc', "bbb.yy\n") +test.must_not_exist('bbb.vcg') +test.must_match('bbb.vcgsuffix', "myyacc.py -g -o bbb.cc bbb.yy\n") + +test.up_to_date(arguments = '.') + + + +test.pass_test() diff --git a/test/YACC/live.py b/test/YACC/live.py new file mode 100644 index 0000000..4934570 --- /dev/null +++ b/test/YACC/live.py @@ -0,0 +1,165 @@ +#!/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 YACC and YACCFLAGS with a live yacc compiler. +""" + +import string + +import TestSCons + +_exe = TestSCons._exe +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +yacc = test.where_is('yacc') or test.where_is('bison') + +if not yacc: + test.skip_test('No yacc or bison found; skipping test.\n') + +test.write("wrapper.py", +"""import os +import string +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment(YACCFLAGS='-d') +yacc = foo.Dictionary('YACC') +bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc) +foo.Program(target = 'foo', source = 'foo.y') +bar.Program(target = 'bar', source = 'bar.y') +foo.Program(target = 'hello', source = ['hello.cpp']) +foo.CXXFile(target = 'file.cpp', source = ['file.yy'], YACCFLAGS='-d') +foo.CFile(target = 'not_foo', source = 'foo.y') +""" % locals()) + +yacc = r""" +%%{ +#include <stdio.h> + +main() +{ + yyparse(); +} + +yyerror(s) +char *s; +{ + fprintf(stderr, "%%s\n", s); + return 0; +} + +yylex() +{ + int c; + + c = fgetc(stdin); + return (c == EOF) ? 0 : c; +} +%%} +%%%% +input: letter newline { printf("%s\n"); }; +letter: 'a' | 'b'; +newline: '\n'; +""" + +test.write("file.yy", """\ +%token GRAPH_T NODE_T EDGE_T DIGRAPH_T EDGEOP_T SUBGRAPH_T + +%pure_parser + +%% +graph: GRAPH_T + ; + +%% +""") + +test.write("hello.cpp", """\ +#include "file.hpp" + +int main() +{ +} +""") + +test.write('foo.y', yacc % 'foo.y') + +test.write('bar.y', yacc % 'bar.y') + + + +test.run(arguments = 'foo' + _exe, stderr = None) + +test.up_to_date(arguments = 'foo' + _exe) + +test.must_not_exist(test.workpath('wrapper.out')) + +test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "foo.y\n") + +test.must_exist(test.workpath('foo.h')) + +test.run(arguments = '-c .') + +test.must_not_exist(test.workpath('foo.h')) + + + +test.run(arguments = 'not_foo.c') + +test.up_to_date(arguments = 'not_foo.c') + +test.must_not_exist(test.workpath('foo.h')) +test.must_exist(test.workpath('not_foo.h')) + +test.run(arguments = '-c .') + +test.must_not_exist(test.workpath('not_foo.h')) + + + +test.run(arguments = 'bar' + _exe) + +test.up_to_date(arguments = 'bar' + _exe) + +test.must_match(test.workpath('wrapper.out'), "wrapper.py\n") + +test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "bar.y\n") + + + +test.run(arguments = '.') + +test.up_to_date(arguments = '.') + + + +test.pass_test() diff --git a/test/ignore-command.py b/test/ignore-command.py index d4de8d3..c1e6149 100644 --- a/test/ignore-command.py +++ b/test/ignore-command.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation +# __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,7 +26,7 @@ Test use of a preceding - to ignore the return value from a command. """ -__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/test/option-n.py 0.96.C352 2005/03/26 00:09:23 knight" +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import os.path diff --git a/test/multi.py b/test/multi.py deleted file mode 100644 index 8bcb1f7..0000000 --- a/test/multi.py +++ /dev/null @@ -1,418 +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 various cases where a target is "built" by multiple builder calls. -""" - -import os.path -import string - -import TestCmd -import TestSCons - -test = TestSCons.TestSCons(match=TestCmd.match_re) - -_python_ = TestSCons._python_ - -# -# A builder with "multi" set can be called multiple times and -# the source files are added to the list. -# - -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()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = 'file1.out', source = 'file1a.in') -env.B(target = 'file1.out', source = 'file1b.in') -""") - -test.write('file1a.in', 'file1a.in\n') -test.write('file1b.in', 'file1b.in\n') - -test.run(arguments='file1.out') - -test.must_match('file1.out', "file1a.in\nfile1b.in\n") - - -# -# A builder with "multi" not set generates an error on the second call. -# - -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()) - -B = Builder(action=build, multi=0) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = 'file2.out', source = 'file2a.in') -env.B(target = 'file2.out', source = 'file2b.in') -""") - -test.write('file2a.in', 'file2a.in\n') -test.write('file2b.in', 'file2b.in\n') - -test.run(arguments='file2.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Multiple ways to build the same target were specified for: file2.out (from ['file2a.in'] and from ['file2b.in']) -""") + TestSCons.file_expr) - - -# -# A warning is generated if the calls have different overrides but the -# overrides don't appear to affect the build operation. -# - -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()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = 'file3.out', source = 'file3a.in', foo=1) -env.B(target = 'file3.out', source = 'file3b.in', foo=2) -""") - -test.write('file3a.in', 'file3a.in\n') -test.write('file3b.in', 'file3b.in\n') - -test.run(arguments='file3.out', - stderr=TestSCons.re_escape(""" -scons: warning: Two different environments were specified for target file3.out, -\tbut they appear to have the same action: build(target, source, env) -""") + TestSCons.file_expr) - -# -# A warning is generated if the calls have different overrides but the -# overrides don't appear to affect the build operation. -# - -test.write('build.py',r"""#!/usr/bin/env python -import sys -def build(num, target, source): - file = open(str(target), 'wb') - file.write('%s\n'%num) - for s in source: - file.write(open(str(s), 'rb').read()) -build(sys.argv[1],sys.argv[2],sys.argv[3:]) -""") - -test.write('SConstruct', """ - -B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = 'file03.out', source = 'file03a.in', foo=1) -env.B(target = 'file03.out', source = 'file03b.in', foo=2) -""" % locals()) - -test.write('file03a.in', 'file03a.in\n') -test.write('file03b.in', 'file03b.in\n') - -test.run(arguments='file03.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Two environments with different actions were specified for the same target: file03.out -""") + TestSCons.file_expr) - -# -# Everything works if the two calls have the same overrides. -# - -test.write('build.py',r"""#!/usr/bin/env python -import sys -def build(num, target, source): - file = open(str(target), 'wb') - file.write('%s\n'%num) - for s in source: - file.write(open(str(s), 'rb').read()) -build(sys.argv[1],sys.argv[2],sys.argv[3:]) -""") - -test.write('SConstruct', """ - -B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = 'file4.out', source = 'file4a.in', foo=3) -env.B(target = 'file4.out', source = 'file4b.in', foo=3) -""" % locals()) - -test.write('file4a.in', 'file4a.in\n') -test.write('file4b.in', 'file4b.in\n') - -python_expr = string.replace(TestSCons.python, '\\', '\\\\') -act = TestSCons.re_escape('"%s" build.py \$foo \$TARGET \$SOURCES' % python_expr) - -test.run(arguments='file4.out', - stderr=(""" -scons: warning: Two different environments were specified for target file4.out, -\tbut they appear to have the same action: %s -""" % act) + TestSCons.file_expr) - -test.must_match('file4.out', "3\nfile4a.in\nfile4b.in\n") - - -# -# Two different environments can be used for the same target, so long -# as the actions have the same signature; a warning is generated. -# - -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()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env2 = env.Clone(DIFFERENT_VARIABLE = 'true') -env.B(target = 'file5.out', source = 'file5a.in') -env2.B(target = 'file5.out', source = 'file5b.in') -""") - -test.write('file5a.in', 'file5a.in\n') -test.write('file5b.in', 'file5b.in\n') - -test.run(arguments='file5.out', - stderr=TestSCons.re_escape(""" -scons: warning: Two different environments were specified for target file5.out, -\tbut they appear to have the same action: build(target, source, env) -""") + TestSCons.file_expr) - -test.must_match('file5.out', "file5a.in\nfile5b.in\n") - - -# -# Environments with actions that have different signatures generate -# an error. -# - -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()) - -B = Builder(action=Action(build, varlist=['XXX']), multi=1) -env = Environment(BUILDERS = { 'B' : B }, XXX = 'foo') -env2 = env.Clone(XXX = 'var') -env.B(target = 'file6.out', source = 'file6a.in') -env2.B(target = 'file6.out', source = 'file6b.in') -""") - -test.write('file6a.in', 'file6a.in\n') -test.write('file6b.in', 'file6b.in\n') - -test.run(arguments='file6.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Two environments with different actions were specified for the same target: file6.out -""") + TestSCons.file_expr) - - -# -# A builder without "multi" set can still be called multiple times -# if the calls are the same. -# - -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()) - -B = Builder(action=build, multi=0) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = 'file7.out', source = 'file7.in') -env.B(target = 'file7.out', source = 'file7.in') -""") - -test.write('file7.in', 'file7.in\n') - -test.run(arguments='file7.out') - -test.must_match('file7.out', "file7.in\n") - - -# -# Trying to call a target with two different "multi" builders -# generates an error. -# - -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()) - -def build2(env, target, source): - build(env, target, source) - -B = Builder(action=build, multi=1) -C = Builder(action=build2, multi=1) -env = Environment(BUILDERS = { 'B' : B, 'C' : C }) -env.B(target = 'file8.out', source = 'file8.in') -env.C(target = 'file8.out', source = 'file8.in') -""") - -test.write('file8a.in', 'file8a.in\n') -test.write('file8b.in', 'file8b.in\n') - -test.run(arguments='file8.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Two different builders (B and C) were specified for the same target: file8.out -""") + TestSCons.file_expr) - - -# -# A "multi" builder can be called multiple times with the same target list -# if everything is identical. -# - -test.write('SConstruct', """ -def build(env, target, source): - for t in target: - file = open(str(t), 'wb') - for s in source: - file.write(open(str(s), 'rb').read()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = ['file9a.out', 'file9b.out'], source = 'file9a.in') -env.B(target = ['file9a.out', 'file9b.out'], source = 'file9b.in') -""") - -test.write('file9a.in', 'file9a.in\n') -test.write('file9b.in', 'file9b.in\n') - -test.run(arguments='file9b.out') - -test.must_match('file9a.out', "file9a.in\nfile9b.in\n") -test.must_match('file9b.out', "file9a.in\nfile9b.in\n") - - -# -# A "multi" builder can NOT be called multiple times with target lists -# that have different orders. This is intentional; the order of the -# targets matter to the builder because the build command can contain -# things like ${TARGET[0]}. -# - -test.write('SConstruct', """ -def build(env, target, source): - for t in target: - file = open(str(target[0]), 'wb') - for s in source: - file.write(open(str(s), 'rb').read()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = ['file10a.out', 'file10b.out'], source = 'file10.in') -env.B(target = ['file10b.out', 'file10a.out'], source = 'file10.in') -""") - -test.write('file10.in', 'file10.in\n') - -test.run(arguments='file10.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Two different target sets have a target in common: file10b.out -""") + TestSCons.file_expr) - - -# -# A target file can't be in two different target lists. -# - -# XXX It would be nice if the following two tests could be made to work -# by executing the action once for each unique set of targets. This -# would make it simple to deal with PDB files on Windows like so: -# -# env.Object(['foo.obj', 'vc60.pdb'], 'foo.c') -# env.Object(['bar.obj', 'vc60.pdb'], 'bar.c') - -test.write('SConstruct', """ -def build(env, target, source): - for t in target: - file = open(str(target[0]), 'wb') - for s in source: - file.write(open(str(s), 'rb').read()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = ['file11a.out', 'file11b.out'], source = 'file11a.in') -env.B(target = ['file11b.out', 'file11c.out'], source = 'file11b.in') -""") - -test.write('file11a.in', 'file11a.in\n') -test.write('file11b.in', 'file11b.in\n') - -test.run(arguments='file11.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Two different target sets have a target in common: file11b.out -""") + TestSCons.file_expr) - - -# -# A target file can't be a lone target and in a list. -# - -test.write('SConstruct', """ -def build(env, target, source): - for t in target: - file = open(str(target[0]), 'wb') - for s in source: - file.write(open(str(s), 'rb').read()) - -B = Builder(action=build, multi=1) -env = Environment(BUILDERS = { 'B' : B }) -env.B(target = ['file12a.out', 'file12b.out'], source = 'file12a.in') -env.B(target = 'file12a.out', source = 'file12b.in') -""") - -test.write('file12a.in', 'file12a.in\n') -test.write('file12b.in', 'file12b.in\n') - -test.run(arguments='file12.out', - status=2, - stderr=TestSCons.re_escape(""" -scons: *** Cannot build same target `file12a.out' as singular and list -""") + TestSCons.file_expr) - - - -test.pass_test() diff --git a/test/option-v.py b/test/option-v.py index 0626106..55278ab 100644 --- a/test/option-v.py +++ b/test/option-v.py @@ -38,7 +38,7 @@ test.write('SConstruct', "") # by the packaging build. copyright_marker = '__' + 'COPYRIGHT' + '__' -copyright_years = '2001, 2002, 2003, 2004, 2005, 2006' +copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007' fmt = '(%s|Copyright \\(c\\) %s The SCons Foundation)\n' diff --git a/test/silent-command.py b/test/silent-command.py index 91880bd..476158a 100644 --- a/test/silent-command.py +++ b/test/silent-command.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation +# __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,7 +26,7 @@ Test the use of a preceding @ to suppress printing a command. """ -__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/test/option-n.py 0.96.C352 2005/03/26 00:09:23 knight" +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import os.path diff --git a/test/timestamp-fallback.py b/test/timestamp-fallback.py index 288f8d8..7576023 100644 --- a/test/timestamp-fallback.py +++ b/test/timestamp-fallback.py @@ -49,10 +49,11 @@ raise ImportError os.environ['PYTHONPATH'] = test.workpath('.') test.write('SConstruct', """ +DefaultEnvironment(tools=[]) def build(env, target, source): open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read()) B = Builder(action = build) -env = Environment(BUILDERS = { 'B' : B }) +env = Environment(tools = [], BUILDERS = { 'B' : B }) env.B(target = 'f1.out', source = 'f1.in') env.B(target = 'f2.out', source = 'f2.in') env.B(target = 'f3.out', source = 'f3.in') |