Added fix for TeX includes with same name as subdirs.
[scons.git] / test / option / debug-count.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
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 from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
25
26 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27
28 """
29 Test that the --debug=count option works.
30 """
31
32 import re
33
34 import TestSCons
35
36 test = TestSCons.TestSCons()
37
38 try:
39     import weakref
40 except ImportError:
41     x = "Python version has no 'weakref' module; skipping tests.\n"
42     test.skip_test(x)
43
44
45
46 test.write('SConstruct', """
47 def cat(target, source, env):
48     open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
49 env = Environment(BUILDERS={'Cat':Builder(action=Action(cat))})
50 env.Cat('file.out', 'file.in')
51 """)
52
53 test.write('file.in', "file.in\n")
54
55 # Just check that object counts for some representative classes
56 # show up in the output.
57
58 def find_object_count(s, stdout):
59     re_string = '\d+ +\d+   %s' % re.escape(s)
60     return re.search(re_string, stdout)
61
62 objects = [
63     'Action.CommandAction',
64     'Builder.BuilderBase',
65     'Environment.Base',
66     'Executor.Executor',
67     'Node.FS',
68     'Node.FS.Base',
69     'Node.Node',
70 ]
71
72 for args in ['-h --debug=count', '--debug=count']:
73     test.run(arguments = args)
74     stdout = test.stdout()
75
76     missing = [o for o in objects if find_object_count(o, stdout) is None]
77
78     if missing:
79         print "Missing the following object lines from '%s' output:" % args
80         print "\t", ' '.join(missing)
81         print "STDOUT =========="
82         print stdout
83         test.fail_test(1)
84
85 expect_warning = """
86 scons: warning: --debug=count is not supported when running SCons
87 \twith the python -O option or optimized \\(.pyo\\) modules.
88 """ + TestSCons.file_expr
89
90 test.run(arguments = '--debug=count -h',
91          interpreter = ['python', '-O'],
92          stderr = expect_warning,
93          match = TestSCons.match_re)
94
95
96 test.pass_test()
97
98 # Local Variables:
99 # tab-width:4
100 # indent-tabs-mode:nil
101 # End:
102 # vim: set expandtab tabstop=4 shiftwidth=4: