Skip to content

Commit 7d8371a

Browse files
test: fix
1 parent f582544 commit 7d8371a

File tree

3 files changed

+47
-47
lines changed

3 files changed

+47
-47
lines changed

package-lock.json

Lines changed: 21 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smoketests/helpers.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ const runTest = async (pkg, cliArgs = [], logMessage = undefined, isSubPackage =
2626
swapPkgName(pkg, isSubPackage);
2727

2828
const { execa } = await import("execa");
29+
const abortController = new AbortController();
2930
const proc = execa(CLI_ENTRY_PATH, cliArgs, {
3031
cwd: __dirname,
32+
reject: false,
33+
cancelSignal: abortController.signal,
3134
});
3235

3336
proc.stdin.setDefaultEncoding("utf8");
@@ -61,8 +64,8 @@ const runTest = async (pkg, cliArgs = [], logMessage = undefined, isSubPackage =
6164
}
6265

6366
if (hasLogMessage && hasPrompt) {
67+
abortController.abort();
6468
hasPassed = true;
65-
proc.kill();
6669
}
6770
});
6871

@@ -85,8 +88,11 @@ const runTestStdout = async ({ packageName, cliArgs, logMessage, isSubPackage }
8588
swapPkgName(packageName, isSubPackage);
8689

8790
const { execa } = await import("execa");
91+
const abortController = new AbortController();
8892
const proc = execa(CLI_ENTRY_PATH, cliArgs, {
8993
cwd: __dirname,
94+
reject: false,
95+
cancelSignal: abortController.signal,
9096
});
9197

9298
proc.stdin.setDefaultEncoding("utf8");
@@ -106,7 +112,7 @@ const runTestStdout = async ({ packageName, cliArgs, logMessage, isSubPackage }
106112

107113
if (data.includes(logMessage)) {
108114
hasPassed = true;
109-
proc.kill();
115+
abortController.abort();
110116
}
111117
});
112118

@@ -140,8 +146,11 @@ const runTestStdoutWithInput = async ({
140146
swapPkgName(packageName, isSubPackage);
141147

142148
const { execa } = await import("execa");
149+
const abortController = new AbortController();
143150
const proc = execa(CLI_ENTRY_PATH, cliArgs, {
144151
cwd: __dirname,
152+
reject: false,
153+
cancelSignal: abortController.signal,
145154
});
146155

147156
proc.stdin.setDefaultEncoding("utf8");
@@ -160,7 +169,7 @@ const runTestStdoutWithInput = async ({
160169

161170
if (data.includes(logMessage)) {
162171
hasPassed = true;
163-
proc.kill();
172+
abortController.abort();
164173
}
165174

166175
for (const input of Object.keys(inputs)) {
@@ -194,8 +203,11 @@ const runTestWithHelp = async (pkg, cliArgs = [], logMessage = undefined, isSubP
194203
swapPkgName(pkg, isSubPackage);
195204

196205
const { execa } = await import("execa");
206+
const abortController = new AbortController();
197207
const proc = execa(CLI_ENTRY_PATH, cliArgs, {
198208
cwd: __dirname,
209+
reject: false,
210+
cancelSignal: abortController.signal,
199211
});
200212

201213
proc.stdin.setDefaultEncoding("utf8");
@@ -230,7 +242,7 @@ const runTestWithHelp = async (pkg, cliArgs = [], logMessage = undefined, isSubP
230242

231243
if (hasLogMessage || hasUndefinedLogMessage) {
232244
hasPassed = true;
233-
proc.kill();
245+
abortController.abort();
234246
}
235247
});
236248

smoketests/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const tests = [
22
require("./missing-packages/webpack-dev-server.test"),
3-
// require("./missing-packages/webpack.test"),
4-
// require("./missing-packages/webpack-bundle-analyzer.test"),
5-
// require("./missing-command-packages/serve.test"),
6-
// require("./missing-command-packages/info.test"),
7-
// require("./missing-command-packages/configtest.test"),
3+
require("./missing-packages/webpack.test"),
4+
require("./missing-packages/webpack-bundle-analyzer.test"),
5+
require("./missing-command-packages/serve.test"),
6+
require("./missing-command-packages/info.test"),
7+
require("./missing-command-packages/configtest.test"),
88
];
99

1010
// eslint-disable-next-line unicorn/prefer-top-level-await
@@ -13,12 +13,13 @@ const tests = [
1313
const passResults = [];
1414
const failResults = [];
1515

16-
for await (const test of tests) {
17-
console.log(`\nRUN ${test.name}`);
16+
for (const test of tests) {
17+
console.log(`RUN ${test.name}`);
1818

1919
let isPass = true;
2020

21-
for await (const testCase of test.run) {
21+
for (const testCase of test.run) {
22+
console.log(`RUN case ${testCase.name}`);
2223
isPass &&= await testCase();
2324
}
2425

@@ -34,7 +35,7 @@ const tests = [
3435
}
3536
}
3637

37-
console.log("\n\nSummary of smoketest run:");
38+
console.log("\nSummary of smoke tests run:");
3839
console.log(`${failResults.length} tests failed, ${passResults.length} tests passed`);
3940

4041
for (const result of failResults) {

0 commit comments

Comments
 (0)