| 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/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 StandaloneTestSuite { | 10 class StandaloneTestSuite { |
| 11 String directoryPath = "tests/standalone/src"; | 11 String directoryPath = "tests/standalone/src"; |
| 12 final String statusFilePath = "tests/standalone/standalone.status"; | 12 final String statusFilePath = "tests/standalone/standalone.status"; |
| 13 Function doTest; | 13 Function doTest; |
| 14 Function doDone; | 14 Function doDone; |
| 15 String shellPath; | 15 String shellPath; |
| 16 String pathSeparator; | 16 String pathSeparator; |
| 17 Map configuration; | 17 Map configuration; |
| 18 TestExpectationsMap testExpectationsMap; | 18 TestExpectations testExpectations; |
| 19 | 19 |
| 20 StandaloneTestSuite(Map this.configuration) { | 20 StandaloneTestSuite(Map this.configuration) { |
| 21 shellPath = getDartShellFileName(configuration) ; | 21 shellPath = getDartShellFileName(configuration) ; |
| 22 pathSeparator = new Platform().pathSeparator(); | 22 pathSeparator = new Platform().pathSeparator(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void forEachTest(Function onTest, [Function onDone = null]) { | 25 void forEachTest(Function onTest, [Function onDone = null]) { |
| 26 doTest = onTest; | 26 doTest = onTest; |
| 27 doDone = (ignore) => onDone(); | 27 doDone = (ignore) => onDone(); |
| 28 | 28 |
| 29 // Read test expectations from status file. | 29 // Read test expectations from status file. |
| 30 testExpectationsMap = ReadTestExpectations(statusFilePath, configuration); | 30 testExpectations = new TestExpectations(); |
| 31 ReadTestExpectationsInto(testExpectations, statusFilePath, configuration); |
| 31 | 32 |
| 32 processDirectory(); | 33 processDirectory(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void processDirectory() { | 36 void processDirectory() { |
| 36 directoryPath = getDirname(directoryPath); | 37 directoryPath = getDirname(directoryPath); |
| 37 Directory dir = new Directory(directoryPath); | 38 Directory dir = new Directory(directoryPath); |
| 38 dir.errorHandler = (s) { | 39 dir.errorHandler = (s) { |
| 39 throw s; | 40 throw s; |
| 40 }; | 41 }; |
| 41 dir.fileHandler = processFile; | 42 dir.fileHandler = processFile; |
| 42 dir.doneHandler = doDone; | 43 dir.doneHandler = doDone; |
| 43 dir.list(false); | 44 dir.list(false); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void processFile(String filename) { | 47 void processFile(String filename) { |
| 47 if (!filename.endsWith("Test.dart")) return; | 48 if (!filename.endsWith("Test.dart")) return; |
| 48 | 49 |
| 49 // If patterns are given only list the files that match one of the | 50 // If patterns are given only list the files that match one of the |
| 50 // patterns. | 51 // patterns. |
| 51 var patterns = configuration['patterns']; | 52 var patterns = configuration['patterns']; |
| 52 if (!patterns.isEmpty() && | 53 if (!patterns.isEmpty() && |
| 53 !patterns.some((re) => re.hasMatch(filename))) { | 54 !patterns.some((re) => re.hasMatch(filename))) { |
| 54 return; | 55 return; |
| 55 } | 56 } |
| 56 | 57 |
| 57 int start = filename.lastIndexOf(pathSeparator); | 58 int start = filename.lastIndexOf(pathSeparator); |
| 58 String testName = filename.substring(start + 1, filename.length - 5); | 59 String testName = filename.substring(start + 1, filename.length - 5); |
| 59 Set<String> expectations = testExpectationsMap.expectations(testName); | 60 Set<String> expectations = testExpectations.expectations(testName); |
| 60 | 61 |
| 61 // TODO(whesse): Skip files with internal directives, and multipart files, | |
| 62 // until they are handled correctly. | |
| 63 if (expectations.contains(SKIP)) return; | 62 if (expectations.contains(SKIP)) return; |
| 64 | 63 |
| 65 List args = ["--ignore-unrecognized-flags"]; | 64 List args = ["--ignore-unrecognized-flags"]; |
| 66 if (configuration["checked"]) { | 65 if (configuration["checked"]) { |
| 67 args.add("--enable_type_checks"); | 66 args.add("--enable_type_checks"); |
| 68 } | 67 } |
| 69 if (configuration["component"] == "leg") { | 68 if (configuration["component"] == "leg") { |
| 70 args.add("--enable_leg"); | 69 args.add("--enable_leg"); |
| 71 } | 70 } |
| 72 | 71 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 118 } |
| 120 dartOptions = match[1].split(' ').filter((e) => e != ''); | 119 dartOptions = match[1].split(' ').filter((e) => e != ''); |
| 121 } | 120 } |
| 122 } | 121 } |
| 123 return {"vmOptions": result, "dartOptions": dartOptions}; | 122 return {"vmOptions": result, "dartOptions": dartOptions}; |
| 124 } | 123 } |
| 125 | 124 |
| 126 void completeHandler(TestCase testCase) { | 125 void completeHandler(TestCase testCase) { |
| 127 } | 126 } |
| 128 } | 127 } |
| OLD | NEW |