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'], | |
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.\n' | |
30 '(only valid with the following runtimes: d8, drt, chrome\n' | |
31 'safari, ie, firefox, opera, none (compile only))', | |
32 'dartc': 'Perform static analysis on Dart code by running dartc.\n' | |
33 '(only valid with the following runtimes: none)', | |
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: """ | |
104 Special command support. Wraps the command line in | |
105 a special command. The special command should contain | |
106 an '@' character which will be replaced by the normal | |
107 command. | |
108 | |
109 For example if the normal command that will be executed | |
110 is 'dart file.dart' and you specify special command | |
111 'python -u valgrind.py @ suffix' the final command will be | |
112 'python -u valgrind.py dart file.dart suffix'"""); | |
113 | |
114 parser.addFlag('time', | |
115 help: 'Print timing information after running tests', | |
116 defaultsTo: false); | |
117 | |
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 | |
122 parser.addFlag('batch', abbr: 'b', | |
123 help: 'Run browser tests in batch mode', | |
124 defaultsTo: true); | |
125 | |
126 print(parser.getUsage()); | |
127 } | |
OLD | NEW |