| 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"; |
| 11 Function doTest; | 12 Function doTest; |
| 12 Function doDone; | 13 Function doDone; |
| 13 String shellPath; | 14 String shellPath; |
| 14 String pathSeparator; | 15 String pathSeparator; |
| 15 | 16 |
| 16 CorelibTestSuite() { | 17 CorelibTestSuite() { |
| 17 shellPath = getDartShellFileName() ; | 18 shellPath = getDartShellFileName() ; |
| 18 pathSeparator = new Platform().pathSeparator(); | 19 pathSeparator = new Platform().pathSeparator(); |
| 19 } | 20 } |
| 20 | 21 |
| 21 void forEachTest(Function onTest, [Function onDone = null]) { | 22 void forEachTest(Function onTest, [Function onDone = null]) { |
| 22 doTest = onTest; | 23 doTest = onTest; |
| 23 doDone = onDone; | 24 doDone = onDone; |
| 24 processDirectory(); | 25 processDirectory(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void processDirectory() { | 28 void processDirectory() { |
| 29 directoryPath = getDirname(directoryPath); |
| 28 Directory dir = new Directory(directoryPath); | 30 Directory dir = new Directory(directoryPath); |
| 29 if (!dir.existsSync()) { | 31 dir.errorHandler = (s) { |
| 30 dir = new Directory(".." + pathSeparator + directoryPath); | 32 throw s; |
| 31 Expect.isTrue(dir.existsSync(), | 33 }; |
| 32 "Cannot find tests/corelib/src or ../tests/corelib/src"); | |
| 33 // TODO(ager): Use dir.errorHandler instead when it is implemented. | |
| 34 } | |
| 35 dir.fileHandler = processFile; | 34 dir.fileHandler = processFile; |
| 36 dir.doneHandler = doDone; | 35 dir.doneHandler = doDone; |
| 37 dir.list(false); | 36 dir.list(false); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void processFile(String filename) { | 39 void processFile(String filename) { |
| 41 if (filename.endsWith("Test.dart")) { | 40 if (filename.endsWith("Test.dart")) { |
| 42 int start = filename.lastIndexOf(pathSeparator); | 41 int start = filename.lastIndexOf(pathSeparator); |
| 43 String displayName = filename.substring(start + 1, filename.length - 5); | 42 String displayName = filename.substring(start + 1, filename.length - 5); |
| 44 // TODO(whesse): Gather test case info from status file and test file. | 43 // TODO(whesse): Gather test case info from status file and test file. |
| 45 doTest(new TestCase(displayName, | 44 doTest(new TestCase(displayName, |
| 46 shellPath, | 45 shellPath, |
| 47 <String>["--enable_type_checks", | 46 <String>["--enable_type_checks", |
| 48 "--ignore-unrecognized-flags", | 47 "--ignore-unrecognized-flags", |
| 49 filename ], | 48 filename ], |
| 50 completeHandler, | 49 completeHandler, |
| 51 new Set.from([PASS, FAIL, CRASH, TIMEOUT]))); | 50 new Set.from([PASS, FAIL, CRASH, TIMEOUT]))); |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 | 53 |
| 55 void completeHandler(TestCase testCase) { | 54 void completeHandler(TestCase testCase) { |
| 56 TestOutput output = testCase.output; | 55 TestOutput output = testCase.output; |
| 57 print("Exit code: ${output.exitCode} Time: ${output.time}"); | 56 print("Exit code: ${output.exitCode} Time: ${output.time}"); |
| 58 } | 57 } |
| 59 } | 58 } |
| OLD | NEW |