| 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/status_file_parser.dart"); | 7 #import("../../tools/testing/dart/test_suite.dart"); |
| 8 #import("../../tools/testing/dart/test_config_utils.dart"); | |
| 9 #import("../../tools/testing/dart/test_runner.dart"); | |
| 10 | 8 |
| 11 class Co19TestSuite { | 9 class Co19TestSuite extends StandardTestSuite { |
| 12 String directoryPath = "tests/co19/src"; | 10 RegExp _testRegExp = const RegExp(@"t[0-9]{2}.dart$"); |
| 13 Function doTest; | |
| 14 Function doDone; | |
| 15 String shellPath; | |
| 16 String pathSeparator; | |
| 17 Map configuration; | |
| 18 TestExpectations testExpectations; | |
| 19 RegExp testRegExp; | |
| 20 | 11 |
| 21 Co19TestSuite(Map this.configuration) { | 12 Co19TestSuite(Map configuration) |
| 22 shellPath = getDartShellFileName(configuration) ; | 13 : super(configuration, |
| 23 pathSeparator = new Platform().pathSeparator(); | 14 "tests/co19/src", |
| 24 testRegExp = new RegExp(@"t[0-9]{2}.dart$"); | 15 ["tests/co19/co19-compiler.status", |
| 25 } | 16 "tests/co19/co19-runtime.status", |
| 17 "tests/co19/co19-frog.status"]); |
| 26 | 18 |
| 27 void forEachTest(Function onTest, [Function onDone = null]) { | 19 bool isTestFile(String filename) => _testRegExp.hasMatch(filename); |
| 28 doTest = onTest; | 20 void listRecursively() => true; |
| 29 doDone = (ignore) => onDone(); | 21 void complexStatusMatching() => true; |
| 30 | |
| 31 // Read test expectations from status file. | |
| 32 testExpectations = new TestExpectations(complexMatching: true); | |
| 33 ReadTestExpectationsInto(testExpectations, | |
| 34 "tests/co19/co19-compiler.status", | |
| 35 configuration); | |
| 36 ReadTestExpectationsInto(testExpectations, | |
| 37 "tests/co19/co19-frog.status", | |
| 38 configuration); | |
| 39 ReadTestExpectationsInto(testExpectations, | |
| 40 "tests/co19/co19-runtime.status", | |
| 41 configuration); | |
| 42 | |
| 43 processDirectory(directoryPath); | |
| 44 } | |
| 45 | |
| 46 void processDirectory(String path) { | |
| 47 path = getDirname(path); | |
| 48 Directory dir = new Directory(path); | |
| 49 dir.errorHandler = (s) { | |
| 50 throw s; | |
| 51 }; | |
| 52 dir.fileHandler = processFile; | |
| 53 dir.doneHandler = doDone; | |
| 54 dir.list(recursive: true); | |
| 55 } | |
| 56 | |
| 57 void processFile(String filename) { | |
| 58 if (!testRegExp.hasMatch(filename)) return; | |
| 59 | |
| 60 // If patterns are given only list the files that match one of the | |
| 61 // patterns. | |
| 62 var patterns = configuration['patterns']; | |
| 63 if (!patterns.isEmpty() && | |
| 64 !patterns.some((re) => re.hasMatch(filename))) { | |
| 65 return; | |
| 66 } | |
| 67 | |
| 68 int start = filename.lastIndexOf('src' + pathSeparator); | |
| 69 String testName = filename.substring(start + 4, filename.length - 5); | |
| 70 Set<String> expectations = testExpectations.expectations(testName); | |
| 71 | |
| 72 if (expectations.contains(SKIP)) return; | |
| 73 | |
| 74 var optionsFromFile = TestUtils.optionsFromFile(filename, configuration); | |
| 75 var argumentLists = | |
| 76 TestUtils.argumentLists(filename, optionsFromFile, configuration); | |
| 77 for (var args in argumentLists) { | |
| 78 var timeout = configuration['timeout']; | |
| 79 var isNegative = optionsFromFile['isNegative']; | |
| 80 doTest(new TestCase(testName, | |
| 81 shellPath, | |
| 82 args, | |
| 83 timeout, | |
| 84 completeHandler, | |
| 85 expectations, | |
| 86 isNegative)); | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 void completeHandler(TestCase test) { | |
| 91 } | |
| 92 } | 22 } |
| OLD | NEW |