| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 7 |
| 8 #import("status_expression.dart"); | 8 #import("status_expression.dart"); |
| 9 | 9 |
| 10 final RegExp StripComment = const RegExp("^[^#]*"); | 10 final RegExp StripComment = const RegExp("^[^#]*"); |
| 11 final RegExp HeaderPattern = const RegExp(@"\[([^\]]+)\]"); | 11 final RegExp HeaderPattern = const RegExp(@"\[([^\]]+)\]"); |
| 12 final RegExp RulePattern = const RegExp(@"\s*([^: ]*)\s*:(.*)"); | 12 final RegExp RulePattern = const RegExp(@"\s*([^: ]*)\s*:(.*)"); |
| 13 final RegExp PrefixPattern = const RegExp(@"^\s*prefix\s+([\w\_\.\-\/]+)\s*$"); | 13 final RegExp PrefixPattern = const RegExp(@"^\s*prefix\s+([\w\_\.\-\/]+)\s*$"); |
| 14 | 14 |
| 15 // TODO(whesse): Implement configuration_info library that contains data | 15 // TODO(whesse): Implement configuration_info library that contains data |
| 16 // structures for test configuration, including Section. | 16 // structures for test configuration, including Section. |
| 17 class Section { | 17 class Section { |
| 18 BooleanExpression condition; | 18 BooleanExpression condition; |
| 19 Collection testSettings = const []; |
| 19 | 20 |
| 20 Section.always() : condition = null; | 21 Section.always() : condition = null; |
| 21 Section(this.condition); | 22 Section(this.condition); |
| 22 } | 23 } |
| 23 | 24 |
| 24 | 25 |
| 25 // Helper method to be able to run the test from the runtime | 26 // Helper method to be able to run the test from the runtime |
| 26 // directory, or the top directory. | 27 // directory, or the top directory. |
| 27 String getFilename(String path) => | 28 String getFilename(String path) => |
| 28 new File(path).existsSync() ? path : '../$path'; | 29 new File(path).existsSync() ? path : '../$path'; |
| 29 | 30 |
| 31 String getDirname(String path) => |
| 32 new Directory(path).existsSync() ? path : '../$path'; |
| 33 |
| 30 | 34 |
| 31 void ReadConfigurationInto(path, sections) { | 35 void ReadConfigurationInto(path, sections) { |
| 32 File file = new File(getFilename(path)); | 36 File file = new File(getFilename(path)); |
| 33 if (!file.existsSync()) return; // TODO(whesse): Handle missing file. | 37 if (!file.existsSync()) return; // TODO(whesse): Handle missing file. |
| 34 FileInputStream file_stream = file.openInputStream(); | 38 FileInputStream file_stream = file.openInputStream(); |
| 35 StringInputStream lines = new StringInputStream(file_stream); | 39 StringInputStream lines = new StringInputStream(file_stream); |
| 36 | 40 |
| 37 Section current = new Section.always(); | 41 Section current = new Section.always(); |
| 38 sections.add(current); | 42 sections.add(current); |
| 39 String prefix = ""; | 43 String prefix = ""; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 prefix = match[1]; | 75 prefix = match[1]; |
| 72 continue; | 76 continue; |
| 73 } | 77 } |
| 74 | 78 |
| 75 print("unmatched line: $line"); | 79 print("unmatched line: $line"); |
| 76 } | 80 } |
| 77 | 81 |
| 78 file_stream.close(); | 82 file_stream.close(); |
| 79 } | 83 } |
| 80 | 84 |
| OLD | NEW |