5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify that use of a Scanner that searches a *PATH list doesn't create
29 nodes for directories that don't exist, so they don't get picked up
32 Under the covers, this tests the behavior of the SCons.Node.FS.find_file()
33 utility function that is used by the Scanner.Classic class to search
34 directories in variables such as $CPPPATH.
41 _python_ = TestSCons._python_
43 test = TestSCons.TestSCons()
45 subdir_SConscript = os.path.join('subdir', 'SConscript')
46 subdir_foo = os.path.join('subdir', 'foo')
47 subdir_foo_k = os.path.join('subdir', 'foo.k')
49 test.subdir('subdir', 'inc1', 'inc2')
51 inc2_include_h = test.workpath('inc2', 'include.h')
53 test.write('build.py', r"""
56 path = sys.argv[1].split()
57 input = open(sys.argv[2], 'rb')
58 output = open(sys.argv[3], 'wb')
69 def process(infp, outfp):
70 for line in infp.readlines():
71 if line[:8] == 'include ':
73 process(find_file(file), outfp)
77 process(input, output)
82 test.write('SConstruct', """\
83 def foo(target, source, env):
84 fp = open(str(target[0]), 'wb')
85 for c in sorted(source[0].children(), key=lambda t: t.name):
88 Command('list.out', 'subdir', foo, source_scanner = DirScanner)
89 SConscript('subdir/SConscript')
92 test.write(['subdir', 'SConscript'], """\
94 kscan = SCons.Scanner.Classic(name = 'kfile',
96 path_variable = 'KPATH',
97 regex = r'^include\s+(\S+)$')
99 env = Environment(KPATH=['.', '..'])
100 env.Append(SCANNERS = kscan)
102 env.Command('foo', 'foo.k', r'%(_python_)s build.py "$KPATH" $SOURCES $TARGET')
105 test.write(['subdir', 'foo.k'], """\
107 include inc1/include.h
108 include %(inc2_include_h)s
111 test.write(['inc1', 'include.h'], """\
115 test.write(['inc2', 'include.h'], """\
119 test.run(arguments = '.')
121 test.must_match('subdir/foo', """\
127 test.must_match('list.out', """\
128 %(subdir_SConscript)s
137 # indent-tabs-mode:nil
139 # vim: set expandtab tabstop=4 shiftwidth=4: