OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library testing.analyze; | 5 library testing.analyze; |
6 | 6 |
7 import 'dart:async' show Stream, Future; | 7 import 'dart:async' show Stream, Future; |
8 | 8 |
9 import 'dart:convert' show LineSplitter, UTF8; | 9 import 'dart:convert' show LineSplitter, UTF8; |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 process.stdin.close(); | 159 process.stdin.close(); |
160 Future stdoutFuture = parseAnalyzerOutput(process.stdout).toList(); | 160 Future stdoutFuture = parseAnalyzerOutput(process.stdout).toList(); |
161 Future stderrFuture = parseAnalyzerOutput(process.stderr).toList(); | 161 Future stderrFuture = parseAnalyzerOutput(process.stderr).toList(); |
162 await process.exitCode; | 162 await process.exitCode; |
163 List<AnalyzerDiagnostic> diagnostics = <AnalyzerDiagnostic>[]; | 163 List<AnalyzerDiagnostic> diagnostics = <AnalyzerDiagnostic>[]; |
164 diagnostics.addAll(await stdoutFuture); | 164 diagnostics.addAll(await stdoutFuture); |
165 diagnostics.addAll(await stderrFuture); | 165 diagnostics.addAll(await stderrFuture); |
166 bool hasOutput = false; | 166 bool hasOutput = false; |
167 Set<String> seen = new Set<String>(); | 167 Set<String> seen = new Set<String>(); |
168 for (AnalyzerDiagnostic diagnostic in diagnostics) { | 168 for (AnalyzerDiagnostic diagnostic in diagnostics) { |
169 String path = diagnostic.uri?.path ?? "<unknown>"; | 169 String path = diagnostic.uri?.path; |
170 if (exclude.any((RegExp r) => path.contains(r))) continue; | 170 if (path != null && exclude.any((RegExp r) => path.contains(r))) { |
| 171 continue; |
| 172 } |
171 String message = "$diagnostic"; | 173 String message = "$diagnostic"; |
172 if (seen.add(message)) { | 174 if (seen.add(message)) { |
173 hasOutput = true; | 175 hasOutput = true; |
174 print(message); | 176 print(message); |
175 } | 177 } |
176 } | 178 } |
177 if (hasOutput) { | 179 if (hasOutput) { |
178 throw "Non-empty output from analyzer."; | 180 throw "Non-empty output from analyzer."; |
179 } | 181 } |
180 sw.stop(); | 182 sw.stop(); |
181 print("Running analyzer took: ${sw.elapsed}."); | 183 print("Running analyzer took: ${sw.elapsed}."); |
182 } | 184 } |
OLD | NEW |