| 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("corelib_test_config"); | 5 #library("corelib_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 CorelibTestSuite { | 10 class CorelibTestSuite { |
| 11 String directoryPath = "tests/corelib/src"; | 11 String directoryPath = "tests/corelib/src"; |
| 12 final String statusFilePath = "tests/corelib/corelib.status"; |
| 12 Function doTest; | 13 Function doTest; |
| 13 Function doDone; | 14 Function doDone; |
| 14 String shellPath; | 15 String shellPath; |
| 15 String pathSeparator; | 16 String pathSeparator; |
| 17 Map<String, String> configuration; |
| 18 TestExpectationsMap testExpectationsMap; |
| 16 | 19 |
| 17 CorelibTestSuite() { | 20 CorelibTestSuite() { |
| 18 shellPath = getDartShellFileName() ; | 21 shellPath = getDartShellFileName() ; |
| 19 pathSeparator = new Platform().pathSeparator(); | 22 pathSeparator = new Platform().pathSeparator(); |
| 23 configuration = {"mode": "debug", |
| 24 "arch": "ia32", |
| 25 "checked": "true", |
| 26 "component": "vm", |
| 27 "system": new Platform().operatingSystem()}; |
| 20 } | 28 } |
| 21 | 29 |
| 22 void forEachTest(Function onTest, [Function onDone = null]) { | 30 void forEachTest(Function onTest, [Function onDone = null]) { |
| 23 doTest = onTest; | 31 doTest = onTest; |
| 24 doDone = onDone; | 32 doDone = onDone; |
| 33 |
| 34 // Read test expectations from status file. |
| 35 testExpectationsMap = ReadTestExpectations(statusFilePath, configuration); |
| 36 |
| 25 processDirectory(); | 37 processDirectory(); |
| 26 } | 38 } |
| 27 | 39 |
| 28 void processDirectory() { | 40 void processDirectory() { |
| 29 directoryPath = getDirname(directoryPath); | 41 directoryPath = getDirname(directoryPath); |
| 30 Directory dir = new Directory(directoryPath); | 42 Directory dir = new Directory(directoryPath); |
| 31 dir.errorHandler = (s) { | 43 dir.errorHandler = (s) { |
| 32 throw s; | 44 throw s; |
| 33 }; | 45 }; |
| 34 dir.fileHandler = processFile; | 46 dir.fileHandler = processFile; |
| 35 dir.doneHandler = doDone; | 47 dir.doneHandler = doDone; |
| 36 dir.list(false); | 48 dir.list(false); |
| 37 } | 49 } |
| 38 | 50 |
| 39 void processFile(String filename) { | 51 void processFile(String filename) { |
| 40 if (filename.endsWith("Test.dart")) { | 52 if (!filename.endsWith("Test.dart")) return; |
| 41 int start = filename.lastIndexOf(pathSeparator); | 53 |
| 42 String displayName = filename.substring(start + 1, filename.length - 5); | 54 Expect.isTrue(filename.contains(directoryPath)); |
| 43 // TODO(whesse): Gather test case info from status file and test file. | 55 int start = filename.lastIndexOf(pathSeparator); |
| 44 doTest(new TestCase(displayName, | 56 String testName = filename.substring(start + 1, filename.length - 5); |
| 45 shellPath, | 57 Set<String> expectations = testExpectationsMap.expectations(testName); |
| 46 <String>["--enable_type_checks", | 58 |
| 47 "--ignore-unrecognized-flags", | 59 // TODO(whesse): Skip files with internal directives, and multipart files, |
| 48 filename ], | 60 // until they are handled correctly. |
| 49 completeHandler, | 61 if (expectations.contains(SKIP)) return; |
| 50 new Set.from([PASS, FAIL, CRASH, TIMEOUT]))); | 62 |
| 51 } | 63 |
| 64 doTest(new TestCase(testName, |
| 65 shellPath, |
| 66 <String>["--enable_type_checks", |
| 67 "--ignore-unrecognized-flags", |
| 68 filename ], |
| 69 completeHandler, |
| 70 expectations)); |
| 52 } | 71 } |
| 53 | 72 |
| 54 void completeHandler(TestCase testCase) { | 73 void completeHandler(TestCase testCase) { |
| 55 TestOutput output = testCase.output; | 74 TestOutput output = testCase.output; |
| 56 print("Exit code: ${output.exitCode} Time: ${output.time}"); | 75 String expected = ""; |
| 76 testCase.expectedOutcomes.forEach((value) { expected += value + " "; }); |
| 77 print(""); |
| 78 print(testCase.displayName); |
| 79 print(" Result:${output.result} Expected:$expected"); |
| 80 print(" Exit code: ${output.exitCode} Time: ${output.time}"); |
| 57 } | 81 } |
| 58 } | 82 } |
| OLD | NEW |