How to use the pn/child_process.execFileSync function in pn

To help you get started, we’ve selected a few pn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikimedia / parsoid / tests / mocha / foma.js View on Github external
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`