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/implementation/apiimpl.dart'; | 10 import 'package:compiler/src/apiimpl.dart'; |
11 import 'package:compiler/implementation/dart2jslib.dart' | 11 import 'package:compiler/src/dart2jslib.dart' |
12 hide Compiler; | 12 hide Compiler; |
13 import 'package:compiler/implementation/filenames.dart'; | 13 import 'package:compiler/src/filenames.dart'; |
14 import 'package:compiler/implementation/source_file_provider.dart'; | 14 import 'package:compiler/src/source_file_provider.dart'; |
15 import 'package:compiler/implementation/util/uri_extras.dart'; | 15 import 'package:compiler/src/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}/')); |
153 var provider = new CompilerSourceFileProvider(); | 155 var provider = new CompilerSourceFileProvider(); |
154 var handler = new CollectingDiagnosticHandler(whiteList, provider); | 156 var handler = new CollectingDiagnosticHandler(whiteList, provider); |
155 var options = <String>['--analyze-only', '--categories=Client,Server']; | 157 var options = <String>['--analyze-only', '--categories=Client,Server']; |
156 if (analyzeAll) options.add('--analyze-all'); | 158 if (analyzeAll) options.add('--analyze-all'); |
157 var compiler = new Compiler( | 159 var compiler = new Compiler( |
158 provider.readStringFromUri, | 160 provider.readStringFromUri, |
159 null, | 161 null, |
160 handler.diagnosticHandler, | 162 handler.diagnosticHandler, |
161 libraryRoot, libraryRoot, | 163 libraryRoot, packageRoot, |
162 options, | 164 options, |
163 {}); | 165 {}); |
164 String MESSAGE = """ | 166 String MESSAGE = """ |
165 | 167 |
166 | 168 |
167 === | 169 === |
168 === ERROR: Unexpected result of analysis. | 170 === ERROR: Unexpected result of analysis. |
169 === | 171 === |
170 === Please update [WHITE_LIST] in $testFileName | 172 === Please update [WHITE_LIST] in $testFileName |
171 === | 173 === |
172 """; | 174 """; |
173 | 175 |
174 void onCompletion(_) { | 176 void onCompletion(_) { |
175 bool result; | 177 bool result; |
176 if (checkResults != null) { | 178 if (checkResults != null) { |
177 result = checkResults(compiler, handler); | 179 result = checkResults(compiler, handler); |
178 } else { | 180 } else { |
179 result = handler.checkResults(); | 181 result = handler.checkResults(); |
180 } | 182 } |
181 if (!result) { | 183 if (!result) { |
182 print(MESSAGE); | 184 print(MESSAGE); |
183 exit(1); | 185 exit(1); |
184 } | 186 } |
185 } | 187 } |
186 if (analyzeAll) { | 188 if (analyzeAll) { |
187 compiler.librariesToAnalyzeWhenRun = uriList; | 189 compiler.librariesToAnalyzeWhenRun = uriList; |
188 return compiler.run(null).then(onCompletion); | 190 return compiler.run(null).then(onCompletion); |
189 } else { | 191 } else { |
190 return compiler.run(uriList.single).then(onCompletion); | 192 return compiler.run(uriList.single).then(onCompletion); |
191 } | 193 } |
192 } | 194 } |
OLD | NEW |