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