OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #library("standalone_test_config"); |
| 6 |
| 7 #import("../../tools/testing/dart/test_runner.dart"); |
| 8 |
| 9 class StandaloneTestSuite { |
| 10 final String directoryPath = "tests/standalone/src"; |
| 11 Function doTest; |
| 12 Function doDone; |
| 13 String shellPath; |
| 14 String pathSeparator; |
| 15 |
| 16 StandaloneTestSuite() { |
| 17 shellPath = getDartShellFileName() ; |
| 18 pathSeparator = new Platform().pathSeparator(); |
| 19 } |
| 20 |
| 21 void forEachTest(Function onTest, [Function onDone = null]) { |
| 22 doTest = onTest; |
| 23 doDone = onDone; |
| 24 processDirectory(); |
| 25 } |
| 26 |
| 27 void processDirectory() { |
| 28 Directory dir = new Directory(directoryPath); |
| 29 if (!dir.existsSync()) { |
| 30 dir = new Directory(".." + pathSeparator + directoryPath); |
| 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. |
| 34 } |
| 35 dir.fileHandler = processFile; |
| 36 dir.doneHandler = doDone; |
| 37 dir.list(false); |
| 38 } |
| 39 |
| 40 void processFile(String filename) { |
| 41 if (filename.endsWith("Test.dart")) { |
| 42 int start = filename.lastIndexOf(pathSeparator); |
| 43 String displayName = filename.substring(start + 1, filename.length - 5); |
| 44 // TODO(whesse): Gather test case info from status file and test file. |
| 45 doTest(new TestCase(displayName, |
| 46 shellPath, |
| 47 <String>["--enable_type_checks", |
| 48 "--ignore-unrecognized-flags", |
| 49 filename ], |
| 50 completeHandler, |
| 51 new Set.from([PASS, FAIL, CRASH, TIMEOUT]))); |
| 52 } |
| 53 } |
| 54 |
| 55 void completeHandler(TestCase testCase) { |
| 56 TestOutput output = testCase.output; |
| 57 print("Exit code: ${output.exitCode} Time: ${output.time}"); |
| 58 } |
| 59 } |
OLD | NEW |