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