Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: tools/testing/dart/test_configurations.dart

Issue 2903703002: Tighten types in test.dart even more. (Closed)
Patch Set: Play nicer with strong mode. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/testing/dart/status_reporter.dart ('k') | tools/testing/dart/test_progress.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 test_configurations; 5 library test_configurations;
6 6
7 import "dart:async"; 7 import "dart:async";
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 new Path('tests/lib_strong'), 51 new Path('tests/lib_strong'),
52 new Path('tests/standalone'), 52 new Path('tests/standalone'),
53 new Path('tests/utils'), 53 new Path('tests/utils'),
54 new Path('utils/tests/css'), 54 new Path('utils/tests/css'),
55 new Path('utils/tests/peg'), 55 new Path('utils/tests/peg'),
56 ]; 56 ];
57 57
58 // This file is created by gclient runhooks. 58 // This file is created by gclient runhooks.
59 final VS_TOOLCHAIN_FILE = new Path("build/win_toolchain.json"); 59 final VS_TOOLCHAIN_FILE = new Path("build/win_toolchain.json");
60 60
61 Future testConfigurations(List<Map> configurations) async { 61 Future testConfigurations(List<Map<String, dynamic>> configurations) async {
62 var startTime = new DateTime.now(); 62 var startTime = new DateTime.now();
63 // Extract global options from first configuration. 63 // Extract global options from first configuration.
64 var firstConf = configurations[0]; 64 var firstConf = configurations[0];
65 var maxProcesses = firstConf['tasks'] as int; 65 var maxProcesses = firstConf['tasks'] as int;
66 var progressIndicator = firstConf['progress']; 66 var progressIndicator = firstConf['progress'] as String;
67 BuildbotProgressIndicator.stepName = firstConf['step_name']; 67 BuildbotProgressIndicator.stepName = firstConf['step_name'] as String;
68 var verbose = firstConf['verbose']; 68 var verbose = firstConf['verbose'] as bool;
69 var printTiming = firstConf['time']; 69 var printTiming = firstConf['time'] as bool;
70 var listTests = firstConf['list']; 70 var listTests = firstConf['list'] as bool;
71 71
72 var reportInJson = firstConf['report_in_json']; 72 var reportInJson = firstConf['report_in_json'] as bool;
73 73
74 var recordingPath = firstConf['record_to_file']; 74 var recordingPath = firstConf['record_to_file'] as String;
75 var recordingOutputPath = firstConf['replay_from_file']; 75 var recordingOutputPath = firstConf['replay_from_file'] as String;
76 76
77 Browser.resetBrowserConfiguration = firstConf['reset_browser_configuration']; 77 Browser.resetBrowserConfiguration =
78 firstConf['reset_browser_configuration'] as bool;
78 79
79 if (recordingPath != null && recordingOutputPath != null) { 80 if (recordingPath != null && recordingOutputPath != null) {
80 print("Fatal: Can't have the '--record_to_file' and '--replay_from_file'" 81 print("Fatal: Can't have the '--record_to_file' and '--replay_from_file'"
81 "at the same time. Exiting ..."); 82 "at the same time. Exiting ...");
82 exit(1); 83 exit(1);
83 } 84 }
84 85
85 if (!firstConf['append_logs']) { 86 if (!(firstConf['append_logs'] as bool)) {
86 var files = [ 87 var files = [
87 new File(TestUtils.flakyFileName), 88 new File(TestUtils.flakyFileName),
88 new File(TestUtils.testOutcomeFileName) 89 new File(TestUtils.testOutcomeFileName)
89 ]; 90 ];
90 for (var file in files) { 91 for (var file in files) {
91 if (file.existsSync()) { 92 if (file.existsSync()) {
92 file.deleteSync(); 93 file.deleteSync();
93 } 94 }
94 } 95 }
95 } 96 }
96 97
97 DebugLogger.init( 98 DebugLogger.init(
98 firstConf['write_debug_log'] ? TestUtils.debugLogFilePath : null, 99 firstConf['write_debug_log'] as bool ? TestUtils.debugLogFilePath : null,
99 append: firstConf['append_logs']); 100 append: firstConf['append_logs'] as bool);
100 101
101 // Print the configurations being run by this execution of 102 // Print the configurations being run by this execution of
102 // test.dart. However, don't do it if the silent progress indicator 103 // test.dart. However, don't do it if the silent progress indicator
103 // is used. This is only needed because of the junit tests. 104 // is used. This is only needed because of the junit tests.
104 if (progressIndicator != 'silent') { 105 if (progressIndicator != 'silent') {
105 var outputWords = configurations.length > 1 106 var outputWords = configurations.length > 1
106 ? ['Test configurations:'] 107 ? ['Test configurations:']
107 : ['Test configuration:']; 108 : ['Test configuration:'];
108 for (Map conf in configurations) { 109 for (Map conf in configurations) {
109 List settings = ['compiler', 'runtime', 'mode', 'arch'] 110 List settings = ['compiler', 'runtime', 'mode', 'arch']
110 .map((name) => conf[name]) 111 .map((name) => conf[name])
111 .toList(); 112 .toList();
112 if (conf['checked']) settings.add('checked'); 113 if (conf['checked'] as bool) settings.add('checked');
113 if (conf['strong']) settings.add('strong'); 114 if (conf['strong'] as bool) settings.add('strong');
114 outputWords.add(settings.join('_')); 115 outputWords.add(settings.join('_'));
115 } 116 }
116 print(outputWords.join(' ')); 117 print(outputWords.join(' '));
117 } 118 }
118 119
119 var runningBrowserTests = configurations.any((config) { 120 var runningBrowserTests = configurations.any((config) {
120 return TestUtils.isBrowserRuntime(config['runtime']); 121 return TestUtils.isBrowserRuntime(config['runtime'] as String);
121 }); 122 });
122 123
123 List<Future> serverFutures = []; 124 List<Future> serverFutures = [];
124 var testSuites = <TestSuite>[]; 125 var testSuites = <TestSuite>[];
125 var maxBrowserProcesses = maxProcesses; 126 var maxBrowserProcesses = maxProcesses;
126 if (configurations.length > 1 && 127 if (configurations.length > 1 &&
127 (configurations[0]['test_server_port'] != 0 || 128 (configurations[0]['test_server_port'] != 0 ||
128 configurations[0]['test_server_cross_origin_port'] != 0)) { 129 configurations[0]['test_server_cross_origin_port'] != 0)) {
129 print("If the http server ports are specified, only one configuration" 130 print("If the http server ports are specified, only one configuration"
130 " may be run at a time"); 131 " may be run at a time");
131 exit(1); 132 exit(1);
132 } 133 }
133 for (var conf in configurations) { 134 for (var conf in configurations) {
134 Map<String, RegExp> selectors = conf['selectors']; 135 var selectors = conf['selectors'] as Map<String, RegExp>;
135 var useContentSecurityPolicy = conf['csp']; 136 var useContentSecurityPolicy = conf['csp'] as bool;
136 if (!listTests && runningBrowserTests) { 137 if (!listTests && runningBrowserTests) {
137 // Start global http servers that serve the entire dart repo. 138 // Start global http servers that serve the entire dart repo.
138 // The http server is available on window.location.port, and a second 139 // The http server is available on window.location.port, and a second
139 // server for cross-domain tests can be found by calling 140 // server for cross-domain tests can be found by calling
140 // getCrossOriginPortNumber(). 141 // getCrossOriginPortNumber().
141 var servers = new TestingServers( 142 var servers = new TestingServers(
142 TestUtils.buildDir(conf), 143 TestUtils.buildDir(conf),
143 useContentSecurityPolicy, 144 useContentSecurityPolicy,
144 conf['runtime'], 145 conf['runtime'] as String,
145 null, 146 null,
146 conf['package_root'], 147 conf['package_root'] as String,
147 conf['packages']); 148 conf['packages'] as String);
148 serverFutures.add(servers.startServers(conf['local_ip'], 149 serverFutures.add(servers.startServers(conf['local_ip'] as String,
149 port: conf['test_server_port'], 150 port: conf['test_server_port'] as int,
150 crossOriginPort: conf['test_server_cross_origin_port'])); 151 crossOriginPort: conf['test_server_cross_origin_port'] as int));
151 conf['_servers_'] = servers; 152 conf['_servers_'] = servers;
152 if (verbose) { 153 if (verbose) {
153 serverFutures.last.then((_) { 154 serverFutures.last.then((_) {
154 var commandline = servers.httpServerCommandLine(); 155 var commandline = servers.httpServerCommandLine();
155 print('Started HttpServers: $commandline'); 156 print('Started HttpServers: $commandline');
156 }); 157 });
157 } 158 }
158 } 159 }
159 160
160 if (conf['runtime'].startsWith('ie')) { 161 if ((conf['runtime'] as String).startsWith('ie')) {
161 // NOTE: We've experienced random timeouts of tests on ie9/ie10. The 162 // NOTE: We've experienced random timeouts of tests on ie9/ie10. The
162 // underlying issue has not been determined yet. Our current hypothesis 163 // underlying issue has not been determined yet. Our current hypothesis
163 // is that windows does not handle the IE processes independently. 164 // is that windows does not handle the IE processes independently.
164 // If we have more than one browser and kill a browser we are seeing 165 // If we have more than one browser and kill a browser we are seeing
165 // issues with starting up a new browser just after killing the hanging 166 // issues with starting up a new browser just after killing the hanging
166 // browser. 167 // browser.
167 maxBrowserProcesses = 1; 168 maxBrowserProcesses = 1;
168 } else if (conf['runtime'].startsWith('safari')) { 169 } else if ((conf['runtime'] as String).startsWith('safari')) {
169 // Safari does not allow us to run from a fresh profile, so we can only 170 // Safari does not allow us to run from a fresh profile, so we can only
170 // use one browser. Additionally, you can not start two simulators 171 // use one browser. Additionally, you can not start two simulators
171 // for mobile safari simultainiously. 172 // for mobile safari simultainiously.
172 maxBrowserProcesses = 1; 173 maxBrowserProcesses = 1;
173 } else if (conf['runtime'] == 'chrome' && 174 } else if ((conf['runtime'] as String) == 'chrome' &&
174 Platform.operatingSystem == 'macos') { 175 Platform.operatingSystem == 'macos') {
175 // Chrome on mac results in random timeouts. 176 // Chrome on mac results in random timeouts.
176 // Issue: https://github.com/dart-lang/sdk/issues/23891 177 // Issue: https://github.com/dart-lang/sdk/issues/23891
177 // This change does not fix the problem. 178 // This change does not fix the problem.
178 maxBrowserProcesses = math.max(1, maxBrowserProcesses ~/ 2); 179 maxBrowserProcesses = math.max(1, maxBrowserProcesses ~/ 2);
179 } else if (conf['runtime'] != 'drt') { 180 } else if ((conf['runtime'] as String) != 'drt') {
180 // Even on machines with more than 16 processors, don't open more 181 // Even on machines with more than 16 processors, don't open more
181 // than 15 browser instances, to avoid overloading the machine. 182 // than 15 browser instances, to avoid overloading the machine.
182 // This is especially important when running locally on powerful 183 // This is especially important when running locally on powerful
183 // desktops. 184 // desktops.
184 maxBrowserProcesses = math.min(maxBrowserProcesses, 15); 185 maxBrowserProcesses = math.min(maxBrowserProcesses, 15);
185 } 186 }
186 187
187 // If we specifically pass in a suite only run that. 188 // If we specifically pass in a suite only run that.
188 if (conf['suite_dir'] != null) { 189 if (conf['suite_dir'] != null) {
189 var suite_path = new Path(conf['suite_dir']); 190 var suite_path = new Path(conf['suite_dir'] as String);
190 testSuites.add(new PKGTestSuite(conf, suite_path)); 191 testSuites.add(new PKGTestSuite(conf, suite_path));
191 } else { 192 } else {
192 for (final testSuiteDir in TEST_SUITE_DIRECTORIES) { 193 for (final testSuiteDir in TEST_SUITE_DIRECTORIES) {
193 final name = testSuiteDir.filename; 194 final name = testSuiteDir.filename;
194 if (selectors.containsKey(name)) { 195 if (selectors.containsKey(name)) {
195 testSuites 196 testSuites
196 .add(new StandardTestSuite.forDirectory(conf, testSuiteDir)); 197 .add(new StandardTestSuite.forDirectory(conf, testSuiteDir));
197 } 198 }
198 } 199 }
199 for (String key in selectors.keys) { 200 for (String key in selectors.keys) {
200 if (key == 'co19') { 201 if (key == 'co19') {
201 testSuites.add(new Co19TestSuite(conf)); 202 testSuites.add(new Co19TestSuite(conf));
202 } else if ((conf['compiler'] == 'dartk' || 203 } else if ((conf['compiler'] == 'dartk' ||
203 conf['compiler'] == 'none') && 204 conf['compiler'] == 'none') &&
204 conf['runtime'] == 'vm' && 205 conf['runtime'] == 'vm' &&
205 key == 'vm') { 206 key == 'vm') {
206 // vm tests contain both cc tests (added here) and dart tests (added 207 // vm tests contain both cc tests (added here) and dart tests (added
207 // in [TEST_SUITE_DIRECTORIES]). 208 // in [TEST_SUITE_DIRECTORIES]).
208 testSuites.add(new VMTestSuite(conf)); 209 testSuites.add(new VMTestSuite(conf));
209 } else if (conf['analyzer']) { 210 } else if (conf['analyzer'] as bool) {
210 if (key == 'analyze_library') { 211 if (key == 'analyze_library') {
211 testSuites.add(new AnalyzeLibraryTestSuite(conf)); 212 testSuites.add(new AnalyzeLibraryTestSuite(conf));
212 } 213 }
213 } 214 }
214 } 215 }
215 } 216 }
216 } 217 }
217 218
218 void allTestsFinished() { 219 void allTestsFinished() {
219 for (var conf in configurations) { 220 for (var conf in configurations) {
(...skipping 29 matching lines...) Expand all
249 var printFailureSummary = progressIndicator != 'buildbot'; 250 var printFailureSummary = progressIndicator != 'buildbot';
250 eventListener.add(new TestFailurePrinter(printFailureSummary, formatter)); 251 eventListener.add(new TestFailurePrinter(printFailureSummary, formatter));
251 } 252 }
252 eventListener.add( 253 eventListener.add(
253 ProgressIndicator.fromName(progressIndicator, startTime, formatter)); 254 ProgressIndicator.fromName(progressIndicator, startTime, formatter));
254 if (printTiming) { 255 if (printTiming) {
255 eventListener.add(new TimingPrinter(startTime)); 256 eventListener.add(new TimingPrinter(startTime));
256 } 257 }
257 eventListener.add(new SkippedCompilationsPrinter()); 258 eventListener.add(new SkippedCompilationsPrinter());
258 } 259 }
259 if (firstConf['write_test_outcome_log']) { 260 if (firstConf['write_test_outcome_log'] as bool) {
260 eventListener.add(new TestOutcomeLogWriter()); 261 eventListener.add(new TestOutcomeLogWriter());
261 } 262 }
262 if (firstConf['copy_coredumps']) { 263 if (firstConf['copy_coredumps'] as bool) {
263 eventListener.add(new UnexpectedCrashLogger()); 264 eventListener.add(new UnexpectedCrashLogger());
264 } 265 }
265 266
266 // The only progress indicator when listing tests should be the 267 // The only progress indicator when listing tests should be the
267 // the summary printer. 268 // the summary printer.
268 if (listTests) { 269 if (listTests) {
269 eventListener.add(new SummaryPrinter(jsonOnly: reportInJson)); 270 eventListener.add(new SummaryPrinter(jsonOnly: reportInJson));
270 } else { 271 } else {
271 eventListener.add(new ExitCodeSetter()); 272 eventListener.add(new ExitCodeSetter());
272 eventListener.add(new IgnoredTestMonitor()); 273 eventListener.add(new IgnoredTestMonitor());
273 } 274 }
274 275
275 // If any of the configurations need to access android devices we'll first 276 // If any of the configurations need to access android devices we'll first
276 // make a pool of all available adb devices. 277 // make a pool of all available adb devices.
277 AdbDevicePool adbDevicePool; 278 AdbDevicePool adbDevicePool;
278 bool needsAdbDevicePool = configurations.any((Map conf) { 279 var needsAdbDevicePool = configurations.any((Map conf) {
279 return conf['runtime'] == 'dart_precompiled' && conf['system'] == 'android'; 280 return conf['runtime'] == 'dart_precompiled' && conf['system'] == 'android';
280 }); 281 });
281 if (needsAdbDevicePool) { 282 if (needsAdbDevicePool) {
282 adbDevicePool = await AdbDevicePool.create(); 283 adbDevicePool = await AdbDevicePool.create();
283 } 284 }
284 285
285 // Start all the HTTP servers required before starting the process queue. 286 // Start all the HTTP servers required before starting the process queue.
286 if (!serverFutures.isEmpty) { 287 if (!serverFutures.isEmpty) {
287 await Future.wait(serverFutures); 288 await Future.wait(serverFutures);
288 } 289 }
(...skipping 19 matching lines...) Expand all
308 maxBrowserProcesses, 309 maxBrowserProcesses,
309 startTime, 310 startTime,
310 testSuites, 311 testSuites,
311 eventListener, 312 eventListener,
312 allTestsFinished, 313 allTestsFinished,
313 verbose, 314 verbose,
314 recordingPath, 315 recordingPath,
315 recordingOutputPath, 316 recordingOutputPath,
316 adbDevicePool); 317 adbDevicePool);
317 } 318 }
OLDNEW
« no previous file with comments | « tools/testing/dart/status_reporter.dart ('k') | tools/testing/dart/test_progress.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698