| 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("standalone_test_config"); | 5 #library("standalone_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 StandaloneTestSuite { | 9 class StandaloneTestSuite extends StandardTestSuite { |
| 12 String directoryPath = "tests/standalone/src"; | 10 StandaloneTestSuite(Map configuration) |
| 13 final String statusFilePath = "tests/standalone/standalone.status"; | 11 : super(configuration, |
| 14 Function doTest; | 12 "tests/standalone/src", |
| 15 Function doDone; | 13 ["tests/standalone/standalone.status"]); |
| 16 String shellPath; | |
| 17 String pathSeparator; | |
| 18 Map configuration; | |
| 19 TestExpectations testExpectations; | |
| 20 | |
| 21 StandaloneTestSuite(Map this.configuration) { | |
| 22 shellPath = getDartShellFileName(configuration) ; | |
| 23 pathSeparator = new Platform().pathSeparator(); | |
| 24 } | |
| 25 | |
| 26 void forEachTest(Function onTest, [Function onDone = null]) { | |
| 27 doTest = onTest; | |
| 28 doDone = (ignore) => onDone(); | |
| 29 | |
| 30 // Read test expectations from status file. | |
| 31 testExpectations = new TestExpectations(); | |
| 32 ReadTestExpectationsInto(testExpectations, statusFilePath, configuration); | |
| 33 | |
| 34 processDirectory(); | |
| 35 } | |
| 36 | |
| 37 void processDirectory() { | |
| 38 directoryPath = getDirname(directoryPath); | |
| 39 Directory dir = new Directory(directoryPath); | |
| 40 dir.errorHandler = (s) { | |
| 41 throw s; | |
| 42 }; | |
| 43 dir.fileHandler = processFile; | |
| 44 dir.doneHandler = doDone; | |
| 45 dir.list(false); | |
| 46 } | |
| 47 | |
| 48 void processFile(String filename) { | |
| 49 if (!filename.endsWith("Test.dart")) return; | |
| 50 | |
| 51 // If patterns are given only list the files that match one of the | |
| 52 // patterns. | |
| 53 var patterns = configuration['patterns']; | |
| 54 if (!patterns.isEmpty() && | |
| 55 !patterns.some((re) => re.hasMatch(filename))) { | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 int start = filename.lastIndexOf(pathSeparator); | |
| 60 String testName = filename.substring(start + 1, filename.length - 5); | |
| 61 Set<String> expectations = testExpectations.expectations(testName); | |
| 62 | |
| 63 if (expectations.contains(SKIP)) return; | |
| 64 | |
| 65 var optionsFromFile = TestUtils.optionsFromFile(filename, configuration); | |
| 66 var argumentLists = | |
| 67 TestUtils.argumentLists(filename, optionsFromFile, configuration); | |
| 68 for (var args in argumentLists) { | |
| 69 var timeout = configuration['timeout']; | |
| 70 var isNegative = optionsFromFile['isNegative']; | |
| 71 doTest(new TestCase(testName, | |
| 72 shellPath, | |
| 73 args, | |
| 74 timeout, | |
| 75 completeHandler, | |
| 76 expectations, | |
| 77 isNegative)); | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 void completeHandler(TestCase testCase) { | |
| 82 } | |
| 83 } | 14 } |
| OLD | NEW |