Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -20,6 +20,32 @@ |
21 | 21 | colors = require('colors'), |
22 | 22 | HTML5 = require('html5').HTML5; |
23 | 23 | |
| 24 | +// Handle options/arguments with optimist module |
| 25 | +var optimist = require('optimist'); |
| 26 | + |
| 27 | +var argv = optimist.usage( 'Usage: $0', { |
| 28 | + 'filter': { |
| 29 | + description: 'Only run tests whose descriptions which match given regex (option not implemented)', |
| 30 | + alias: 'regex', |
| 31 | + }, |
| 32 | + 'help': { |
| 33 | + description: 'Show this help message', |
| 34 | + alias: 'h', |
| 35 | + }, |
| 36 | + 'disabled': { |
| 37 | + description: 'Run disabled tests (default false) (option not implemented)', |
| 38 | + default: false, |
| 39 | + boolean: true, |
| 40 | + }, |
| 41 | + } |
| 42 | + ).argv // keep that |
| 43 | + ; |
| 44 | + |
| 45 | +if( argv.help ) { |
| 46 | + optimist.showHelp(); |
| 47 | + process.exit( 0 ); |
| 48 | +} |
| 49 | + |
24 | 50 | // @fixme wrap more or this setup in a common module |
25 | 51 | |
26 | 52 | // Fetch up some of our wacky parser bits... |
— | — | @@ -74,11 +100,11 @@ |
75 | 101 | |
76 | 102 | var testFileName = '../../../../phase3/tests/parser/parserTests.txt'; // default |
77 | 103 | var testFileName2 = '../../../../tests/parser/parserTests.txt'; // Fallback. Not everyone fetch at phase3 level |
78 | | -if (process.argv.length > 2) { |
| 104 | + |
| 105 | +if (argv._[0]) { |
79 | 106 | // hack :D |
80 | | - testFileName = process.argv[2]; |
| 107 | + testFileName = argv._[0] ; |
81 | 108 | testFileName2 = null; |
82 | | - console.log(testFileName); |
83 | 109 | } |
84 | 110 | |
85 | 111 | try { |
Index: trunk/extensions/VisualEditor/tests/parser/README |
— | — | @@ -9,4 +9,5 @@ |
10 | 10 | * jsdom |
11 | 11 | * diff |
12 | 12 | * libxmljs (requires native compilation) |
| 13 | +* optimist (for argument handling) |
13 | 14 | * webworker |