summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-09-15 01:45:17 (GMT)
committerSteven Knight <knight@baldmt.com>2002-09-15 01:45:17 (GMT)
commitb04744713085a486615cbef5f489dc522988fb36 (patch)
tree2bac76ddc5252e4e37c6f5df0738278d1b2aa6d5 /test
parent37d6dd7bf93de0e1cbd5382cd7687ff5294183ec (diff)
downloadSCons-b04744713085a486615cbef5f489dc522988fb36.zip
SCons-b04744713085a486615cbef5f489dc522988fb36.tar.gz
SCons-b04744713085a486615cbef5f489dc522988fb36.tar.bz2
Provide a Scanner hook to allow file scans to be avoided when it isn't necessary.
Diffstat (limited to 'test')
-rw-r--r--test/scan-once.py94
1 files changed, 94 insertions, 0 deletions
diff --git a/test/scan-once.py b/test/scan-once.py
new file mode 100644
index 0000000..76c3451
--- /dev/null
+++ b/test/scan-once.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# 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 TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', r"""
+import os.path
+
+def scan(node, env, target, arg):
+ print 'scanning',node,'for',target
+ return []
+
+def exists_check(node):
+ return os.path.exists(str(node))
+
+PScanner = Scanner(name = 'PScanner',
+ function = scan,
+ argument = None,
+ scan_check = exists_check,
+ skeys = ['.s'])
+
+def echo(env, target, source):
+ print 'create %s from %s' % (str(target[0]), str(source[0]))
+
+Echo = Builder(action = echo,
+ src_suffix = '.s',
+ suffix = '.s')
+
+env = Environment(BUILDERS = {'Echo':Echo}, SCANNERS = [PScanner])
+
+f1 = env.Echo(source=['file1'], target=['file2'])
+f2 = env.Echo(source=['file2'], target=['file3'])
+f3 = env.Echo(source=['file3'], target=['file4'])
+
+Default(f3)
+""")
+
+test.run(arguments = '.', stdout = """create file2.s from file1.s
+create file3.s from file2.s
+create file4.s from file3.s
+""")
+
+test.write('file1.s', 'file1.s\n')
+
+test.run(arguments = '.', stdout = """scanning file1.s for file2.s
+create file2.s from file1.s
+scanning file1.s for file2.s
+create file3.s from file2.s
+create file4.s from file3.s
+""")
+
+test.write('file2.s', 'file2.s\n')
+
+test.run(arguments = '.', stdout = """scanning file1.s for file2.s
+scanning file2.s for file3.s
+create file3.s from file2.s
+scanning file2.s for file3.s
+create file4.s from file3.s
+""")
+
+test.write('file3.s', 'file3.s\n')
+
+test.run(arguments = '.', stdout = """scanning file1.s for file2.s
+scanning file2.s for file3.s
+scanning file3.s for file4.s
+create file4.s from file3.s
+""")
+
+test.pass_test()