Skip to content

Commit 26f3fe1

Browse files
committed
updated err test to handle exit code 1
1 parent b6a5ccf commit 26f3fe1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,4 @@ dist
104104
.tern-port
105105

106106
*bak*
107+
*.out

test.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
// using NodeJS' assert library to test flug
2-
const assert = require("assert");
3-
const child_process = require("child_process");
2+
const assert = require("node:assert");
3+
const child_process = require("node:child_process");
4+
const fs = require("node:fs");
45

56
const $ = str => {
6-
const output = child_process.execSync(str + " 2>&1", { cwd: __dirname }).toString();
7-
// console.log("output:", output);
8-
return output;
7+
try {
8+
const output = child_process.execSync(str + " 2>&1", {
9+
cwd: __dirname,
10+
stdio: [
11+
0,
12+
fs.openSync('log.out', 'w'),
13+
fs.openSync('err.out', 'w')
14+
]
15+
}).toString();
16+
return output;
17+
} catch (error) {
18+
const msg = fs.readFileSync('log.out', 'utf-8');
19+
return msg;
20+
}
921
};
1022

1123
const t = (cmd, expected) => {

0 commit comments

Comments
 (0)