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

Unified Diff: lib/args/example.dart

Issue 10335007: First pass at a generic reusable command line option parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removing stale #import from unittest. Created 8 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: lib/args/example.dart
diff --git a/lib/args/example.dart b/lib/args/example.dart
new file mode 100644
index 0000000000000000000000000000000000000000..38390d4ac0dbd08c761756a0b46a43e45396d0ba
--- /dev/null
+++ b/lib/args/example.dart
@@ -0,0 +1,128 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// This is an example of converting the args in test.dart to use this API.
+/// It shows what it looks like to build an [ArgParser] and then, when the code
+/// is run, demonstrates what the generated usage text looks like.
+#library('example');
+
+#import('dart:io');
+
+#import('args.dart');
+
+main() {
+ var parser = new ArgParser();
+
+ parser.addOption('mode', abbr: 'm', defaultsTo: 'debug',
+ help: 'Mode in which to run the tests',
+ allowed: ['all', 'debug', 'release']);
+
+ parser.addOption('compiler', abbr: 'c', defaultsTo: 'none',
+ help: 'Specify any compilation step (if needed).',
+ allowed: ['none', 'dart2js', 'dartc', 'frog'],
+ allowedHelp: {
+ '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.
+ '(only valid with the following runtimes: vm, drt)',
+ 'dart2js': 'Compile dart code to JavaScript by running dart2js (leg).\n'
+ '(only valid with the following runtimes: same as frog)',
+ 'dartc': 'Perform static analysis on Dart code by running dartc.\n'
+ '(only valid with the following runtimes: none)',
+ 'frog': '(DEPRECATED) Compile dart code to JavaScript by running the\n'
+ 'frog compiler. (only valid with the following runtimes: d8,\n'
+ 'drt, chrome, safari, ie, firefox, opera, none (compile only))'
+ });
+
+ parser.addOption('runtime', abbr: 'r', defaultsTo: 'vm',
+ help: 'Where the tests should be run.',
+ allowed: ['vm', 'd8', 'drt', 'dartium', 'ff', 'firefox', 'chrome',
+ 'safari', 'ie', 'opera', 'none'],
+ allowedHelp: {
+ 'vm': 'Run Dart code on the standalone dart vm.',
+ 'd8': 'Run JavaScript from the command line using v8.',
+ 'drt': 'Run Dart or JavaScript in the headless version of Chrome,\n'
+ 'DumpRenderTree.',
+ 'dartium': 'Run Dart or JavaScript in Dartium.',
+ 'ff': 'Run JavaScript in Firefox',
+ 'chrome': 'Run JavaScript in Chrome',
+ 'safari': 'Run JavaScript in Safari',
+ 'ie': 'Run JavaScript in Internet Explorer',
+ 'opera': 'Run JavaScript in Opera',
+ 'none': 'No runtime, compile only (for example, used for dartc static\n'
+ 'analysis tests).',
+ });
+
+ parser.addOption('arch', abbr: 'a', defaultsTo: 'ia32',
+ help: 'The architecture to run tests for',
+ allowed: ['all', 'ia32', 'x64', 'simarm']);
+
+ parser.addOption('system', abbr: 's', defaultsTo: Platform.operatingSystem(),
+ help: 'The operating system to run tests on',
+ allowed: ['linux', 'macos', 'windows']);
+
+ parser.addFlag('checked', defaultsTo: false,
+ help: 'Run tests in checked mode');
+
+ parser.addFlag('host-checked', defaultsTo: false,
+ help: 'Run compiler in checked mode');
+
+ parser.addOption('timeout', abbr: 't',
+ help: 'Timeout in seconds');
+
+ parser.addOption('progress', abbr: 'p', defaultsTo: 'compact',
+ help: 'Progress indication mode',
+ allowed: ['compact', 'color', 'line', 'verbose', 'silent', 'status',
+ 'buildbot']);
+
+ parser.addFlag('report', defaultsTo: false,
+ help: 'Print a summary report of the number of tests, by expectation');
+
+ parser.addOption('tasks', abbr: 'j',
+ defaultsTo: Platform.numberOfProcessors().toString(),
+ help: 'The number of parallel tasks to run');
+
+ parser.addOption('shards', defaultsTo: '1',
+ help: 'The number of instances that the tests will be sharded over');
+
+ parser.addOption('shard', defaultsTo: '1',
+ help: 'The index of this instance when running in sharded mode');
+
+ parser.addFlag('verbose', abbr: 'v', defaultsTo: false,
+ help: 'Verbose output');
+
+ parser.addFlag('list', defaultsTo: false,
+ help: 'List tests only, do not run them');
+
+ parser.addFlag('keep-generated-tests', defaultsTo: false,
+ help: 'Keep the generated files in the temporary directory');
+
+ parser.addFlag('valgrind', defaultsTo: false,
+ help: 'Run tests through valgrind');
+
+ parser.addOption('special-command',
+ help: """Special command support. Wraps the command line in
+a special command. The special command should contain
+an '@' character which will be replaced by the normal
+command.
+
+For example if the normal command that will be executed
+is 'dart file.dart' and you specify special command
+'python -u valgrind.py @ suffix' the final command will be
+'python -u valgrind.py dart file.dart suffix'""");
+
+ parser.addFlag('time',
+ help: 'Print timing information after running tests',
+ defaultsTo: false);
+
+ parser.addOption('frog', help: 'Path to frog script or executable');
+ parser.addOption('dart', help: 'Path to dart executable');
+ parser.addOption('drt', help: 'Path to DumpRenderTree executable');
+ parser.addOption('dartium', help: 'Path to Dartium Chrome executable');
+ parser.addOption('froglib', help: 'Path to frog library');
+
+ parser.addFlag('batch', abbr: 'b',
+ help: 'Run browser tests in batch mode',
+ defaultsTo: true);
+
+ print(parser.getUsage());
+}
« no previous file with comments | « lib/args/args.dart ('k') | lib/args/utils.dart » ('j') | lib/unittest/unittest.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698