OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """A tool to run croc to generate code coverage, executed by buildbot. | 6 """A tool to run croc to generate code coverage, executed by buildbot. |
7 | 7 |
8 When this is run, the current directory (cwd) should be the outer build | 8 When this is run, the current directory (cwd) should be the outer build |
9 directory (e.g., chrome-release/build/). | 9 directory (e.g., chrome-release/build/). |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 def main_linux(options, args): | 73 def main_linux(options, args): |
74 """Print appropriate size information about built Linux targets. | 74 """Print appropriate size information about built Linux targets. |
75 | 75 |
76 Returns the first non-zero exit status of any command it executes, | 76 Returns the first non-zero exit status of any command it executes, |
77 or zero on success. | 77 or zero on success. |
78 | 78 |
79 Assumes make, not scons. | 79 Assumes make, not scons. |
80 """ | 80 """ |
81 target_dir = os.path.join(os.path.dirname(options.build_dir), | 81 target_dir = os.path.join(os.path.dirname(options.build_dir), |
82 'out', options.target) | 82 'out', options.target) |
83 if os.path.exists(os.path.join(target_dir, 'total_coverage')): | |
84 print 'total_coverage directory exists' | |
85 total_cov_file = os.path.join(target_dir, 'total_coverage', 'coverage.info') | |
86 cmdline = [ | |
87 sys.executable, | |
88 'src/tools/code_coverage/croc.py', | |
89 '-c', 'src/build/common.croc', | |
90 '-c', 'src/build/linux/chrome_linux.croc', | |
91 '-i', total_cov_file, | |
92 '-r', os.getcwd(), | |
93 '--tree', | |
94 '--html', | |
95 os.path.join(target_dir, 'total_coverage', 'coverage_croc_html'), | |
96 ] | |
97 main_common(total_cov_file, cmdline) | |
83 | 98 |
84 cov_file = os.path.join(target_dir, 'coverage.info') | 99 if os.path.exists(os.path.join(target_dir, 'unittests_coverage')): |
85 | 100 print 'unittests_coverage directory exists' |
86 cmdline = [ | 101 unittests_cov_file = os.path.join(target_dir, 'unittests_coverage', 'coverag e.info') |
87 sys.executable, | 102 cmdline = [ |
88 'src/tools/code_coverage/croc.py', | 103 sys.executable, |
89 '-c', 'src/build/common.croc', | 104 'src/tools/code_coverage/croc.py', |
90 '-c', 'src/build/linux/chrome_linux.croc', | 105 '-c', 'src/build/common.croc', |
91 '-i', cov_file, | 106 '-c', 'src/build/linux/chrome_linux.croc', |
92 '-r', os.getcwd(), | 107 '-i', unittests_cov_file, |
93 '--tree', | 108 '-r', os.getcwd(), |
94 '--html', os.path.join(target_dir, 'coverage_croc_html'), | 109 '--tree', |
95 ] | 110 '--html', |
96 | 111 os.path.join(target_dir, 'unittests_coverage', 'coverage_croc_html'), |
97 return main_common(cov_file, cmdline) | 112 ] |
113 main_common(unittests_cov_file, cmdline) | |
114 return | |
cmp
2012/11/05 21:26:35
I assume main_common returns something useful. If
pshenoy
2012/11/05 21:52:14
Done. Not sure how do I return the result of previ
cmp
2012/11/05 21:59:29
There are a couple approaches:
- add result values
pshenoy
2012/11/05 22:22:23
Thanks. Done.
| |
98 | 115 |
99 | 116 |
100 def main_win(options, args): | 117 def main_win(options, args): |
101 """Print appropriate size information about built Windows targets. | 118 """Print appropriate size information about built Windows targets. |
102 | 119 |
103 Returns the first non-zero exit status of any command it executes, | 120 Returns the first non-zero exit status of any command it executes, |
104 or zero on success. | 121 or zero on success. |
105 """ | 122 """ |
106 target_dir = os.path.join(options.build_dir, options.target) | 123 target_dir = os.path.join(options.build_dir, options.target) |
107 cov_file = os.path.join(target_dir, 'coverage.info') | 124 cov_file = os.path.join(target_dir, 'coverage.info') |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 else: | 178 else: |
162 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) | 179 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) |
163 msg = 'Use the --platform= option to specify a supported platform:\n' | 180 msg = 'Use the --platform= option to specify a supported platform:\n' |
164 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') | 181 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') |
165 return 2 | 182 return 2 |
166 return real_main(options, args) | 183 return real_main(options, args) |
167 | 184 |
168 | 185 |
169 if '__main__' == __name__: | 186 if '__main__' == __name__: |
170 sys.exit(main()) | 187 sys.exit(main()) |
OLD | NEW |