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

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

Issue 2914893003: Revert "Replace the configuration map with a typed object." (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « tools/testing/dart/status_expression.dart ('k') | tools/testing/dart/status_reporter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/status_file.dart
diff --git a/tools/testing/dart/status_file.dart b/tools/testing/dart/status_file.dart
index 8df6a70c575083fd4b7c175a49120f63af57cbfc..cd2d65f2f9511fadf5a356abb930d42fae257000 100644
--- a/tools/testing/dart/status_file.dart
+++ b/tools/testing/dart/status_file.dart
@@ -4,9 +4,7 @@
import 'dart:io';
-import 'environment.dart';
import 'expectation.dart';
-import 'path.dart';
import 'status_expression.dart';
/// Splits out a trailing line comment
@@ -45,32 +43,19 @@ final _issuePattern = new RegExp("[Ii]ssue ([0-9]+)");
/// Entries may also appear before any section header, in which case they
/// always apply.
class StatusFile {
- final String _path;
final List<StatusSection> sections = [];
- /// Parses the status file at [_path].
- StatusFile.read(this._path) {
- var lines = new File(_path).readAsLinesSync();
+ /// Parses the status file at [path].
+ StatusFile.read(String path) {
+ var lines = new File(path).readAsLinesSync();
// The current section whose rules are being parsed.
StatusSection section;
var lineNumber = 0;
-
for (var line in lines) {
lineNumber++;
- fail(String message, [List<String> errors]) {
- print('$message in "$_shortPath" line $lineNumber:\n$line');
-
- if (errors != null) {
- for (var error in errors) {
- print("- ${error.replaceAll('\n', '\n ')}");
- }
- }
- exit(1);
- }
-
// Strip off the comment and whitespace.
var match = _commentPattern.firstMatch(line);
var source = "";
@@ -86,22 +71,9 @@ class StatusFile {
// See if we are starting a new section.
match = _sectionPattern.firstMatch(source);
if (match != null) {
- try {
- var condition = Expression.parse(match[1].trim());
-
- var errors = <String>[];
- condition.validate(errors);
-
- if (errors.isNotEmpty) {
- var s = errors.length > 1 ? "s" : "";
- fail('Validation error$s', errors);
- }
-
- section = new StatusSection(condition);
- sections.add(section);
- } on FormatException {
- fail("Status expression syntax error");
- }
+ var condition = Expression.parse(match[1].trim());
+ section = new StatusSection(condition);
+ sections.add(section);
continue;
}
@@ -110,16 +82,7 @@ class StatusFile {
if (match != null) {
var path = match[1].trim();
// TODO(whesse): Handle test names ending in a wildcard (*).
- var expectations = <Expectation>[];
- for (var name in match[2].split(",")) {
- name = name.trim();
- try {
- expectations.add(Expectation.find(name));
- } on ArgumentError {
- fail('Unrecognized test expectation "$name"');
- }
- }
-
+ var expectations = _parseExpectations(match[2]);
var issue = _issueNumber(comment);
// If we haven't found a section header yet, create an implicit section
@@ -133,16 +96,17 @@ class StatusFile {
continue;
}
- fail("Unrecognized input");
+ throw new FormatException(
+ "Could not parse line $lineNumber of status file '$path':\n$line");
}
}
- /// Gets the path to this status file relative to the Dart repo root.
- String get _shortPath {
- var repoRoot = new Path(Platform.script
- .toFilePath(windows: Platform.operatingSystem == "windows"))
- .join(new Path("../../../../"));
- return new Path(_path).relativeTo(repoRoot).toString();
+ /// Parses a comma-separated list of expectation names from [text].
+ List<Expectation> _parseExpectations(String text) {
+ return text
+ .split(",")
+ .map((name) => Expectation.find(name.trim()))
+ .toList();
}
/// Returns the issue number embedded in [comment] or `null` if there is none.
@@ -184,7 +148,7 @@ class StatusSection {
final List<StatusEntry> entries = [];
/// Returns true if this section should apply in the given [environment].
- bool isEnabled(Environment environment) =>
+ bool isEnabled(Map<String, dynamic> environment) =>
_condition == null || _condition.evaluate(environment);
StatusSection(this._condition);
« no previous file with comments | « tools/testing/dart/status_expression.dart ('k') | tools/testing/dart/status_reporter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698