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__"
34 # Check for the sconsign script before we instantiate TestSCons(),
35 # because that will change directory on us.
36 if os.path.exists('sconsign.py'):
37 sconsign = 'sconsign.py'
38 elif os.path.exists('sconsign'):
41 print "Can find neither 'sconsign.py' nor 'sconsign' scripts."
44 def sort_match(test, lines, expect):
45 lines = string.split(lines, '\n')
47 expect = string.split(expect, '\n')
49 return test.match_re(lines, expect)
51 test = TestSCons.TestSCons(match = TestCmd.match_re)
56 test.subdir('work1', ['work1', 'sub1'], ['work1', 'sub2'],
57 'work2', ['work2', 'sub1'], ['work2', 'sub2'])
59 test.write(['work1', 'SConstruct'], """
60 env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
61 env1.Program('sub1/hello.c')
62 env2 = env1.Copy(CPPPATH = ['sub2'])
63 env2.Program('sub2/hello.c')
66 test.write(['work1', 'sub1', 'hello.c'], r"""\
68 main(int argc, char *argv[])
71 printf("sub1/hello.c\n");
76 test.write(['work1', 'sub2', 'hello.c'], r"""\
80 main(int argc, char *argv[])
83 printf("sub2/goodbye.c\n");
88 test.write(['work1', 'sub2', 'inc1.h'], r"""\
89 #define STRING1 "inc1.h"
92 test.write(['work1', 'sub2', 'inc2.h'], r"""\
93 #define STRING2 "inc2.h"
96 test.run(chdir = 'work1', arguments = '--implicit-cache .')
98 test.run(interpreter = TestSCons.python,
100 arguments = "work1/sub1/.sconsign",
102 hello.exe: None \S+ None
103 hello.obj: None \S+ None
106 test.run(interpreter = TestSCons.python,
108 arguments = "-v work1/sub1/.sconsign",
120 test.run(interpreter = TestSCons.python,
122 arguments = "-b -v work1/sub1/.sconsign",
130 test.run(interpreter = TestSCons.python,
132 arguments = "-c -v work1/sub1/.sconsign",
140 test.run(interpreter = TestSCons.python,
142 arguments = "-e hello.obj work1/sub1/.sconsign",
144 hello.obj: None \S+ None
147 test.run(interpreter = TestSCons.python,
149 arguments = "-e hello.obj -e hello.exe -e hello.obj work1/sub1/.sconsign",
151 hello.obj: None \S+ None
152 hello.exe: None \S+ None
153 hello.obj: None \S+ None
156 test.run(interpreter = TestSCons.python,
158 arguments = "work1/sub2/.sconsign",
160 hello.exe: None \S+ None
161 hello.obj: None \S+ None
164 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
165 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
167 test.run(interpreter = TestSCons.python,
169 arguments = "-i -v work1/sub2/.sconsign",
176 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
177 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
179 test.run(interpreter = TestSCons.python,
181 arguments = "-e hello.obj work1/sub2/.sconsign work1/sub1/.sconsign",
183 hello.obj: None \S+ None
186 hello.obj: None \S+ None
187 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
188 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
190 test.run(chdir = 'work1', arguments = '--clean .')
192 test.write(['work1', 'SConstruct'], """
193 SourceSignatures('timestamp')
194 TargetSignatures('content')
195 env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
196 env1.Program('sub1/hello.c')
197 env2 = env1.Copy(CPPPATH = ['sub2'])
198 env2.Program('sub2/hello.c')
203 test.run(chdir = 'work1', arguments = '. --max-drift=1')
205 test.run(interpreter = TestSCons.python,
207 arguments = "work1/sub1/.sconsign")
209 test.fail_test(not sort_match(test, test.stdout(), """\
210 hello.exe: None \S+ None
211 hello.c: \d+ None \d+
212 hello.obj: None \S+ None
215 test.run(interpreter = TestSCons.python,
217 arguments = "-r work1/sub1/.sconsign")
219 test.fail_test(not sort_match(test, test.stdout(), """\
220 hello.exe: None \S+ None
221 hello.c: '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' None \d+
222 hello.obj: None \S+ None
226 ##############################################################################
228 test.write(['work2', 'SConstruct'], """
230 env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
231 env1.Program('sub1/hello.c')
232 env2 = env1.Copy(CPPPATH = ['sub2'])
233 env2.Program('sub2/hello.c')
236 test.write(['work2', 'sub1', 'hello.c'], r"""\
238 main(int argc, char *argv[])
241 printf("sub1/hello.c\n");
246 test.write(['work2', 'sub2', 'hello.c'], r"""\
250 main(int argc, char *argv[])
253 printf("sub2/goodbye.c\n");
258 test.write(['work2', 'sub2', 'inc1.h'], r"""\
259 #define STRING1 "inc1.h"
262 test.write(['work2', 'sub2', 'inc2.h'], r"""\
263 #define STRING2 "inc2.h"
266 test.run(chdir = 'work2', arguments = '--implicit-cache .')
268 test.run(interpreter = TestSCons.python,
270 arguments = "work2/.sconsign.dbm",
273 hello.exe: None \S+ None
274 hello.obj: None \S+ None
276 hello.exe: None \S+ None
277 hello.obj: None \S+ None
280 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
281 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
283 test.run(interpreter = TestSCons.python,
285 arguments = "-v work2/.sconsign.dbm",
308 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
309 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
311 test.run(interpreter = TestSCons.python,
313 arguments = "-b -v work2/.sconsign.dbm",
327 test.run(interpreter = TestSCons.python,
329 arguments = "-c -v work2/.sconsign.dbm",
343 test.run(interpreter = TestSCons.python,
345 arguments = "-e hello.obj work2/.sconsign.dbm",
348 hello.obj: None \S+ None
350 hello.obj: None \S+ None
353 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
354 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
356 test.run(interpreter = TestSCons.python,
358 arguments = "-e hello.obj -e hello.exe -e hello.obj work2/.sconsign.dbm",
361 hello.obj: None \S+ None
362 hello.exe: None \S+ None
363 hello.obj: None \S+ None
365 hello.obj: None \S+ None
368 hello.exe: None \S+ None
369 hello.obj: None \S+ None
372 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
373 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\'),
374 string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
375 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
377 test.run(interpreter = TestSCons.python,
379 arguments = "-i -v work2/.sconsign.dbm",
390 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
391 string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
393 test.run(chdir = 'work2', arguments = '--clean .')
395 test.write(['work2','SConstruct'], """
396 SConsignFile('my_sconsign')
397 SourceSignatures('timestamp')
398 TargetSignatures('content')
399 env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
400 env1.Program('sub1/hello.c')
401 env2 = env1.Copy(CPPPATH = ['sub2'])
402 env2.Program('sub2/hello.c')
407 test.run(chdir = 'work2', arguments = '. --max-drift=1')
409 test.run(interpreter = TestSCons.python,
411 arguments = "-d sub1 -f dbm work2/my_sconsign")
413 test.fail_test(not sort_match(test, test.stdout(), """\
415 hello.exe: None \S+ None
416 hello.obj: None \S+ None
417 hello.c: \d+ None \d+
420 test.run(interpreter = TestSCons.python,
422 arguments = "-r -d sub1 -f dbm work2/my_sconsign")
424 test.fail_test(not sort_match(test, test.stdout(), """\
426 hello.exe: None \S+ None
427 hello.obj: None \S+ None
428 hello.c: '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' None \d+
431 ##############################################################################
433 test.write('bad_sconsign', "bad_sconsign\n")
435 test.run(interpreter = TestSCons.python,
437 arguments = "-f dbm no_sconsign",
438 stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n")
440 test.run(interpreter = TestSCons.python,
442 arguments = "-f dbm bad_sconsign",
443 stderr = "sconsign: ignoring invalid .sconsign.dbm file `bad_sconsign': db type could not be determined\n")
445 test.run(interpreter = TestSCons.python,
447 arguments = "-f sconsign no_sconsign",
448 stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n")
450 test.run(interpreter = TestSCons.python,
452 arguments = "-f sconsign bad_sconsign",
453 stderr = "sconsign: ignoring invalid .sconsign file `bad_sconsign'\n")