Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1656)

Unified Diff: dart/tools/testing/dart/test_runner.dart

Issue 47743005: test.py: Run the analyzer on all dart files in the sdk. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/tools/testing/dart/test_runner.dart
diff --git a/dart/tools/testing/dart/test_runner.dart b/dart/tools/testing/dart/test_runner.dart
index 2a197ca024e869ac2c70ce2fe6b529e70a0f70fc..9f62c9c79f906e0b5d8c9bbb6a6cfdeeee381e8d 100644
--- a/dart/tools/testing/dart/test_runner.dart
+++ b/dart/tools/testing/dart/test_runner.dart
@@ -339,23 +339,30 @@ class SeleniumTestCommand extends Command {
class AnalysisCommand extends Command {
final String flavor;
+ // If [fileFilter] is given, only errors/warnings reported by the analyzer
+ // for which [fileFilter] returns [:true:] are considered.
+ final Function fileFilter;
+
AnalysisCommand._(this.flavor,
String displayName,
String executable,
List<String> arguments,
- String configurationDir)
+ String configurationDir,
+ this.fileFilter)
: super._(displayName, executable, arguments, configurationDir);
void _buildHashCode(HashCodeBuilder builder) {
super._buildHashCode(builder);
builder.add(flavor);
+ builder.add(fileFilter);
}
bool _equal(Command other) {
return
other is AnalysisCommand &&
super._equal(other) &&
- flavor == other.flavor;
+ flavor == other.flavor &&
+ fileFilter == other.fileFilter;
}
}
@@ -434,9 +441,10 @@ class CommandBuilder {
AnalysisCommand getAnalysisCommand(
String displayName, executable, arguments, String configurationDir,
- {String flavor: 'dartanalyzer'}) {
+ {String flavor: 'dartanalyzer', Function fileFilter: null}) {
var command = new AnalysisCommand._(
- flavor, displayName, executable, arguments, configurationDir);
+ flavor, displayName, executable, arguments, configurationDir,
+ fileFilter);
return _getUniqueCommand(command);
}
@@ -917,6 +925,7 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
// ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source.
final int ERROR_LEVEL = 0;
final int ERROR_TYPE = 1;
+ final int FILENAME = 3;
final int FORMATTED_ERROR = 7;
AnalysisCommandOutputImpl(command,
@@ -977,6 +986,13 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
}
void parseAnalyzerOutput(List<String> outErrors, List<String> outWarnings) {
+ AnalysisCommand analysisCommand = command;
+ Function fileFilter = analysisCommand.fileFilter;
+ if (fileFilter == null) {
+ // If no filter function was given, we don't filter the output at all.
+ fileFilter = (arg) => true;
+ }
+
// Parse a line delimited by the | character using \ as an escape charager
// like: FOO|BAR|FOO\|BAR|FOO\\BAZ as 4 fields: FOO BAR FOO|BAR FOO\BAZ
List<String> splitMachineError(String line) {
@@ -1004,12 +1020,17 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
for (String line in decodeUtf8(super.stderr).split("\n")) {
if (line.length == 0) continue;
List<String> fields = splitMachineError(line);
- if (fields[ERROR_LEVEL] == 'ERROR') {
- outErrors.add(fields[FORMATTED_ERROR]);
- } else if (fields[ERROR_LEVEL] == 'WARNING') {
- outWarnings.add(fields[FORMATTED_ERROR]);
+ // We only consider errors/warnings for files of interest.
+ if (fields.length > FILENAME) {
+ if (fileFilter(fields[FILENAME])) {
+ if (fields[ERROR_LEVEL] == 'ERROR') {
+ outErrors.add(fields[FORMATTED_ERROR]);
+ } else if (fields[ERROR_LEVEL] == 'WARNING') {
+ outWarnings.add(fields[FORMATTED_ERROR]);
+ }
+ }
+ // OK to Skip error output that doesn't match the machine format
}
- // OK to Skip error output that doesn't match the machine format
}
}
}

Powered by Google App Engine
This is Rietveld 408576698