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; |
17 TestSettingMap testSettingMap; | |
18 Configuration configuration; | |
15 | 19 |
16 StandaloneTestSuite() { | 20 StandaloneTestSuite() { |
17 shellPath = getDartShellFileName() ; | 21 shellPath = getDartShellFileName() ; |
18 pathSeparator = new Platform().pathSeparator(); | 22 pathSeparator = new Platform().pathSeparator(); |
23 testSettingMap = new TestSettingMap(); | |
24 configuration = new Configuration({"mode":"debug", | |
25 "arch":"ia32", | |
26 "checked":"false", | |
27 "component":"vm", | |
28 "system": | |
29 new Platform().operatingSystem()}); | |
Mads Ager (google)
2011/11/09 14:46:53
How about avoiding this indentation by doing:
con
Bill Hesse
2011/11/09 14:55:39
Done.
Mads Ager (google)
2011/11/09 15:12:35
Could you upload a new snapshot?
| |
19 } | 30 } |
20 | 31 |
21 void forEachTest(Function onTest, [Function onDone = null]) { | 32 void forEachTest(Function onTest, [Function onDone = null]) { |
22 doTest = onTest; | 33 doTest = onTest; |
23 doDone = onDone; | 34 doDone = onDone; |
35 | |
36 // Read configuration from status file. | |
37 List<Section> sections = new List<Section>(); | |
38 ReadConfigurationInto(statusFilePath, sections); | |
39 for (Section section in sections) { | |
40 if (configuration.isEnabled(section)) { | |
41 for (var testSetting in section.testSettings) { | |
42 testSettingMap.addTest(testSetting, configuration); | |
Mads Ager (google)
2011/11/09 14:46:53
What is a testSetting and why does the testSetting
Bill Hesse
2011/11/09 14:55:39
This is the immediate next thing to be implemented
Mads Ager (google)
2011/11/09 15:12:35
OK, I would still leave it out of this change unti
| |
43 } | |
44 } | |
45 } | |
46 | |
24 processDirectory(); | 47 processDirectory(); |
25 } | 48 } |
26 | 49 |
27 void processDirectory() { | 50 void processDirectory() { |
51 directoryPath = getDirname(directoryPath); | |
28 Directory dir = new Directory(directoryPath); | 52 Directory dir = new Directory(directoryPath); |
29 if (!dir.existsSync()) { | 53 Expect.isTrue(dir.existsSync(), |
30 dir = new Directory(".." + pathSeparator + directoryPath); | 54 "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. | 55 // TODO(ager): Use dir.errorHandler instead when it is implemented. |
34 } | |
35 dir.fileHandler = processFile; | 56 dir.fileHandler = processFile; |
36 dir.doneHandler = doDone; | 57 dir.doneHandler = doDone; |
37 dir.list(false); | 58 dir.list(false); |
38 } | 59 } |
39 | 60 |
40 void processFile(String filename) { | 61 void processFile(String filename) { |
41 if (filename.endsWith("Test.dart")) { | 62 if (!filename.endsWith("Test.dart")) return; |
42 int start = filename.lastIndexOf(pathSeparator); | 63 |
43 String displayName = filename.substring(start + 1, filename.length - 5); | 64 Expect.isTrue(filename.contains(directoryPath)); |
44 // TODO(whesse): Gather test case info from status file and test file. | 65 String testName = filename.substring( |
Mads Ager (google)
2011/11/09 14:46:53
I linked what you had before much better. This loo
Bill Hesse
2011/11/09 14:55:39
The reason for the complication is that some test
Mads Ager (google)
2011/11/09 15:12:35
OK, in that case should you make the directory lis
| |
45 doTest(new TestCase(displayName, | 66 filename.indexOf(directoryPath) + directoryPath.length + 1, |
46 shellPath, | 67 filename.length - ".dart".length); |
47 <String>["--enable_type_checks", | 68 Set<String> expectations = testSettingMap.expectations(testName); |
Mads Ager (google)
2011/11/09 14:46:53
I would leave this out for now as well. It doesn't
Bill Hesse
2011/11/09 14:55:39
I wanted the design, and the stubs. That way, I c
Mads Ager (google)
2011/11/09 15:12:35
Same as above. I would wait until it does somethin
| |
48 "--ignore-unrecognized-flags", | 69 expectations.addAll(ExpectationsFromFile(filename)); |
49 filename ], | 70 if (expectations.contains(SKIP)) return; |
50 completeHandler, | 71 |
51 new Set.from([PASS, FAIL, CRASH, TIMEOUT]))); | 72 doTest(new TestCase(testName, |
52 } | 73 shellPath, |
74 <String>["--enable_type_checks", | |
75 "--ignore-unrecognized-flags", | |
76 filename ], | |
77 completeHandler, | |
78 expectations)); | |
53 } | 79 } |
54 | 80 |
55 void completeHandler(TestCase testCase) { | 81 void completeHandler(TestCase testCase) { |
56 TestOutput output = testCase.output; | 82 TestOutput output = testCase.output; |
57 print("Exit code: ${output.exitCode} Time: ${output.time}"); | 83 print("Exit code: ${output.exitCode} Time: ${output.time}"); |
58 } | 84 } |
59 } | 85 } |
86 | |
87 | |
88 class Configuration { | |
89 Map<String, String> environment; | |
90 | |
91 Configuration(this.environment); | |
92 | |
93 bool isEnabled(Section section) => | |
94 section.condition == null || section.condition.evaluate(environment); | |
95 } | |
96 | |
97 class TestSettingMap { | |
98 TestSettingMap(); | |
99 | |
100 void addTest(testSetting, Configuration configuration) { } | |
101 | |
102 Set<String> expectations(String filename) => | |
103 new Set.from([PASS, FAIL, CRASH, TIMEOUT]); | |
104 } | |
105 | |
106 | |
107 Collection<String> ExpectationsFromFile(String fileName) { | |
108 return new List<String>(); | |
109 } | |
OLD | NEW |