Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /// This is an example of converting the args in test.dart to use this API. | |
| 6 /// It shows what it looks like to build an [ArgParser] and then, when the code | |
| 7 /// is run, demonstrates what the generated usage text looks like. | |
| 8 #library('example'); | |
| 9 | |
| 10 #import('dart:io'); | |
| 11 | |
| 12 #import('args.dart'); | |
| 13 | |
| 14 main() { | |
| 15 var parser = new ArgParser(); | |
| 16 | |
| 17 parser.addOption('mode', abbr: 'm', defaultsTo: 'debug', | |
| 18 help: 'Mode in which to run the tests', | |
| 19 allowed: ['all', 'debug', 'release']); | |
| 20 | |
| 21 parser.addOption('compiler', abbr: 'c', defaultsTo: 'none', | |
| 22 help: 'Specify any compilation step (if needed).', | |
| 23 allowed: ['none', 'dart2js', 'dartc', 'frog'], | |
| 24 allowedHelp: { | |
| 25 'none': 'Do not compile the Dart code (run native Dart code on the VM).\ n' | |
|
Siggi Cherem (dart-lang)
2012/05/02 22:07:43
80 col
Bob Nystrom
2012/05/03 00:23:40
Done.
| |
| 26 '(only valid with the following runtimes: vm, drt)', | |
| 27 'dart2js': 'Compile dart code to JavaScript by running dart2js (leg).\n' | |
| 28 '(only valid with the following runtimes: same as frog)', | |
| 29 'dartc': 'Perform static analysis on Dart code by running dartc.\n' | |
| 30 '(only valid with the following runtimes: none)', | |
| 31 'frog': '(DEPRECATED) Compile dart code to JavaScript by running the\n' | |
| 32 'frog compiler. (only valid with the following runtimes: d8,\n' | |
| 33 'drt, chrome, safari, ie, firefox, opera, none (compile only))' | |
| 34 }); | |
| 35 | |
| 36 parser.addOption('runtime', abbr: 'r', defaultsTo: 'vm', | |
| 37 help: 'Where the tests should be run.', | |
| 38 allowed: ['vm', 'd8', 'drt', 'dartium', 'ff', 'firefox', 'chrome', | |
| 39 'safari', 'ie', 'opera', 'none'], | |
| 40 allowedHelp: { | |
| 41 'vm': 'Run Dart code on the standalone dart vm.', | |
| 42 'd8': 'Run JavaScript from the command line using v8.', | |
| 43 'drt': 'Run Dart or JavaScript in the headless version of Chrome,\n' | |
| 44 'DumpRenderTree.', | |
| 45 'dartium': 'Run Dart or JavaScript in Dartium.', | |
| 46 'ff': 'Run JavaScript in Firefox', | |
| 47 'chrome': 'Run JavaScript in Chrome', | |
| 48 'safari': 'Run JavaScript in Safari', | |
| 49 'ie': 'Run JavaScript in Internet Explorer', | |
| 50 'opera': 'Run JavaScript in Opera', | |
| 51 'none': 'No runtime, compile only (for example, used for dartc static\n' | |
| 52 'analysis tests).', | |
| 53 }); | |
| 54 | |
| 55 parser.addOption('arch', abbr: 'a', defaultsTo: 'ia32', | |
| 56 help: 'The architecture to run tests for', | |
| 57 allowed: ['all', 'ia32', 'x64', 'simarm']); | |
| 58 | |
| 59 parser.addOption('system', abbr: 's', defaultsTo: Platform.operatingSystem(), | |
| 60 help: 'The operating system to run tests on', | |
| 61 allowed: ['linux', 'macos', 'windows']); | |
| 62 | |
| 63 parser.addFlag('checked', defaultsTo: false, | |
| 64 help: 'Run tests in checked mode'); | |
| 65 | |
| 66 parser.addFlag('host-checked', defaultsTo: false, | |
| 67 help: 'Run compiler in checked mode'); | |
| 68 | |
| 69 parser.addOption('timeout', abbr: 't', | |
| 70 help: 'Timeout in seconds'); | |
| 71 | |
| 72 parser.addOption('progress', abbr: 'p', defaultsTo: 'compact', | |
| 73 help: 'Progress indication mode', | |
| 74 allowed: ['compact', 'color', 'line', 'verbose', 'silent', 'status', | |
| 75 'buildbot']); | |
| 76 | |
| 77 parser.addFlag('report', defaultsTo: false, | |
| 78 help: 'Print a summary report of the number of tests, by expectation'); | |
| 79 | |
| 80 parser.addOption('tasks', abbr: 'j', | |
| 81 defaultsTo: Platform.numberOfProcessors().toString(), | |
| 82 help: 'The number of parallel tasks to run'); | |
| 83 | |
| 84 parser.addOption('shards', defaultsTo: '1', | |
| 85 help: 'The number of instances that the tests will be sharded over'); | |
| 86 | |
| 87 parser.addOption('shard', defaultsTo: '1', | |
| 88 help: 'The index of this instance when running in sharded mode'); | |
| 89 | |
| 90 parser.addFlag('verbose', abbr: 'v', defaultsTo: false, | |
| 91 help: 'Verbose output'); | |
| 92 | |
| 93 parser.addFlag('list', defaultsTo: false, | |
| 94 help: 'List tests only, do not run them'); | |
| 95 | |
| 96 parser.addFlag('keep-generated-tests', defaultsTo: false, | |
| 97 help: 'Keep the generated files in the temporary directory'); | |
| 98 | |
| 99 parser.addFlag('valgrind', defaultsTo: false, | |
| 100 help: 'Run tests through valgrind'); | |
| 101 | |
| 102 parser.addOption('special-command', | |
| 103 help: """Special command support. Wraps the command line in | |
| 104 a special command. The special command should contain | |
| 105 an '@' character which will be replaced by the normal | |
| 106 command. | |
| 107 | |
| 108 For example if the normal command that will be executed | |
| 109 is 'dart file.dart' and you specify special command | |
| 110 'python -u valgrind.py @ suffix' the final command will be | |
| 111 'python -u valgrind.py dart file.dart suffix'"""); | |
| 112 | |
| 113 parser.addFlag('time', | |
| 114 help: 'Print timing information after running tests', | |
| 115 defaultsTo: false); | |
| 116 | |
| 117 parser.addOption('frog', help: 'Path to frog script or executable'); | |
| 118 parser.addOption('dart', help: 'Path to dart executable'); | |
| 119 parser.addOption('drt', help: 'Path to DumpRenderTree executable'); | |
| 120 parser.addOption('dartium', help: 'Path to Dartium Chrome executable'); | |
| 121 parser.addOption('froglib', help: 'Path to frog library'); | |
| 122 | |
| 123 parser.addFlag('batch', abbr: 'b', | |
| 124 help: 'Run browser tests in batch mode', | |
| 125 defaultsTo: true); | |
| 126 | |
| 127 print(parser.getUsage()); | |
| 128 } | |
| OLD | NEW |