7f693d11cb7c3dfd37234082961c09704ca280b4
[scons.git] / test / scons-time / run / option / verbose.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
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Verify that the run -v and --verbose options display command output.
29 """
30
31 import re
32
33 import TestSCons_time
34
35 _python_ = re.escape(TestSCons_time._python_)
36
37
38 test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re,
39                                      diff = TestSCons_time.diff_re)
40
41 scons_py = re.escape(test.workpath('src', 'script', 'scons.py'))
42 src_engine = re.escape(test.workpath('src', 'engine'))
43
44 tmp_scons_time = test.tempdir_re()
45 tmp_scons_time_foo = test.tempdir_re('foo')
46
47
48 test.write_fake_scons_py()
49
50 foo_tar_gz = test.write_sample_project('foo.tar.gz')
51
52 expect = """\
53 %(scons_py)s
54     --version
55 SCONS_LIB_DIR = %(src_engine)s
56 SConstruct file directory: %(tmp_scons_time_foo)s
57 """ % locals()
58
59 test.run(arguments = 'run -q foo.tar.gz', stdout = expect)
60
61 test.must_exist('foo-000-0.log',
62                 'foo-000-0.prof',
63                 'foo-000-1.log',
64                 'foo-000-1.prof',
65                 'foo-000-2.log',
66                 'foo-000-2.prof')
67
68 time_re = r'\[\d\d:\d\d:\d\d\]'
69
70 scons_flags = '--debug=count --debug=memory --debug=time --debug=memoizer'
71
72
73 expect = """\
74 scons-time%(time_re)s: mkdir %(tmp_scons_time)s
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 scons-time%(time_re)s: rm -rf %(tmp_scons_time)s
115 """
116
117 foo_tar_gz = re.escape(foo_tar_gz)
118
119 log0 = re.escape(test.workpath('foo-001-0.log'))
120 log1 = re.escape(test.workpath('foo-001-1.log'))
121 log2 = re.escape(test.workpath('foo-001-2.log'))
122
123 prof0 = re.escape(test.workpath('foo-001-0.prof'))
124 prof1 = re.escape(test.workpath('foo-001-1.prof'))
125 prof2 = re.escape(test.workpath('foo-001-2.prof'))
126
127 test.run(arguments = 'run -v foo.tar.gz', stdout = expect % locals())
128
129 test.must_exist('foo-001-0.log',
130                 'foo-001-0.prof',
131                 'foo-001-1.log',
132                 'foo-001-1.prof',
133                 'foo-001-2.log',
134                 'foo-001-2.prof')
135
136 log0 = re.escape(test.workpath('foo-002-0.log'))
137 log1 = re.escape(test.workpath('foo-002-1.log'))
138 log2 = re.escape(test.workpath('foo-002-2.log'))
139
140 prof0 = re.escape(test.workpath('foo-002-0.prof'))
141 prof1 = re.escape(test.workpath('foo-002-1.prof'))
142 prof2 = re.escape(test.workpath('foo-002-2.prof'))
143
144 test.run(arguments = 'run --verbose foo.tar.gz', stdout = expect % locals())
145
146
147 test.pass_test()
148
149 # Local Variables:
150 # tab-width:4
151 # indent-tabs-mode:nil
152 # End:
153 # vim: set expandtab tabstop=4 shiftwidth=4: