Debian Codegraph @

test/scons-time/run/option/verbose.py

raw
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
25 """
26 Verify that the run -v and --verbose options display command output.
27 """
28
29 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30
31 import sys
32 import re
33 import os
34 import TestSCons_time
35
36 _python_ = re.escape('"' + sys.executable + '"')
37
38
39 test = TestSCons_time.TestSCons_time(match=TestSCons_time.match_re,
40 diff=TestSCons_time.diff_re)
41
42 scons_py = re.escape(test.workpath('scripts', 'scons.py'))
43 src_engine = re.escape(test.workpath())
44
45 tmp_scons_time = test.tempdir_re()
46 tmp_scons_time_foo = test.tempdir_re('foo')
47
48
49 test.write_fake_scons_py()
50
51 foo_tar_gz = test.write_sample_project('foo.tar.gz')
52
53 expect = """\
54 %(scons_py)s
55 --version
56 SCONS_LIB_DIR = %(src_engine)s
57 SConstruct file directory: %(tmp_scons_time_foo)s
58 """ % locals()
59
60 test.run(arguments='run -q foo.tar.gz', stdout=expect)
61
62 test.must_exist('foo-000-0.log',
63 'foo-000-0.prof',
64 'foo-000-1.log',
65 'foo-000-1.prof',
66 'foo-000-2.log',
67 'foo-000-2.prof')
68
69 time_re = r'\[\d\d:\d\d:\d\d\]'
70
71 scons_flags = '--debug=count --debug=memory --debug=time --debug=memoizer'
72
73
74 expect = """\
75 scons-time%(time_re)s: cd %(tmp_scons_time)s
76 scons-time%(time_re)s: tar xzf %(foo_tar_gz)s
77 scons-time%(time_re)s: cd foo
78 scons-time%(time_re)s: find \\* -type f | xargs cat > /dev/null
79 scons-time%(time_re)s: export SCONS_LIB_DIR=%(src_engine)s
80 scons-time%(time_re)s: %(_python_)s %(scons_py)s --version
81 %(scons_py)s
82 --version
83 SCONS_LIB_DIR = %(src_engine)s
84 SConstruct file directory: %(tmp_scons_time_foo)s
85 scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(prof0)s --help 2>&1 \\| tee %(log0)s
86 %(scons_py)s
87 --debug=count
88 --debug=memory
89 --debug=time
90 --debug=memoizer
91 --profile=%(prof0)s
92 --help
93 SCONS_LIB_DIR = %(src_engine)s
94 SConstruct file directory: %(tmp_scons_time_foo)s
95 scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(prof1)s 2>&1 \\| tee %(log1)s
96 %(scons_py)s
97 --debug=count
98 --debug=memory
99 --debug=time
100 --debug=memoizer
101 --profile=%(prof1)s
102 SCONS_LIB_DIR = %(src_engine)s
103 SConstruct file directory: %(tmp_scons_time_foo)s
104 scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(prof2)s 2>&1 \\| tee %(log2)s
105 %(scons_py)s
106 --debug=count
107 --debug=memory
108 --debug=time
109 --debug=memoizer
110 --profile=%(prof2)s
111 SCONS_LIB_DIR = %(src_engine)s
112 SConstruct file directory: %(tmp_scons_time_foo)s
113 scons-time%(time_re)s: cd .*
114 """
115 if 'PRESERVE' not in os.environ or not os.environ['PRESERVE']:
116 expect += """scons-time%(time_re)s: rm -rf %(tmp_scons_time)s
117 """
118
119 foo_tar_gz = re.escape(foo_tar_gz)
120
121 log0 = re.escape(test.workpath('foo-001-0.log'))
122 log1 = re.escape(test.workpath('foo-001-1.log'))
123 log2 = re.escape(test.workpath('foo-001-2.log'))
124
125 prof0 = re.escape(test.workpath('foo-001-0.prof'))
126 prof1 = re.escape(test.workpath('foo-001-1.prof'))
127 prof2 = re.escape(test.workpath('foo-001-2.prof'))
128
129 test.run(arguments='run -v foo.tar.gz', stdout=expect % locals())
130
131 test.must_exist('foo-001-0.log',
132 'foo-001-0.prof',
133 'foo-001-1.log',
134 'foo-001-1.prof',
135 'foo-001-2.log',
136 'foo-001-2.prof')
137
138 log0 = re.escape(test.workpath('foo-002-0.log'))
139 log1 = re.escape(test.workpath('foo-002-1.log'))
140 log2 = re.escape(test.workpath('foo-002-2.log'))
141
142 prof0 = re.escape(test.workpath('foo-002-0.prof'))
143 prof1 = re.escape(test.workpath('foo-002-1.prof'))
144 prof2 = re.escape(test.workpath('foo-002-2.prof'))
145
146 test.run(arguments='run --verbose foo.tar.gz', stdout=expect % locals())
147
148
149 test.pass_test()
150
151 # Local Variables:
152 # tab-width:4
153 # indent-tabs-mode:nil
154 # End:
155 # vim: set expandtab tabstop=4 shiftwidth=4: