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, |
| 86 'total_coverage', |
| 87 'coverage.info') |
| 88 cmdline = [ |
| 89 sys.executable, |
| 90 'src/tools/code_coverage/croc.py', |
| 91 '-c', 'src/build/common.croc', |
| 92 '-c', 'src/build/linux/chrome_linux.croc', |
| 93 '-i', total_cov_file, |
| 94 '-r', os.getcwd(), |
| 95 '--tree', |
| 96 '--html', |
| 97 os.path.join(target_dir, 'total_coverage', 'coverage_croc_html'), |
| 98 ] |
| 99 result = main_common(total_cov_file, cmdline) |
83 | 100 |
84 cov_file = os.path.join(target_dir, 'coverage.info') | 101 if os.path.exists(os.path.join(target_dir, 'unittests_coverage')): |
| 102 print 'unittests_coverage directory exists' |
| 103 unittests_cov_file = os.path.join(target_dir, |
| 104 'unittests_coverage', |
| 105 'coverage.info') |
| 106 cmdline = [ |
| 107 sys.executable, |
| 108 'src/tools/code_coverage/croc.py', |
| 109 '-c', 'src/build/common.croc', |
| 110 '-c', 'src/build/linux/chrome_linux.croc', |
| 111 '-i', unittests_cov_file, |
| 112 '-r', os.getcwd(), |
| 113 '--tree', |
| 114 '--html', |
| 115 os.path.join(target_dir, 'unittests_coverage', 'coverage_croc_html'), |
| 116 ] |
| 117 unittests_result = main_common(unittests_cov_file, cmdline) |
85 | 118 |
86 cmdline = [ | 119 if unittests_result != 0: |
87 sys.executable, | 120 result = unittests_result |
88 'src/tools/code_coverage/croc.py', | 121 return result |
89 '-c', 'src/build/common.croc', | |
90 '-c', 'src/build/linux/chrome_linux.croc', | |
91 '-i', cov_file, | |
92 '-r', os.getcwd(), | |
93 '--tree', | |
94 '--html', os.path.join(target_dir, 'coverage_croc_html'), | |
95 ] | |
96 | |
97 return main_common(cov_file, cmdline) | |
98 | 122 |
99 | 123 |
100 def main_win(options, args): | 124 def main_win(options, args): |
101 """Print appropriate size information about built Windows targets. | 125 """Print appropriate size information about built Windows targets. |
102 | 126 |
103 Returns the first non-zero exit status of any command it executes, | 127 Returns the first non-zero exit status of any command it executes, |
104 or zero on success. | 128 or zero on success. |
105 """ | 129 """ |
106 target_dir = os.path.join(options.build_dir, options.target) | 130 target_dir = os.path.join(options.build_dir, options.target) |
107 cov_file = os.path.join(target_dir, 'coverage.info') | 131 cov_file = os.path.join(target_dir, 'coverage.info') |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 else: | 185 else: |
162 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) | 186 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) |
163 msg = 'Use the --platform= option to specify a supported platform:\n' | 187 msg = 'Use the --platform= option to specify a supported platform:\n' |
164 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') | 188 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') |
165 return 2 | 189 return 2 |
166 return real_main(options, args) | 190 return real_main(options, args) |
167 | 191 |
168 | 192 |
169 if '__main__' == __name__: | 193 if '__main__' == __name__: |
170 sys.exit(main()) | 194 sys.exit(main()) |
OLD | NEW |