MCPcopy
hub / github.com/rollup/rollup / runTest

Function runTest

test/cli/index.js:49–175  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

47);
48
49async function runTest(config) {
50 if (config.before) {
51 await config.before();
52 }
53 return new Promise((resolve, reject) => {
54 let stdout = '';
55 let stderr = '';
56
57 const spawnOptions = {
58 timeout: 40_000,
59 env: { ...process.env, FORCE_COLOR: '0', ...config.env },
60 killSignal: 'SIGKILL'
61 };
62 const childProcess = config.spawnArgs
63 ? spawn('node', [config.spawnScript || rollupBinary, ...config.spawnArgs], spawnOptions)
64 : exec(config.command.replace(/(^| )rollup($| )/g, ` node ${rollupBinary} `), spawnOptions);
65
66 childProcess.stdout.on('data', data => {
67 stdout += String(data);
68 });
69
70 childProcess.stderr.on('data', async data => {
71 stderr += String(data);
72 if (config.abortOnStderr) {
73 try {
74 if (await config.abortOnStderr(String(data))) {
75 childProcess.kill('SIGTERM');
76 }
77 } catch (error) {
78 childProcess.kill('SIGTERM');
79 reject(error);
80 }
81 }
82 });
83
84 childProcess.on('error', error => {
85 console.log('GOT AN ERROR', error);
86 reject(error);
87 childProcess.kill('SIGKILL');
88 });
89
90 childProcess.on('close', async code => {
91 try {
92 let error;
93 if (code > 0) {
94 error = new Error(stderr);
95 error.code = code;
96 }
97 if (config.after) {
98 await config.after(error, stdout, stderr);
99 }
100 if (error && !childProcess.killed) {
101 if (config.error) {
102 if (!config.error(error)) {
103 return resolve();
104 }
105 } else {
106 return reject(error);

Callers 3

loadConfigAndRunTestFunction · 0.85
index.jsFile · 0.85
runTestsWithCodeFunction · 0.85

Calls 8

rejectFunction · 0.85
logMethod · 0.80
errorMethod · 0.80
exportsMethod · 0.80
onMethod · 0.65
isDirectoryMethod · 0.65
resolveFunction · 0.50
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…