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("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 | 9 |
| 9 class CorelibTestSuite { | 10 class CorelibTestSuite { |
| 10 final String directoryPath = "tests/corelib/src"; | 11 String directoryPath = "tests/corelib/src"; |
| 12 final String statusFilePath = "tests/corelib/corelib.status"; | |
| 11 Function doTest; | 13 Function doTest; |
| 12 Function doDone; | 14 Function doDone; |
| 13 String shellPath; | 15 String shellPath; |
| 14 String pathSeparator; | 16 String pathSeparator; |
| 17 Map<String, String> configuration; | |
| 18 TestExpectationsMap testExpectationsMap; | |
| 15 | 19 |
| 16 CorelibTestSuite() { | 20 CorelibTestSuite() { |
| 17 shellPath = getDartShellFileName() ; | 21 shellPath = getDartShellFileName() ; |
| 18 pathSeparator = new Platform().pathSeparator(); | 22 pathSeparator = new Platform().pathSeparator(); |
| 23 configuration = {"mode": "debug", | |
|
Mads Ager (google)
2011/11/10 16:31:57
In the next changelist we can replace this with th
| |
| 24 "arch": "ia32", | |
| 25 "checked": "true", | |
| 26 "component": "vm", | |
| 27 "system": new Platform().operatingSystem()}; | |
| 19 } | 28 } |
| 20 | 29 |
| 21 void forEachTest(Function onTest, [Function onDone = null]) { | 30 void forEachTest(Function onTest, [Function onDone = null]) { |
| 22 doTest = onTest; | 31 doTest = onTest; |
| 23 doDone = onDone; | 32 doDone = onDone; |
| 33 | |
| 34 // Read test expectations from status file. | |
| 35 testExpectationsMap = ReadTestExpectations(statusFilePath, configuration); | |
| 36 | |
| 24 processDirectory(); | 37 processDirectory(); |
| 25 } | 38 } |
| 26 | 39 |
| 27 void processDirectory() { | 40 void processDirectory() { |
| 41 directoryPath = getDirname(directoryPath); | |
| 28 Directory dir = new Directory(directoryPath); | 42 Directory dir = new Directory(directoryPath); |
| 29 if (!dir.existsSync()) { | 43 Expect.isTrue(dir.existsSync(), |
| 30 dir = new Directory(".." + pathSeparator + directoryPath); | 44 "Cannot find tests/corelib/src or ../tests/corelib/src"); |
| 31 Expect.isTrue(dir.existsSync(), | |
| 32 "Cannot find tests/corelib/src or ../tests/corelib/src"); | |
| 33 // TODO(ager): Use dir.errorHandler instead when it is implemented. | 45 // TODO(ager): Use dir.errorHandler instead when it is implemented. |
| 34 } | |
| 35 dir.fileHandler = processFile; | 46 dir.fileHandler = processFile; |
| 36 dir.doneHandler = doDone; | 47 dir.doneHandler = doDone; |
| 37 dir.list(false); | 48 dir.list(false); |
| 38 } | 49 } |
| 39 | 50 |
| 40 void processFile(String filename) { | 51 void processFile(String filename) { |
| 41 if (filename.endsWith("Test.dart")) { | 52 if (!filename.endsWith("Test.dart")) return; |
| 42 int start = filename.lastIndexOf(pathSeparator); | 53 |
| 43 String displayName = filename.substring(start + 1, filename.length - 5); | 54 Expect.isTrue(filename.contains(directoryPath)); |
| 44 // TODO(whesse): Gather test case info from status file and test file. | 55 int start = filename.lastIndexOf(pathSeparator); |
| 45 doTest(new TestCase(displayName, | 56 String testName = filename.substring(start + 1, filename.length - 5); |
| 46 shellPath, | 57 Set<String> expectations = testExpectationsMap.expectations(testName); |
| 47 <String>["--enable_type_checks", | 58 |
| 48 "--ignore-unrecognized-flags", | 59 // TODO(whesse): Skip files with internal directives, and multipart files, |
| 49 filename ], | 60 // until they are handled correctly. |
| 50 completeHandler, | 61 if (expectations.contains(SKIP)) return; |
| 51 new Set.from([PASS, FAIL, CRASH, TIMEOUT]))); | 62 |
| 52 } | 63 |
| 64 doTest(new TestCase(testName, | |
| 65 shellPath, | |
| 66 <String>["--enable_type_checks", | |
| 67 "--ignore-unrecognized-flags", | |
| 68 filename ], | |
| 69 completeHandler, | |
| 70 expectations)); | |
| 53 } | 71 } |
| 54 | 72 |
| 55 void completeHandler(TestCase testCase) { | 73 void completeHandler(TestCase testCase) { |
| 56 TestOutput output = testCase.output; | 74 TestOutput output = testCase.output; |
| 57 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}"); | |
| 58 } | 81 } |
| 59 } | 82 } |
| OLD | NEW |