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

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

Issue 11343008: Land update to tools directory with new binaries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tools/testing/dart/status_file_parser.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_options_parser"); 5 #library("test_options_parser");
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:math"); 8 #import("dart:math");
9 #import("drt_updater.dart"); 9 #import("drt_updater.dart");
10 #import("test_suite.dart"); 10 #import("test_suite.dart");
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 347
348 // Multiple uses of a flag are an error, because there is no 348 // Multiple uses of a flag are an error, because there is no
349 // naturally correct way to handle conflicting options. 349 // naturally correct way to handle conflicting options.
350 if (configuration.containsKey(spec.name)) { 350 if (configuration.containsKey(spec.name)) {
351 print('Error: test.dart disallows multiple "--${spec.name}" flags'); 351 print('Error: test.dart disallows multiple "--${spec.name}" flags');
352 exit(1); 352 exit(1);
353 } 353 }
354 // Parse the value for the option. 354 // Parse the value for the option.
355 if (spec.type == 'bool') { 355 if (spec.type == 'bool') {
356 if (!value.isEmpty()) { 356 if (!value.isEmpty) {
357 print('No value expected for bool option $name'); 357 print('No value expected for bool option $name');
358 exit(1); 358 exit(1);
359 } 359 }
360 configuration[spec.name] = true; 360 configuration[spec.name] = true;
361 } else if (spec.type == 'int') { 361 } else if (spec.type == 'int') {
362 try { 362 try {
363 configuration[spec.name] = parseInt(value); 363 configuration[spec.name] = parseInt(value);
364 } catch (e) { 364 } catch (e) {
365 print('Integer value expected for int option $name'); 365 print('Integer value expected for int option $name');
366 exit(1); 366 exit(1);
367 } 367 }
368 } else { 368 } else {
369 assert(spec.type == 'string'); 369 assert(spec.type == 'string');
370 if (!spec.values.isEmpty()) { 370 if (!spec.values.isEmpty) {
371 for (var v in value.split(',')) { 371 for (var v in value.split(',')) {
372 if (spec.values.lastIndexOf(v) == -1) { 372 if (spec.values.lastIndexOf(v) == -1) {
373 print('Unknown value ($v) for option $name'); 373 print('Unknown value ($v) for option $name');
374 exit(1); 374 exit(1);
375 } 375 }
376 } 376 }
377 } 377 }
378 configuration[spec.name] = value; 378 configuration[spec.name] = value;
379 } 379 }
380 } 380 }
381 381
382 // Apply default values for unspecified options. 382 // Apply default values for unspecified options.
383 for (var option in _options) { 383 for (var option in _options) {
384 if (!configuration.containsKey(option.name)) { 384 if (!configuration.containsKey(option.name)) {
385 configuration[option.name] = option.defaultValue; 385 configuration[option.name] = option.defaultValue;
386 } 386 }
387 } 387 }
388 388
389 List<Map> expandedConfigs = _expandConfigurations(configuration); 389 List<Map> expandedConfigs = _expandConfigurations(configuration);
390 List<Map> result = expandedConfigs.filter(_isValidConfig); 390 List<Map> result = expandedConfigs.filter(_isValidConfig);
391 return result.isEmpty() ? null : result; 391 return result.isEmpty ? null : result;
392 } 392 }
393 393
394 /** 394 /**
395 * Determine if a particular configuration has a valid combination of compiler 395 * Determine if a particular configuration has a valid combination of compiler
396 * and runtime elements. 396 * and runtime elements.
397 */ 397 */
398 bool _isValidConfig(Map config) { 398 bool _isValidConfig(Map config) {
399 bool isValid = true; 399 bool isValid = true;
400 List<String> validRuntimes; 400 List<String> validRuntimes;
401 switch (config['compiler']) { 401 switch (config['compiler']) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 void _printHelp() { 617 void _printHelp() {
618 print('usage: dart test.dart [options]\n'); 618 print('usage: dart test.dart [options]\n');
619 print('Options:\n'); 619 print('Options:\n');
620 for (var option in _options) { 620 for (var option in _options) {
621 print('${option.name}: ${option.description}.'); 621 print('${option.name}: ${option.description}.');
622 for (var name in option.keys) { 622 for (var name in option.keys) {
623 assert(name.startsWith('-')); 623 assert(name.startsWith('-'));
624 var buffer = new StringBuffer();; 624 var buffer = new StringBuffer();;
625 buffer.add(name); 625 buffer.add(name);
626 if (option.type == 'bool') { 626 if (option.type == 'bool') {
627 assert(option.values.isEmpty()); 627 assert(option.values.isEmpty);
628 } else { 628 } else {
629 buffer.add(name.startsWith('--') ? '=' : ' '); 629 buffer.add(name.startsWith('--') ? '=' : ' ');
630 if (option.type == 'int') { 630 if (option.type == 'int') {
631 assert(option.values.isEmpty()); 631 assert(option.values.isEmpty);
632 buffer.add('n (default: ${option.defaultValue})'); 632 buffer.add('n (default: ${option.defaultValue})');
633 } else { 633 } else {
634 buffer.add('['); 634 buffer.add('[');
635 bool first = true; 635 bool first = true;
636 for (var value in option.values) { 636 for (var value in option.values) {
637 if (!first) buffer.add(", "); 637 if (!first) buffer.add(", ");
638 if (value == option.defaultValue) buffer.add('*'); 638 if (value == option.defaultValue) buffer.add('*');
639 buffer.add(value); 639 buffer.add(value);
640 first = false; 640 first = false;
641 } 641 }
(...skipping 16 matching lines...) Expand all
658 return option; 658 return option;
659 } 659 }
660 } 660 }
661 print('Unknown test option $name'); 661 print('Unknown test option $name');
662 exit(1); 662 exit(1);
663 } 663 }
664 664
665 665
666 List<_TestOptionSpecification> _options; 666 List<_TestOptionSpecification> _options;
667 } 667 }
OLDNEW
« no previous file with comments | « tools/testing/dart/status_file_parser.dart ('k') | tools/testing/dart/test_progress.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698