MCPcopy Create free account
hub / github.com/webpack/webpack-cli / runTestWithHelp

Function runTestWithHelp

smoketests/helpers.js:204–265  ·  view source on GitHub ↗
(pkg, cliArgs = [], logMessage = undefined, isSubPackage = false)

Source from the content-addressed store, hash-verified

202};
203
204const runTestWithHelp = async (pkg, cliArgs = [], logMessage = undefined, isSubPackage = false) => {
205 // Simulate package missing
206 swapPkgName(pkg, isSubPackage);
207
208 const { execa } = await import("execa");
209 const abortController = new AbortController();
210 const proc = execa(CLI_ENTRY_PATH, cliArgs, {
211 cwd: __dirname,
212 reject: false,
213 gracefulCancel: true,
214 cancelSignal: abortController.signal,
215 });
216
217 proc.stdin.setDefaultEncoding("utf8");
218 proc.stdout.on("data", (chunk) => {
219 console.log(` stdout: ${chunk.toString()}`);
220 });
221
222 return new Promise((resolve) => {
223 const timeout = setTimeout(() => {
224 console.log(" timeout: killing process");
225 proc.kill();
226 }, 30000);
227
228 const undefinedLogMessage = "Can't find and load command";
229
230 let hasLogMessage = false;
231 let hasUndefinedLogMessage = false;
232 let hasPassed = false;
233
234 proc.stderr.on("data", (chunk) => {
235 const data = stripVTControlCharacters(chunk.toString());
236
237 console.log(` stderr: ${data}`);
238
239 if (data.includes(logMessage)) {
240 hasLogMessage = true;
241 }
242
243 if (data.includes(undefinedLogMessage)) {
244 hasUndefinedLogMessage = true;
245 }
246
247 if (hasLogMessage || hasUndefinedLogMessage) {
248 hasPassed = true;
249 abortController.abort();
250 }
251 });
252
253 proc.on("exit", () => {
254 swapPkgName(`.${pkg}`, isSubPackage);
255 clearTimeout(timeout);
256 resolve(hasPassed);
257 });
258
259 proc.on("error", () => {
260 swapPkgName(`.${pkg}`, isSubPackage);
261 clearTimeout(timeout);

Callers

nothing calls this directly

Calls 2

swapPkgNameFunction · 0.85
resolveFunction · 0.85

Tested by

no test coverage detected