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

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

Issue 9302034: Make test.dart use the path of the running script to find the Dart checkout. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix copyright dates. Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("status_file_parser"); 5 #library("status_file_parser");
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("status_expression.dart"); 8 #import("status_expression.dart");
9 9
10 // Possible outcomes of running a test. 10 // Possible outcomes of running a test.
11 final CRASH = "crash"; 11 final CRASH = "crash";
(...skipping 15 matching lines...) Expand all
27 BooleanExpression condition; 27 BooleanExpression condition;
28 List<TestRule> testRules; 28 List<TestRule> testRules;
29 29
30 Section.always() : condition = null, testRules = new List<TestRule>(); 30 Section.always() : condition = null, testRules = new List<TestRule>();
31 Section(this.condition) : testRules = new List<TestRule>(); 31 Section(this.condition) : testRules = new List<TestRule>();
32 32
33 bool isEnabled(environment) => 33 bool isEnabled(environment) =>
34 condition == null || condition.evaluate(environment); 34 condition == null || condition.evaluate(environment);
35 } 35 }
36 36
37
38 // Helper method to be able to run the test from the runtime
39 // directory, or the top directory.
40 String getFilename(String path) =>
41 new File(path).existsSync() ? path : '../$path';
42
43 String getDirname(String path) =>
44 new Directory(path).existsSync() ? path : '../$path';
45
46 void ReadTestExpectationsInto(TestExpectations expectations, 37 void ReadTestExpectationsInto(TestExpectations expectations,
47 String statusFilePath, 38 String statusFilePath,
48 environment, 39 environment,
49 onDone) { 40 onDone) {
50 List<Section> sections = new List<Section>(); 41 List<Section> sections = new List<Section>();
51 42
52 void sectionsRead() { 43 void sectionsRead() {
53 for (Section section in sections) { 44 for (Section section in sections) {
54 if (section.isEnabled(environment)) { 45 if (section.isEnabled(environment)) {
55 for (var rule in section.testRules) { 46 for (var rule in section.testRules) {
56 expectations.addRule(rule, environment); 47 expectations.addRule(rule, environment);
57 } 48 }
58 } 49 }
59 } 50 }
60 onDone(); 51 onDone();
61 } 52 }
62 53
63 ReadConfigurationInto(statusFilePath, sections, sectionsRead); 54 ReadConfigurationInto(statusFilePath, sections, sectionsRead);
64 } 55 }
65 56
66 void ReadConfigurationInto(path, sections, onDone) { 57 void ReadConfigurationInto(path, sections, onDone) {
67 File file = new File(getFilename(path)); 58 File file = new File(path);
68 if (!file.existsSync()) return; // TODO(whesse): Handle missing file. 59 if (!file.existsSync()) return; // TODO(whesse): Handle missing file.
69 InputStream file_stream = file.openInputStream(); 60 InputStream file_stream = file.openInputStream();
70 StringInputStream lines = new StringInputStream(file_stream); 61 StringInputStream lines = new StringInputStream(file_stream);
71 62
72 Section current = new Section.always(); 63 Section current = new Section.always();
73 sections.add(current); 64 sections.add(current);
74 String prefix = ""; 65 String prefix = "";
75 66
76 lines.lineHandler = () { 67 lines.lineHandler = () {
77 String line; 68 String line;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 234 }
244 regExps[i] = regExp; 235 regExps[i] = regExp;
245 } 236 }
246 _keyToRegExps[key] = regExps; 237 _keyToRegExps[key] = regExps;
247 }); 238 });
248 239
249 _regExpCache = null; 240 _regExpCache = null;
250 _preprocessed = true; 241 _preprocessed = true;
251 } 242 }
252 } 243 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698