| OLD | NEW |
| 1 // Copyright (c) 2012, 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"; |
| 12 final TIMEOUT = "timeout"; | 12 final TIMEOUT = "timeout"; |
| 13 final FAIL = "fail"; | 13 final FAIL = "fail"; |
| 14 final PASS = "pass"; | 14 final PASS = "pass"; |
| 15 // An indication to skip the test. The caller is responsible for skipping it. | 15 // An indication to skip the test. The caller is responsible for skipping it. |
| 16 final SKIP = "skip"; | 16 final SKIP = "skip"; |
| 17 final OK = "ok"; | 17 final OK = "ok"; |
| 18 | 18 |
| 19 final RegExp StripComment = const RegExp("^[^#]*"); | 19 final RegExp StripComment = const RegExp("^[^#]*"); |
| 20 final RegExp HeaderPattern = const RegExp(@"^\[([^\]]+)\]"); | 20 final RegExp HeaderPattern = const RegExp(@"^\[([^\]]+)\]"); |
| 21 final RegExp RulePattern = const RegExp(@"\s*([^: ]*)\s*:(.*)"); | 21 final RegExp RulePattern = const RegExp(@"\s*([^: ]*)\s*:(.*)"); |
| 22 final RegExp PrefixPattern = const RegExp(@"^\s*prefix\s+([\w\_\.\-\/]+)\s*$"); | |
| 23 | 22 |
| 24 // TODO(whesse): Implement configuration_info library that contains data | 23 // TODO(whesse): Implement configuration_info library that contains data |
| 25 // structures for test configuration, including Section. | 24 // structures for test configuration, including Section. |
| 26 class Section { | 25 class Section { |
| 27 BooleanExpression condition; | 26 BooleanExpression condition; |
| 28 List<TestRule> testRules; | 27 List<TestRule> testRules; |
| 29 | 28 |
| 30 Section.always() : condition = null, testRules = new List<TestRule>(); | 29 Section.always() : condition = null, testRules = new List<TestRule>(); |
| 31 Section(this.condition) : testRules = new List<TestRule>(); | 30 Section(this.condition) : testRules = new List<TestRule>(); |
| 32 | 31 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 void ReadConfigurationInto(path, sections, onDone) { | 56 void ReadConfigurationInto(path, sections, onDone) { |
| 58 File file = new File(path); | 57 File file = new File(path); |
| 59 if (!file.existsSync()) { | 58 if (!file.existsSync()) { |
| 60 throw new Exception('Cannot find test status file $path'); | 59 throw new Exception('Cannot find test status file $path'); |
| 61 } | 60 } |
| 62 InputStream file_stream = file.openInputStream(); | 61 InputStream file_stream = file.openInputStream(); |
| 63 StringInputStream lines = new StringInputStream(file_stream); | 62 StringInputStream lines = new StringInputStream(file_stream); |
| 64 | 63 |
| 65 Section current = new Section.always(); | 64 Section current = new Section.always(); |
| 66 sections.add(current); | 65 sections.add(current); |
| 67 String prefix = ""; | |
| 68 | 66 |
| 69 lines.onLine = () { | 67 lines.onLine = () { |
| 70 String line; | 68 String line; |
| 71 while ((line = lines.readLine()) != null) { | 69 while ((line = lines.readLine()) != null) { |
| 72 Match match = StripComment.firstMatch(line); | 70 Match match = StripComment.firstMatch(line); |
| 73 line = (match == null) ? "" : match[0]; | 71 line = (match == null) ? "" : match[0]; |
| 74 line = line.trim(); | 72 line = line.trim(); |
| 75 if (line.isEmpty()) continue; | 73 if (line.isEmpty()) continue; |
| 76 | 74 |
| 77 match = HeaderPattern.firstMatch(line); | 75 match = HeaderPattern.firstMatch(line); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 89 String name = match[1].trim(); | 87 String name = match[1].trim(); |
| 90 // TODO(whesse): Handle test names ending in a wildcard (*). | 88 // TODO(whesse): Handle test names ending in a wildcard (*). |
| 91 String expression_string = match[2].trim(); | 89 String expression_string = match[2].trim(); |
| 92 List<String> tokens = new Tokenizer(expression_string).tokenize(); | 90 List<String> tokens = new Tokenizer(expression_string).tokenize(); |
| 93 SetExpression expression = | 91 SetExpression expression = |
| 94 new ExpressionParser(new Scanner(tokens)).parseSetExpression(); | 92 new ExpressionParser(new Scanner(tokens)).parseSetExpression(); |
| 95 current.testRules.add(new TestRule(name, expression)); | 93 current.testRules.add(new TestRule(name, expression)); |
| 96 continue; | 94 continue; |
| 97 } | 95 } |
| 98 | 96 |
| 99 match = PrefixPattern.firstMatch(line); | |
| 100 if (match != null) { | |
| 101 prefix = match[1]; | |
| 102 continue; | |
| 103 } | |
| 104 | |
| 105 print("unmatched line: $line"); | 97 print("unmatched line: $line"); |
| 106 } | 98 } |
| 107 }; | 99 }; |
| 108 | 100 |
| 109 lines.onClosed = () { | 101 lines.onClosed = () { |
| 110 onDone(); | 102 onDone(); |
| 111 }; | 103 }; |
| 112 } | 104 } |
| 113 | 105 |
| 114 | 106 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 197 } |
| 206 regExps[i] = regExp; | 198 regExps[i] = regExp; |
| 207 } | 199 } |
| 208 _keyToRegExps[key] = regExps; | 200 _keyToRegExps[key] = regExps; |
| 209 }); | 201 }); |
| 210 | 202 |
| 211 _regExpCache = null; | 203 _regExpCache = null; |
| 212 _preprocessed = true; | 204 _preprocessed = true; |
| 213 } | 205 } |
| 214 } | 206 } |
| OLD | NEW |