Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ParserTests.prototype.main = Promise.async(function *(options, mockAPIServerURL) {
this.runDisabled = ScriptUtils.booleanOption(options['run-disabled']);
this.runPHP = ScriptUtils.booleanOption(options['run-php']);
// test case filtering
this.testFilter = null; // null is the 'default' by definition
if (options.filter || options.regex) {
// NOTE: filter.toString() is required because a number-only arg
// shows up as a numeric type rather than a string.
// Ex: parserTests.js --filter 53221
var pattern = options.regex || JSUtils.escapeRegExp(options.filter.toString());
this.testFilter = new RegExp(pattern);
}
this.testParserFilePath = path.join(__dirname, '../lib/parserTests/parserTests.pegjs');
this.testParser = PEG.buildParser(yield fs.readFile(this.testParserFilePath, 'utf8'));
const parsedTests = yield this.getTests(options);
this.testFormat = parsedTests[0];
this.cases = parsedTests[1];
if (this.testFormat && this.testFormat.text) {
this.testFormat = +(this.testFormat.text);
} else {
this.testFormat = 1;
}
if (options.maxtests) {
var n = Number(options.maxtests);
console.warn('maxtests:' + n);
if (n > 0) {
this.cases.length = n;
}