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

Side by Side Diff: tools/testing/dart/status_file.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: 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/StatusFileTest.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");
Mads Ager (google) 2011/10/31 16:05:20 status_file_parser maybe?
Bill Hesse 2011/11/02 10:15:44 Done.
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 String SplitPath(String path) => path;
Mads Ager (google) 2011/10/31 16:05:20 Could you comment on this identity function. Is th
Bill Hesse 2011/11/02 10:15:44 Done.
31
32 void ReadConfigurationInto(path, sections) {
33 File file = new File(getFilename(path));
34 Expect.isTrue(file.existsSync()); // TODO(whesse): Handle missing file.
35 FileInputStream file_stream = file.openInputStream();
36 StringInputStream lines = new StringInputStream(file_stream);
37
38 Section current = new Section.always();
39 sections.add(current);
40 String prefix = "";
41
Mads Ager (google) 2011/10/31 16:05:20 Remove extra blank line?
Bill Hesse 2011/11/02 10:15:44 Done.
42
43 while (true) {
Mads Ager (google) 2011/10/31 16:05:20 We could do something like: String line; while ((
Bill Hesse 2011/11/02 10:15:44 Done.
44 String line = lines.readLine();
45 if (line == null) break;
46 Match match = StripComment.firstMatch(line);
47 line = (match == null) ? "" : match[0];
48 line = line.trim();
49 if (line == "") continue;
50
51 match = HeaderPattern.firstMatch(line);
52 if (match != null) {
53 String condition_string = match[1].trim();
54 List<String> tokens = new Tokenizer(condition_string).tokenize();
55 ExpressionParser parser = new ExpressionParser(new Scanner(tokens));
56 current = new Section(parser.parseBooleanExpression());
57 sections.add(current);
58 continue;
59 }
60
61 match = RulePattern.firstMatch(line);
62 if (match != null) {
63 String path = prefix + SplitPath(match[1].trim());
Mads Ager (google) 2011/10/31 16:05:20 Since SplitPath is the identify function, I would
Bill Hesse 2011/11/02 10:15:44 Done.
64 String expression_string = match[2].trim();
65 List<String> tokens = new Tokenizer(expression_string).tokenize();
66 SetExpression expression =
67 new ExpressionParser(new Scanner(tokens)).parseSetExpression();
68 // TODO(whesse): Save rule in configuration data structure.
69 continue;
70 }
71
72 match = PrefixPattern.firstMatch(line);
73 if (match != null) {
74 prefix = SplitPath(match[1]);
Mads Ager (google) 2011/10/31 16:05:20 Add a TODO here as well?
Bill Hesse 2011/11/02 10:15:44 Done.
75 continue;
76 }
77
78 print("unmatched line: $line");
79 }
80
81 file_stream.close();
82 }
83
OLDNEW
« no previous file with comments | « tests/standalone/src/StatusFileTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698