Skip to content

Commit 9cea2c3

Browse files
committed
fix: Fix JSON output from ctest not being received
'exit' spawn event does not wait for stdout to be closed. 'close' is the correct event Also fixes the tests being flaky
1 parent 45a2eac commit 9cea2c3

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*.tgz
66
*.log
77
/out/
8+
/src/*.js

out/cmake.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ class CMakeTests {
4949
child.stdout.on("data", (chunk) => {
5050
output += chunk.toString();
5151
});
52-
child.on("exit", (code) => {
52+
child.on("close", (code) => {
5353
if (code === 0) {
54-
resolve(this.ctestJsonToList(output));
54+
if (output.length == 0) {
55+
console.error("ctestJsonToList: Empty json output. Command was ctest --show-only=json-v1 , in " +
56+
this.buildDirPath);
57+
reject(new Error("Failed to get ctest JSON output"));
58+
}
59+
else {
60+
resolve(this.ctestJsonToList(output));
61+
}
5562
}
5663
else {
5764
reject(new Error("Failed to run ctest"));

src/cmake.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ export class CMakeTests {
4444
output += chunk.toString();
4545
});
4646

47-
child.on("exit", (code) => {
47+
child.on("close", (code) => {
4848
if (code === 0) {
49-
resolve(this.ctestJsonToList(output));
49+
if (output.length == 0) {
50+
console.error(
51+
"ctestJsonToList: Empty json output. Command was ctest --show-only=json-v1 , in " +
52+
this.buildDirPath,
53+
);
54+
reject(new Error("Failed to get ctest JSON output"));
55+
} else {
56+
resolve(this.ctestJsonToList(output));
57+
}
5058
} else {
5159
reject(new Error("Failed to run ctest"));
5260
}

0 commit comments

Comments
 (0)