Add --debug=tree (print depenency tree) support
[scons.git] / test / option--debug.py
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2001 Steven Knight
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "test/option--test.py __REVISION__ __DATE__ __DEVELOPER__"
26
27 import TestSCons
28 import sys
29 import string
30
31 test = TestSCons.TestSCons()
32
33 test.write('SConstruct', """
34 env = Environment()
35 env.Program('foo', 'foo.c bar.c')
36 """)
37
38 test.write('foo.c', """
39 #include "foo.h"
40 int main(int argc, char *argv[])
41 {
42         argv[argc++] = "--";
43         printf("f1.c\n");
44         exit (0);
45 }
46 """)
47
48 test.write('bar.c', """
49 #include "bar.h"
50 """)
51
52 test.write('foo.h', """
53 #ifndef FOO_H
54 #define FOO_H
55 #include "bar.h"
56 #endif
57 """)
58
59 test.write('bar.h', """
60 #ifndef BAR_H
61 #define BAR_H
62 #include "foo.h"
63 #endif
64 """)
65
66
67 if sys.platform == 'win32':
68     foo = 'foo.exe'
69 else:
70     foo = 'foo'
71
72 test.run(arguments = "--debug=tree " + foo)
73
74 tree = """
75 +-foo
76   +-foo.o
77   | +-foo.c
78   |   +-foo.h
79   |   +-bar.h
80   +-bar.o
81     +-bar.c
82       +-bar.h
83       +-foo.h
84 """
85
86 assert string.find(test.stdout(), tree) != -1
87
88 test.run(arguments = "--debug=tree " + foo)
89 assert string.find(test.stdout(), tree) != -1
90
91 test.pass_test()
92