r104702 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104701‎ | r104702 | r104703 >
Date:17:03, 30 November 2011
Author:hashar
Status:deferred
Tags:
Comment:
allow test filtering using a regexp on title test

use --filter :)
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -25,7 +25,7 @@
2626
2727 var argv = optimist.usage( 'Usage: $0', {
2828 'filter': {
29 - description: 'Only run tests whose descriptions which match given regex (option not implemented)',
 29+ description: 'Only run tests whose descriptions which match given regex',
3030 alias: 'regex',
3131 },
3232 'help': {
@@ -38,6 +38,11 @@
3939 boolean: true,
4040 },
4141 }
 42+ ).check( function(argv) {
 43+ if( argv.filter === true ) {
 44+ throw "--filter need an argument";
 45+ }
 46+ }
4247 ).argv // keep that
4348 ;
4449
@@ -45,6 +50,11 @@
4651 optimist.showHelp();
4752 process.exit( 0 );
4853 }
 54+var test_filter = null;
 55+if( argv.filter ) { // null is the default by definition
 56+ test_filter = new RegExp( argv.filter );
 57+ console.log( "Filtering title test using Regexp " + test_filter );
 58+}
4959
5060 // @fixme wrap more or this setup in a common module
5161
@@ -334,6 +344,10 @@
335345 //processArticle(item);
336346 break;
337347 case 'test':
 348+ if( test_filter && -1 === item.title.search( test_filter ) ) {
 349+ // Skip test whose title does not match --filter
 350+ break;
 351+ }
338352 // Add comments to following test.
339353 item.comments = comments;
340354 comments = [];

Status & tagging log