Chromium Code Reviews| 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("co19_test_config"); | 5 #library("co19_test_config"); |
| 6 | 6 |
| 7 #import("../../tools/testing/dart/test_runner.dart"); | 7 #import("../../tools/testing/dart/test_runner.dart"); |
| 8 #import("../../tools/testing/dart/status_file_parser.dart"); | 8 #import("../../tools/testing/dart/status_file_parser.dart"); |
| 9 | 9 |
| 10 class Co19TestSuite { | 10 class Co19TestSuite { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 configuration["timeout"], | 101 configuration["timeout"], |
| 102 completeHandler, | 102 completeHandler, |
| 103 expectations, | 103 expectations, |
| 104 isNegative)); | 104 isNegative)); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 Map testOptions(String filename) { | 110 Map testOptions(String filename) { |
| 111 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); | 111 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); |
|
Bill Hesse
2011/11/16 13:47:24
.* does not match newline, so these can match sing
Mads Ager (google)
2011/11/16 14:40:37
Yes, thanks. I actually didn't think about that. I
| |
| 112 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); | 112 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); |
| 113 | |
| 114 // Read the entire file into a byte buffer and transform it to a | |
| 115 // String. This will treat the file as ascii but the only parts | |
| 116 // we are interested in will be ascii in any case. | |
| 113 File file = new File(filename); | 117 File file = new File(filename); |
| 114 FileInputStream fileStream = file.openInputStream(); | 118 file.openSync(); |
| 115 StringInputStream lines = new StringInputStream(fileStream); | 119 List chars = new List(file.lengthSync()); |
| 120 var offset = 0; | |
| 121 while (offset != chars.length) { | |
| 122 offset += file.readListSync(chars, offset, chars.length - offset); | |
| 123 } | |
| 124 file.closeSync(); | |
| 125 String contents = new String.fromCharCodes(chars); | |
| 126 chars = null; | |
| 116 | 127 |
| 128 // Find the options in the file. | |
| 117 List<List> result = new List<List>(); | 129 List<List> result = new List<List>(); |
| 118 List<String> dartOptions; | 130 List<String> dartOptions; |
| 119 bool isNegative = false; | 131 bool isNegative = false; |
| 120 String line; | 132 |
| 121 while ((line = lines.readLine()) != null) { | 133 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); |
| 122 Match match = testOptionsRegExp.firstMatch(line); | 134 for (var match in matches) { |
| 123 if (match != null) { | 135 result.add(match[1].split(' ').filter((e) => e != '')); |
| 124 result.add(match[1].split(' ').filter((e) => e != '')); | 136 } |
| 137 | |
| 138 matches = dartOptionsRegExp.allMatches(contents); | |
| 139 for (var match in matches) { | |
| 140 if (dartOptions != null) { | |
| 141 throw new Exception( | |
| 142 'More than one "// DartOptions=" line in test $filename'); | |
| 125 } | 143 } |
| 144 dartOptions = match[1].split(' ').filter((e) => e != ''); | |
| 145 } | |
| 126 | 146 |
| 127 match = dartOptionsRegExp.firstMatch(line); | 147 if (contents.contains("@compile-error") || |
| 128 if (match != null) { | 148 contents.contains("@runtime-error")) { |
| 129 if (dartOptions != null) { | 149 isNegative = true; |
| 130 throw new Exception( | 150 } else if (contents.contains("@dynamic-type-error") && |
| 131 'More than one "// DartOptions=" line in test $filename'); | 151 configuration['checked']) { |
| 132 } | 152 isNegative = true; |
| 133 dartOptions = match[1].split(' ').filter((e) => e != ''); | 153 } |
| 134 } | |
| 135 | 154 |
| 136 if (line.contains("@compile-error") || line.contains("@runtime-error")) { | |
| 137 isNegative = true; | |
| 138 } else if (line.contains("@dynamic-type-error") && | |
| 139 configuration['checked']) { | |
| 140 isNegative = true; | |
| 141 } | |
| 142 } | |
| 143 return { "vmOptions": result, | 155 return { "vmOptions": result, |
| 144 "dartOptions": dartOptions, | 156 "dartOptions": dartOptions, |
| 145 "isNegative" : isNegative }; | 157 "isNegative" : isNegative }; |
| 146 } | 158 } |
| 147 | 159 |
| 148 void completeHandler(TestCase testCase) { | 160 void completeHandler(TestCase test) { |
| 149 } | 161 } |
| 150 } | 162 } |
| OLD | NEW |