summaryrefslogtreecommitdiff
path: root/test/Scanner
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2008-04-30 05:39:46 +0000
committerSteven Knight <knight@baldmt.com>2008-04-30 05:39:46 +0000
commitd5061a1effee5927efc7a6acd55443fa00218a78 (patch)
treef3178f3f085f178e22d840046acc862e23422870 /test/Scanner
parent1a10d4bc650741b2e279321ad32948ecba127c1c (diff)
downloadscons-d5061a1effee5927efc7a6acd55443fa00218a78.tar.gz
Merged revisions 2898-2901,2903-2927 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r2903 | stevenknight | 2008-04-22 08:23:52 -0700 (Tue, 22 Apr 2008) | 3 lines Issue 2019: don't blow up when a "dictionary" source_scanner doesn't have a more-specific scanner entry for a specified source file's suffix. ........ r2904 | stevenknight | 2008-04-23 11:13:19 -0700 (Wed, 23 Apr 2008) | 3 lines Fix regression in use of $CXXFLAGS by the default $SHCXXFLAGS setting. (Greg Noel) ........ r2905 | stevenknight | 2008-04-23 11:23:12 -0700 (Wed, 23 Apr 2008) | 3 lines Update the test/CXX/SHCXXFLAGS.py with some more modern idioms copied from test/CXX/CXXFLAGS.py. ........ r2921 | belley | 2008-04-28 08:52:13 -0700 (Mon, 28 Apr 2008) | 98 lines Candidate list must be flushed when stopping the taskmaster. ============================================================ The taskmaster's candidate list must be flushed when the taskmaster is stopped, either because of a build error or a keyboard interrupt. This involves failing each candidates along with their waiting parents. This is necessary because the waiting parents might be in the pending_children set() that is used by the taskmaster to determine if cycles exist in the dependency graph. Failure to do so leads to confusing error messages such as: scons: *** Found dependency cycle(s): Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/DynamicProperty.h (<SCons.Node.FS.File instance at 0x95d230c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/NotSupported.h (<SCons.Node.FS.File instance at 0x960634c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/InvalidRequest.h (<SCons.Node.FS.File instance at 0x95d2bac>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/RequestCanceled.h (<SCons.Node.FS.File instance at 0x960648c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/InvalidType.h (<SCons.Node.FS.File instance at 0x95d2cec>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Core/InvalidProperty.h (<SCons.Node.FS.File instance at 0x9606d2c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/SecurityError.h (<SCons.Node.FS.File instance at 0x96065cc>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Core/PropertyCollector.h (<SCons.Node.FS.File instance at 0x9606e6c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/InvalidArgument.h (<SCons.Node.FS.File instance at 0x95d2a6c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/DynamicData.h (<SCons.Node.FS.File instance at 0x95d21cc>) Changes made: Job.py: ------ o Implemented an InterruptState object that allows the sharing of the interrupt state between the Jobs, the Serial/Parallel and the Worker thread object. This allows for somewhat faster interruption when Ctrl-C is pressed because the Worker thread will not start any new task, i.e. the ones siting in the request queue. Taskmaster.py: -------------- o Moved the code contained the function Task.fail_continue() to the function Taskmaster.will_not_build(). This function perform the clean-up for nodes that will never be built. This includes failing these nodes along with their waiting parents and removing them from the list of pending children. o Improved the taskmaster tracing so that the pending children ref counts of nodes is also printed. o When stopping the taskmaster, no_next_candidate() now calls will_not_build() repetitively to make sure that all candidate nodes that will never be build are properly cleaned-up. test/Parallel/multiple-parents.py --------------------------------- Improved the test to also exercise the following functionality: o Nodes with multiple targets (not just aliases as it was before). o SideEffect() o Interrupting the build. Submitted against changeset 2920. All tests pass with both Python 2.5.1 and 1.5.2 Benoit ........ r2922 | stevenknight | 2008-04-28 11:50:10 -0700 (Mon, 28 Apr 2008) | 26 lines Issue 2024: http://scons.tigris.org/issues/show_bug.cgi?id=2024 Some public packages were importing specific SCons.Options.*Option submodules directly, instead of using the SCons.Options package itself (which actually exposed all the SCons.Options.*Option variable names directly, but what they hey). Our scripts didn't test for direct importing of the submodules, so this broke when I implemented backwards comptability with a SCons/Options.py module, instead of a full SCons/Options/*.py package. This restores the SCons/Options/*.py package files with stub modules that provide backwards compatibility (by referring to the new SCons.Variables functions and classes) and allow for importing all of The test/Deprecated/Options/*Option.py scripts have had specific submodule imports added. To make sure this corresponding "feature" continues to work in the future, I'll be following this with another checkin that adds submodule imports for the SCons.Variables.*Variable modules. I ran this with the SCons/Options.py file in place, and also with a compiled SCons/Options.pyc file in place, to try to make sure it works regardless. We've seen issues on Debian where their packaging doesn't clean up old *.pyc files when a Python *.py module is removed. It looks like this should work regardless of whether the Options.pyc file is there or not. ........ r2923 | stevenknight | 2008-04-28 11:52:52 -0700 (Mon, 28 Apr 2008) | 3 lines Update the test/Variables/*Variable.py scripts to verify that importing SCons.Variables.*Variable submodules continues to work in the future. ........ r2924 | belley | 2008-04-28 14:06:54 -0700 (Mon, 28 Apr 2008) | 6 lines Fixed a test that my morning change broke. The taskmaster tracing now includes the pending children ref count. Benoit ........ r2925 | stevenknight | 2008-04-28 18:00:25 -0700 (Mon, 28 Apr 2008) | 4 lines Issue 2028: Make sure already-existing Entry Nodes that we find are converted to Dir Nodes when searching a *PATH list for implicit dependencies. ........ r2926 | stevenknight | 2008-04-29 08:11:40 -0700 (Tue, 29 Apr 2008) | 3 lines Issue 2034: Fix $FORTRANMODDIR values like ${TARGET.dir} in the default $_FORTANMODFLAG expansion. (Stefano) ........ r2927 | stevenknight | 2008-04-29 11:34:02 -0700 (Tue, 29 Apr 2008) | 3 lines Restore the SCons.Options package (maintains backwards compatibility of importing submodules) to setup.py. ........
Diffstat (limited to 'test/Scanner')
-rw-r--r--test/Scanner/Entry-to-Dir.py59
-rw-r--r--test/Scanner/source_scanner-dict.py218
2 files changed, 277 insertions, 0 deletions
diff --git a/test/Scanner/Entry-to-Dir.py b/test/Scanner/Entry-to-Dir.py
new file mode 100644
index 00000000..0b5dbd71
--- /dev/null
+++ b/test/Scanner/Entry-to-Dir.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 an implicit dependency search for a directory for which
+we have an Entry Node works as expected, converting the Entry into a
+Dir Node.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment()
+tc = env.Program('testcase', 'testcase.cpp')
+foo = env.Entry('foo')
+tc[0].all_children()[0].all_children()
+""")
+
+test.write('testcase.cpp', """\
+#if 0
+#include "foo/bar/widget.h"
+#endif
+int main(int argc, char *argv[])
+{
+ return 0;
+}
+""")
+
+test.run(arguments = '.')
+
+# In 0.98.2, re-running failed with a stack trace.
+test.run(arguments = '.')
+
+test.pass_test()
diff --git a/test/Scanner/source_scanner-dict.py b/test/Scanner/source_scanner-dict.py
new file mode 100644
index 00000000..1ac15a82
--- /dev/null
+++ b/test/Scanner/source_scanner-dict.py
@@ -0,0 +1,218 @@
+#!/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 source_scanner that uses a dictionary to select more
+specific scanners for source file suffixes works correctly, even
+when it's handed a file suffix that it doesn't know how to scan
+(i.e., for which it doesn't have a specific scanner in its dictionary).
+"""
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.write('build.py', r"""
+import sys
+output = open(sys.argv[1], 'wb')
+for infile in sys.argv[2:]:
+ input = open(infile, 'rb')
+
+ include_prefix = 'include%s ' % infile[-1]
+
+ def process(infp, outfp, include_prefix=include_prefix):
+ for line in infp.readlines():
+ if line[:len(include_prefix)] == include_prefix:
+ file = line[len(include_prefix):-1]
+ process(open(file, 'rb'), outfp)
+ else:
+ outfp.write(line)
+
+ process(input, output)
+
+sys.exit(0)
+""")
+
+# Execute a subsidiary SConscript just to make sure we can
+# get at the Scanner keyword from there.
+
+test.write('SConstruct', """
+SConscript('SConscript')
+""")
+
+test.write('SConscript', """
+import re
+
+include1_re = re.compile(r'^include1\s+(\S+)$', re.M)
+include2_re = re.compile(r'^include2\s+(\S+)$', re.M)
+include3_re = re.compile(r'^include3\s+(\S+)$', re.M)
+
+def k1_scan(node, env, scanpaths, arg=None):
+ contents = node.get_contents()
+ includes = include1_re.findall(contents)
+ return includes
+
+def k2_scan(node, env, scanpaths, arg=None):
+ contents = node.get_contents()
+ includes = include2_re.findall(contents)
+ return includes
+
+def k3_scan(node, env, scanpaths, arg=None):
+ contents = node.get_contents()
+ includes = include3_re.findall(contents)
+ return includes
+
+kscanner = Scanner({'.k1' : Scanner(k1_scan), '.k2': Scanner(k2_scan)})
+
+b = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES',
+ source_scanner=kscanner)
+env = Environment(BUILDERS={'Build':b})
+
+kscanner.add_scanner('.k3', Scanner(k3_scan))
+
+env.Build('aaa', 'aaa.k1')
+env.Build('bbb', 'bbb.k2')
+env.Build('ccc', 'ccc.k3')
+env.Build('ddd', ['ddd.k4', 'aaa.k1', 'bbb.k2', 'ccc.k3'])
+""" % locals())
+
+test.write('aaa.k1',
+"""aaa.k1 1
+line 2
+include1 xxx
+include2 yyy
+include3 zzz
+line 6
+""")
+
+test.write('bbb.k2',
+"""bbb.k2 1
+line 2
+include1 xxx
+include2 yyy
+include3 zzz
+line 6
+""")
+
+test.write('ccc.k3',
+"""ccc.k3 1
+line 2
+include1 xxx
+include2 yyy
+include3 zzz
+line 6
+""")
+
+test.write('ddd.k4',
+"""ddd.k4 1
+line 2
+line 3
+""")
+
+test.write('xxx', "xxx 1\n")
+test.write('yyy', "yyy 1\n")
+test.write('zzz', "zzz 1\n")
+
+
+
+
+expect = test.wrap_stdout("""\
+%(_python_)s build.py aaa aaa.k1
+%(_python_)s build.py bbb bbb.k2
+%(_python_)s build.py ccc ccc.k3
+%(_python_)s build.py ddd ddd.k4 aaa.k1 bbb.k2 ccc.k3
+""" % locals())
+
+test.run(stdout=expect)
+
+expect_aaa = 'aaa.k1 1\nline 2\nxxx 1\ninclude2 yyy\ninclude3 zzz\nline 6\n'
+expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 1\ninclude3 zzz\nline 6\n'
+expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 1\nline 6\n'
+expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc
+
+test.must_match('aaa', expect_aaa)
+test.must_match('bbb', expect_bbb)
+test.must_match('ccc', expect_ccc)
+test.must_match('ddd', expect_ddd)
+
+test.up_to_date(arguments = '.')
+
+
+
+test.write('zzz', "zzz 2\n")
+
+expect = test.wrap_stdout("""\
+%(_python_)s build.py ccc ccc.k3
+%(_python_)s build.py ddd ddd.k4 aaa.k1 bbb.k2 ccc.k3
+""" % locals())
+
+test.run(stdout=expect)
+
+expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 2\nline 6\n'
+expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc
+
+test.must_match('bbb', expect_bbb)
+test.must_match('ddd', expect_ddd)
+
+
+
+test.write('yyy', "yyy 2\n")
+
+expect = test.wrap_stdout("""\
+%(_python_)s build.py bbb bbb.k2
+%(_python_)s build.py ddd ddd.k4 aaa.k1 bbb.k2 ccc.k3
+""" % locals())
+
+test.run(stdout=expect)
+
+expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 2\ninclude3 zzz\nline 6\n'
+expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc
+
+test.must_match('bbb', expect_bbb)
+test.must_match('ddd', expect_ddd)
+
+
+
+test.write('xxx', "xxx 2\n")
+
+expect = test.wrap_stdout("""\
+%(_python_)s build.py aaa aaa.k1
+%(_python_)s build.py ddd ddd.k4 aaa.k1 bbb.k2 ccc.k3
+""" % locals())
+
+test.run(stdout=expect)
+
+expect_aaa = 'aaa.k1 1\nline 2\nxxx 2\ninclude2 yyy\ninclude3 zzz\nline 6\n'
+expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc
+
+test.must_match('aaa', expect_aaa)
+test.must_match('ddd', expect_ddd)
+
+
+
+test.pass_test()