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