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 the --debug=explain information gets saved by default.
33 _python_ = TestSCons._python_
35 test = TestSCons.TestSCons()
37 test.subdir( 'src', ['src', 'subdir'])
39 cat_py = test.workpath('cat.py')
40 inc_bbb_k = test.workpath('inc', 'bbb.k')
41 inc_ddd = test.workpath('inc', 'ddd')
42 inc_eee = test.workpath('inc', 'eee')
44 test.write(cat_py, r"""
47 def process(outfp, infp):
48 for line in infp.readlines():
49 if line[:8] == 'include ':
55 print "os.getcwd() =", os.getcwd()
61 outfp = open(sys.argv[1], 'wb')
62 for f in sys.argv[2:]:
64 process(outfp, open(f, 'rb'))
69 test.write(['src', 'SConstruct'], """\
72 include_re = re.compile(r'^include\s+(\S+)$', re.M)
74 def kfile_scan(node, env, target, arg):
75 contents = node.get_text_contents()
76 includes = include_re.findall(contents)
79 kscan = Scanner(name = 'kfile',
80 function = kfile_scan,
84 cat = Builder(action = r'%(_python_)s %(cat_py)s $TARGET $SOURCES')
87 env.Append(BUILDERS = {'Cat':cat},
91 SConscript('SConscript')
92 env.Install('../inc', 'aaa')
93 env.InstallAs('../inc/bbb.k', 'bbb.k')
94 env.Install('../inc', 'ddd')
95 env.InstallAs('../inc/eee', 'eee.in')
98 test.write(['src', 'SConscript'], """\
100 env.Cat('file1', 'file1.in')
101 env.Cat('file2', 'file2.k')
102 env.Cat('file3', ['xxx', 'yyy', 'zzz'])
103 env.Command('file4', 'file4.in', r'%(_python_)s %(cat_py)s $TARGET - $SOURCES')
104 env.Cat('file5', 'file5.k')
105 env.Cat('subdir/file6', 'subdir/file6.in')
108 test.write(['src', 'aaa'], "aaa 1\n")
109 test.write(['src', 'bbb.k'], """\
115 test.write(['src', 'ccc'], "ccc 1\n")
116 test.write(['src', 'ddd'], "ddd 1\n")
117 test.write(['src', 'eee.in'], "eee.in 1\n")
119 test.write(['src', 'file1.in'], "file1.in 1\n")
121 test.write(['src', 'file2.k'], """\
128 test.write(['src', 'file4.in'], "file4.in 1\n")
130 test.write(['src', 'xxx'], "xxx 1\n")
131 test.write(['src', 'yyy'], "yyy 1\n")
132 test.write(['src', 'zzz'], "zzz 1\n")
134 test.write(['src', 'file5.k'], """\
141 test.write(['src', 'subdir', 'file6.in'], "subdir/file6.in 1\n")
144 test.run(chdir='src', arguments='.')
146 test.must_match(['src', 'file1'], "file1.in 1\n")
147 test.must_match(['src', 'file2'], """\
153 test.must_match(['src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n")
154 test.must_match(['src', 'file4'], "file4.in 1\n")
155 test.must_match(['src', 'file5'], """\
165 test.write(['src', 'file1.in'], "file1.in 2\n")
166 test.write(['src', 'yyy'], "yyy 2\n")
167 test.write(['src', 'zzz'], "zzz 2\n")
168 test.write(['src', 'bbb.k'], "bbb.k 2\ninclude ccc\n")
170 expect = test.wrap_stdout("""\
171 scons: rebuilding `file1' because `file1.in' changed
172 %(_python_)s %(cat_py)s file1 file1.in
173 scons: rebuilding `file2' because `yyy' changed
174 %(_python_)s %(cat_py)s file2 file2.k
175 scons: rebuilding `file3' because:
178 %(_python_)s %(cat_py)s file3 xxx yyy zzz
179 scons: rebuilding `%(inc_bbb_k)s' because:
180 `%(inc_ddd)s' is no longer a dependency
181 `%(inc_eee)s' is no longer a dependency
183 Install file: "bbb.k" as "%(inc_bbb_k)s"
184 scons: rebuilding `file5' because `%(inc_bbb_k)s' changed
185 %(_python_)s %(cat_py)s file5 file5.k
188 test.run(chdir='src', arguments='--debug=explain .', stdout=expect)
190 test.must_match(['src', 'file1'], "file1.in 2\n")
191 test.must_match(['src', 'file2'], """\
197 test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
198 test.must_match(['src', 'file5'], """\