OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /** | 6 /** |
7 * This file is the entrypoint of the dart test suite. This suite is used | 7 * This file is the entrypoint of the dart test suite. This suite is used |
8 * to test: | 8 * to test: |
9 * | 9 * |
10 * 1. the dart vm | 10 * 1. the dart vm |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // Extract global options from first configuration. | 75 // Extract global options from first configuration. |
76 var firstConf = configurations[0]; | 76 var firstConf = configurations[0]; |
77 Map<String, RegExp> selectors = firstConf['selectors']; | 77 Map<String, RegExp> selectors = firstConf['selectors']; |
78 var maxProcesses = firstConf['tasks']; | 78 var maxProcesses = firstConf['tasks']; |
79 var progressIndicator = firstConf['progress']; | 79 var progressIndicator = firstConf['progress']; |
80 BuildbotProgressIndicator.stepName = firstConf['step_name']; | 80 BuildbotProgressIndicator.stepName = firstConf['step_name']; |
81 var verbose = firstConf['verbose']; | 81 var verbose = firstConf['verbose']; |
82 var printTiming = firstConf['time']; | 82 var printTiming = firstConf['time']; |
83 var listTests = firstConf['list']; | 83 var listTests = firstConf['list']; |
84 | 84 |
85 if (!firstConf['append_flaky_log']) { | 85 if (!firstConf['append_flaky_log']) { |
86 var file = new File(TestUtils.flakyFileName()); | 86 var file = new File(TestUtils.flakyFileName()); |
87 if (file.existsSync()) { | 87 if (file.existsSync()) { |
88 file.deleteSync(); | 88 file.deleteSync(); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 // Print the configurations being run by this execution of | 92 // Print the configurations being run by this execution of |
93 // test.dart. However, don't do it if the silent progress indicator | 93 // test.dart. However, don't do it if the silent progress indicator |
94 // is used. This is only needed because of the junit tests. | 94 // is used. This is only needed because of the junit tests. |
95 if (progressIndicator != 'silent') { | 95 if (progressIndicator != 'silent') { |
96 List output_words = configurations.length > 1 ? | 96 List output_words = configurations.length > 1 ? |
97 ['Test configurations:'] : ['Test configuration:']; | 97 ['Test configurations:'] : ['Test configuration:']; |
98 for (Map conf in configurations) { | 98 for (Map conf in configurations) { |
99 List settings = | 99 List settings = |
100 ['compiler', 'runtime', 'mode', 'arch'].map((name) => conf[name]); | 100 ['compiler', 'runtime', 'mode', 'arch'].map((name) => conf[name]); |
101 if (conf['checked']) settings.add('checked'); | 101 if (conf['checked']) settings.add('checked'); |
102 output_words.add(Strings.join(settings, '_')); | 102 output_words.add(Strings.join(settings, '_')); |
103 } | 103 } |
104 print(Strings.join(output_words, ' ')); | 104 print(Strings.join(output_words, ' ')); |
105 } | 105 } |
106 | 106 |
107 // Start global http servers that serve the entire dart repo. | |
108 // The http server is available on window.location.port, and a second server | |
109 // for cross-domain tests can be found by calling getCrossOriginPortNumber(). | |
110 List serverList = []; | |
111 if (!listTests) { | |
112 // Only start the server if we are running browser tests. | |
113 var runningBrowserTests = configurations.some((config) { | |
114 return TestUtils.isBrowserRuntime(config['runtime']); | |
115 }); | |
116 if (runningBrowserTests) { | |
117 serverList.add(startHttpServer('127.0.0.1')); | |
118 // We start two servers so that we can test cross-domain tests. | |
119 serverList.add(startHttpServer('127.0.0.1', serverList[0].port)); | |
120 } | |
121 } | |
122 | |
123 var configurationIterator = configurations.iterator(); | 107 var configurationIterator = configurations.iterator(); |
124 void enqueueConfiguration(ProcessQueue queue) { | 108 void enqueueConfiguration(ProcessQueue queue) { |
125 if (!configurationIterator.hasNext) return; | 109 if (!configurationIterator.hasNext) return; |
126 | 110 |
127 var conf = configurationIterator.next(); | 111 var conf = configurationIterator.next(); |
128 for (String key in selectors.keys) { | 112 for (String key in selectors.keys) { |
129 if (key == 'co19') { | 113 if (key == 'co19') { |
130 queue.addTestSuite(new Co19TestSuite(conf)); | 114 queue.addTestSuite(new Co19TestSuite(conf)); |
131 } else if (conf['runtime'] == 'vm' && key == 'vm') { | 115 } else if (conf['runtime'] == 'vm' && key == 'vm') { |
132 // vm tests contain both cc tests (added here) and dart tests (added in | 116 // vm tests contain both cc tests (added here) and dart tests (added in |
133 // [TEST_SUITE_DIRECTORIES]). | 117 // [TEST_SUITE_DIRECTORIES]). |
134 queue.addTestSuite(new VMTestSuite(conf)); | 118 queue.addTestSuite(new VMTestSuite(conf)); |
135 } else if (conf['compiler'] == 'dartc' && key == 'dartc') { | 119 } else if (conf['compiler'] == 'dartc' && key == 'dartc') { |
136 queue.addTestSuite(new SamplesDartcTestSuite(conf)); | 120 queue.addTestSuite(new SamplesDartcTestSuite(conf)); |
137 queue.addTestSuite(new JUnitDartcTestSuite(conf)); | 121 queue.addTestSuite(new JUnitDartcTestSuite(conf)); |
138 } | 122 } |
139 } | 123 } |
140 | 124 |
141 for (final testSuiteDir in TEST_SUITE_DIRECTORIES) { | 125 for (final testSuiteDir in TEST_SUITE_DIRECTORIES) { |
142 final name = testSuiteDir.filename; | 126 final name = testSuiteDir.filename; |
143 if (selectors.containsKey(name)) { | 127 if (selectors.containsKey(name)) { |
144 queue.addTestSuite( | 128 queue.addTestSuite( |
145 new StandardTestSuite.forDirectory(conf, testSuiteDir, serverList)); | 129 new StandardTestSuite.forDirectory(conf, testSuiteDir)); |
146 } | 130 } |
147 } | 131 } |
148 } | 132 } |
149 | 133 |
| 134 // Start global http server that serves the entire dart repo. |
| 135 // The http server is available on localhost:9876 for any |
| 136 // test that needs to load resources from the repo over http. |
| 137 if (!listTests) { |
| 138 // Only start the server if we are running browser tests. |
| 139 var runningBrowserTests = configurations.some((config) { |
| 140 return TestUtils.isBrowserRuntime(config['runtime']); |
| 141 }); |
| 142 if (runningBrowserTests) startHttpServer('127.0.0.1', 9876); |
| 143 } |
| 144 |
150 // Start process queue. | 145 // Start process queue. |
151 new ProcessQueue(maxProcesses, | 146 new ProcessQueue(maxProcesses, |
152 progressIndicator, | 147 progressIndicator, |
153 startTime, | 148 startTime, |
154 printTiming, | 149 printTiming, |
155 enqueueConfiguration, | 150 enqueueConfiguration, |
156 () => terminateHttpServers(serverList), | 151 () => terminateHttpServer(), |
157 verbose, | 152 verbose, |
158 listTests); | 153 listTests); |
159 } | 154 } |
OLD | NEW |