Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe(`Compiling ${l.base}.foma`, function() {
this.timeout(100000); /* compilation can take a while */
const fomaFile = `${l.base}${l.examples ? '-examples' : ''}.foma`;
// This has to be sync, since we're going to create test cases
// based on the result of this, and mocha doesn't support async
// test case generation.
// XXX skip this if `foma` isn't on the path.
let result = childProcess.execFileSync('foma', ['-f', fomaFile], {
cwd: fstDir,
encoding: 'utf8',
});
// Count the number of tests expected
let expectedTests = 0;
result = result.replace(
/^EXPECT\s+(\d+)\s*$/mg,
(m, num) => {
expectedTests += Number.parseInt(num, 10);
return '';
});
// EXPECT: is a shorthand for one-line tests
result = result.replace(
/^EXPECT(?:\[(.*)\])?: (.*)$/mg,
(m, name, out) => `\n${out}\n`