OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyze_helper; | 5 library analyze_helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:compiler/compiler.dart' as api; | 9 import 'package:compiler/compiler.dart' as api; |
10 import 'package:compiler/src/apiimpl.dart'; | 10 import 'package:compiler/implementation/apiimpl.dart'; |
11 import 'package:compiler/src/dart2jslib.dart' | 11 import 'package:compiler/implementation/dart2jslib.dart' |
12 hide Compiler; | 12 hide Compiler; |
13 import 'package:compiler/src/filenames.dart'; | 13 import 'package:compiler/implementation/filenames.dart'; |
14 import 'package:compiler/src/source_file_provider.dart'; | 14 import 'package:compiler/implementation/source_file_provider.dart'; |
15 import 'package:compiler/src/util/uri_extras.dart'; | 15 import 'package:compiler/implementation/util/uri_extras.dart'; |
16 | 16 |
17 /** | 17 /** |
18 * Map of whitelisted warnings and errors. | 18 * Map of whitelisted warnings and errors. |
19 * | 19 * |
20 * Only add a whitelisting together with a bug report to dartbug.com and add | 20 * Only add a whitelisting together with a bug report to dartbug.com and add |
21 * the bug issue number as a comment on the whitelisting. | 21 * the bug issue number as a comment on the whitelisting. |
22 * | 22 * |
23 * Use an identifiable suffix of the file uri as key. Use a fixed substring of | 23 * Use an identifiable suffix of the file uri as key. Use a fixed substring of |
24 * the error/warning message in the list of whitelistings for each file. | 24 * the error/warning message in the list of whitelistings for each file. |
25 */ | 25 */ |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 Future analyze(List<Uri> uriList, | 135 Future analyze(List<Uri> uriList, |
136 Map<String, List<String>> whiteList, | 136 Map<String, List<String>> whiteList, |
137 {bool analyzeAll: true, | 137 {bool analyzeAll: true, |
138 CheckResults checkResults}) { | 138 CheckResults checkResults}) { |
139 String testFileName = | 139 String testFileName = |
140 relativize(Uri.base, Platform.script, Platform.isWindows); | 140 relativize(Uri.base, Platform.script, Platform.isWindows); |
141 | 141 |
142 print(""" | 142 print(""" |
143 | 143 |
144 | 144 |
145 === | 145 === |
146 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName | 146 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName |
147 === | 147 === |
148 | 148 |
149 | 149 |
150 """); | 150 """); |
151 | 151 |
152 var libraryRoot = currentDirectory.resolve('sdk/'); | 152 var libraryRoot = currentDirectory.resolve('sdk/'); |
153 var packageRoot = | |
154 currentDirectory.resolveUri(new Uri.file('${Platform.packageRoot}/')); | |
155 var provider = new CompilerSourceFileProvider(); | 153 var provider = new CompilerSourceFileProvider(); |
156 var handler = new CollectingDiagnosticHandler(whiteList, provider); | 154 var handler = new CollectingDiagnosticHandler(whiteList, provider); |
157 var options = <String>['--analyze-only', '--categories=Client,Server']; | 155 var options = <String>['--analyze-only', '--categories=Client,Server']; |
158 if (analyzeAll) options.add('--analyze-all'); | 156 if (analyzeAll) options.add('--analyze-all'); |
159 var compiler = new Compiler( | 157 var compiler = new Compiler( |
160 provider.readStringFromUri, | 158 provider.readStringFromUri, |
161 null, | 159 null, |
162 handler.diagnosticHandler, | 160 handler.diagnosticHandler, |
163 libraryRoot, packageRoot, | 161 libraryRoot, libraryRoot, |
164 options, | 162 options, |
165 {}); | 163 {}); |
166 String MESSAGE = """ | 164 String MESSAGE = """ |
167 | 165 |
168 | 166 |
169 === | 167 === |
170 === ERROR: Unexpected result of analysis. | 168 === ERROR: Unexpected result of analysis. |
171 === | 169 === |
172 === Please update [WHITE_LIST] in $testFileName | 170 === Please update [WHITE_LIST] in $testFileName |
173 === | 171 === |
174 """; | 172 """; |
175 | 173 |
176 void onCompletion(_) { | 174 void onCompletion(_) { |
177 bool result; | 175 bool result; |
178 if (checkResults != null) { | 176 if (checkResults != null) { |
179 result = checkResults(compiler, handler); | 177 result = checkResults(compiler, handler); |
180 } else { | 178 } else { |
181 result = handler.checkResults(); | 179 result = handler.checkResults(); |
182 } | 180 } |
183 if (!result) { | 181 if (!result) { |
184 print(MESSAGE); | 182 print(MESSAGE); |
185 exit(1); | 183 exit(1); |
186 } | 184 } |
187 } | 185 } |
188 if (analyzeAll) { | 186 if (analyzeAll) { |
189 compiler.librariesToAnalyzeWhenRun = uriList; | 187 compiler.librariesToAnalyzeWhenRun = uriList; |
190 return compiler.run(null).then(onCompletion); | 188 return compiler.run(null).then(onCompletion); |
191 } else { | 189 } else { |
192 return compiler.run(uriList.single).then(onCompletion); | 190 return compiler.run(uriList.single).then(onCompletion); |
193 } | 191 } |
194 } | 192 } |
OLD | NEW |