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 'package:args/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'], | |
24 allowedHelp: { | |
25 'none': 'Do not compile the Dart code (run native Dart code on the' | |
26 ' VM).\n(only valid with the following runtimes: vm, drt)', | |
27 'dart2js': 'Compile dart code to JavaScript by running dart2js.\n' | |
28 '(only valid with the following runtimes: d8, drt, chrome\n' | |
29 'safari, ie, firefox, opera, none (compile only))', | |
30 'dartc': 'Perform static analysis on Dart code by running dartc.\n' | |
31 '(only valid with the following runtimes: none)', | |
32 }); | |
33 | |
34 parser.addOption('runtime', abbr: 'r', defaultsTo: 'vm', | |
35 help: 'Where the tests should be run.', | |
36 allowed: ['vm', 'd8', 'drt', 'dartium', 'ff', 'firefox', 'chrome', | |
37 'safari', 'ie', 'opera', 'none'], | |
38 allowedHelp: { | |
39 'vm': 'Run Dart code on the standalone dart vm.', | |
40 'd8': 'Run JavaScript from the command line using v8.', | |
41 // TODO(antonm): rename flag. | |
42 'drt': 'Run Dart or JavaScript in the headless version of Chrome,\n' | |
43 'content shell.', | |
44 'dartium': 'Run Dart or JavaScript in Dartium.', | |
45 'ff': 'Run JavaScript in Firefox', | |
46 'chrome': 'Run JavaScript in Chrome', | |
47 'safari': 'Run JavaScript in Safari', | |
48 'ie': 'Run JavaScript in Internet Explorer', | |
49 'opera': 'Run JavaScript in Opera', | |
50 'none': 'No runtime, compile only (for example, used for dartc static\n' | |
51 'analysis tests).', | |
52 }); | |
53 | |
54 parser.addOption('arch', abbr: 'a', defaultsTo: 'ia32', | |
55 help: 'The architecture to run tests for', | |
56 allowed: ['all', 'ia32', 'x64', 'simarm']); | |
57 | |
58 parser.addOption('system', abbr: 's', defaultsTo: Platform.operatingSystem, | |
59 help: 'The operating system to run tests on', | |
60 allowed: ['linux', 'macos', 'windows']); | |
61 | |
62 parser.addFlag('checked', defaultsTo: false, | |
63 help: 'Run tests in checked mode'); | |
64 | |
65 parser.addFlag('host-checked', defaultsTo: false, | |
66 help: 'Run compiler in checked mode'); | |
67 | |
68 parser.addOption('timeout', abbr: 't', | |
69 help: 'Timeout in seconds'); | |
70 | |
71 parser.addOption('progress', abbr: 'p', defaultsTo: 'compact', | |
72 help: 'Progress indication mode', | |
73 allowed: ['compact', 'color', 'line', 'verbose', 'silent', 'status', | |
74 'buildbot']); | |
75 | |
76 parser.addFlag('report', defaultsTo: false, | |
77 help: 'Print a summary report of the number of tests, by expectation'); | |
78 | |
79 parser.addOption('tasks', abbr: 'j', | |
80 defaultsTo: Platform.numberOfProcessors.toString(), | |
81 help: 'The number of parallel tasks to run'); | |
82 | |
83 parser.addOption('shards', defaultsTo: '1', | |
84 help: 'The number of instances that the tests will be sharded over'); | |
85 | |
86 parser.addOption('shard', defaultsTo: '1', | |
87 help: 'The index of this instance when running in sharded mode'); | |
88 | |
89 parser.addFlag('verbose', abbr: 'v', defaultsTo: false, | |
90 help: 'Verbose output'); | |
91 | |
92 parser.addFlag('list', defaultsTo: false, | |
93 help: 'List tests only, do not run them'); | |
94 | |
95 parser.addFlag('keep-generated-tests', defaultsTo: false, | |
96 help: 'Keep the generated files in the temporary directory'); | |
97 | |
98 parser.addFlag('valgrind', defaultsTo: false, | |
99 help: 'Run tests through valgrind'); | |
100 | |
101 parser.addOption('special-command', | |
102 help: """ | |
103 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('dart', help: 'Path to dart executable'); | |
118 parser.addOption('drt', help: 'Path to content shell executable'); | |
119 parser.addOption('dartium', help: 'Path to Dartium Chrome executable'); | |
120 | |
121 parser.addFlag('batch', abbr: 'b', | |
122 help: 'Run browser tests in batch mode', | |
123 defaultsTo: true); | |
124 | |
125 print(parser.getUsage()); | |
126 } | |
OLD | NEW |