r104421 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104420‎ | r104421 | r104422 >
Date:11:41, 28 November 2011
Author:hashar
Status:deferred
Tags:
Comment:
Adds a path fallback to find test file.

I do not fetch mediawiki in ../../../../phase3 . This patch use another
path as a fallback.
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -70,9 +70,11 @@
7171 var parser = new PegParser();
7272
7373 var testFileName = '../../../../phase3/tests/parser/parserTests.txt'; // default
 74+var testFileName2 = '../../../../tests/parser/parserTests.txt'; // Fallback. Not everyone fetch at phase3 level
7475 if (process.argv.length > 2) {
7576 // hack :D
7677 testFileName = process.argv[2];
 78+ testFileName2 = null;
7779 console.log(testFileName);
7880 }
7981
@@ -82,9 +84,17 @@
8385 console.log(e);
8486 }
8587
86 -var testFile = fs.readFileSync(testFileName, 'utf8');
 88+var testFile;
 89+try {
 90+ testFile = fs.readFileSync(testFileName, 'utf8');
 91+} catch (e) {
 92+ // Try opening fallback file
 93+ if( testFileName2 !== '' ) {
 94+ try { testFile = fs.readFileSync( testFileName2, 'utf8' ); }
 95+ catch(e) { console.log(e); }
 96+ }
 97+}
8798
88 -
8999 try {
90100 var cases = testParser.parse(testFile);
91101 } catch (e) {

Status & tagging log