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

Side by Side Diff: tools/testing/dart/status_file_parser.dart

Issue 8335008: Add status_file_parser.dart library, and tests for it, to the Dart rewrite of the test suite runner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename library to status_file_parser. Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/src/StatusFileParserTest.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4
5 #library("status_file_parser");
6
7
8 #import("status_expression.dart");
9
10 final RegExp StripComment = const RegExp("^[^#]*");
11 final RegExp HeaderPattern = const RegExp(@"\[([^\]]+)\]");
12 final RegExp RulePattern = const RegExp(@"\s*([^: ]*)\s*:(.*)");
13 final RegExp PrefixPattern = const RegExp(@"^\s*prefix\s+([\w\_\.\-\/]+)\s*$");
14
15 // TODO(whesse): Implement configuration_info library that contains data
16 // structures for test configuration, including Section.
17 class Section {
18 BooleanExpression condition;
19
20 Section.always() : condition = null;
21 Section(this.condition);
22 }
23
24
25 // Helper method to be able to run the test from the runtime
26 // directory, or the top directory.
27 String getFilename(String path) =>
28 new File(path).existsSync() ? path : '../$path';
29
30
31 void ReadConfigurationInto(path, sections) {
32 File file = new File(getFilename(path));
33 Expect.isTrue(file.existsSync()); // TODO(whesse): Handle missing file.
34 FileInputStream file_stream = file.openInputStream();
35 StringInputStream lines = new StringInputStream(file_stream);
36
37 Section current = new Section.always();
38 sections.add(current);
39 String prefix = "";
40
41 String line;
42 while ((line = lines.readLine()) != null) {
43 Match match = StripComment.firstMatch(line);
44 line = (match == null) ? "" : match[0];
45 line = line.trim();
46 if (line == "") continue;
47
48 match = HeaderPattern.firstMatch(line);
49 if (match != null) {
50 String condition_string = match[1].trim();
51 List<String> tokens = new Tokenizer(condition_string).tokenize();
52 ExpressionParser parser = new ExpressionParser(new Scanner(tokens));
53 current = new Section(parser.parseBooleanExpression());
54 sections.add(current);
55 continue;
56 }
57
58 match = RulePattern.firstMatch(line);
59 if (match != null) {
60 String path = prefix + match[1].trim();
61 String expression_string = match[2].trim();
62 List<String> tokens = new Tokenizer(expression_string).tokenize();
63 SetExpression expression =
64 new ExpressionParser(new Scanner(tokens)).parseSetExpression();
65 // TODO(whesse): Save rule in configuration data structure.
66 continue;
67 }
68
69 match = PrefixPattern.firstMatch(line);
70 if (match != null) {
71 prefix = match[1];
72 continue;
73 }
74
75 print("unmatched line: $line");
76 }
77
78 file_stream.close();
79 }
80
OLDNEW
« no previous file with comments | « tests/standalone/src/StatusFileParserTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698