@iamsergio/qttest-utils 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/out/qttest.d.ts +1 -0
- package/out/qttest.js +32 -0
- package/out/test.js +29 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.6.1](https://github.com/KDAB/qttest-utils/compare/v2.6.0...v2.6.1) (2026-04-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Improve gtest vs qttest detection ([75b2f57](https://github.com/KDAB/qttest-utils/commit/75b2f575962edc2e78737dc8615c5476bd62e8b2))
|
|
9
|
+
* Improve gtest vs qttest detection ([cb26f31](https://github.com/KDAB/qttest-utils/commit/cb26f316de3e882802e2c81df9c517e6658f9821))
|
|
10
|
+
|
|
3
11
|
## [2.6.0](https://github.com/KDAB/qttest-utils/compare/v2.5.0...v2.6.0) (2026-04-05)
|
|
4
12
|
|
|
5
13
|
|
package/out/qttest.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class QtTest {
|
|
|
32
32
|
*/
|
|
33
33
|
linksToQtTestLib(): Promise<boolean> | undefined;
|
|
34
34
|
isQtTestViaHelp(): Promise<boolean | undefined>;
|
|
35
|
+
isGTest(): Promise<boolean>;
|
|
35
36
|
slotByName(name: string): QtTestSlot | undefined;
|
|
36
37
|
runTest(slot?: QtTestSlot, cwd?: string): Promise<boolean>;
|
|
37
38
|
tapOutputFileName(slot?: QtTestSlot): string;
|
package/out/qttest.js
CHANGED
|
@@ -115,6 +115,11 @@ class QtTest {
|
|
|
115
115
|
* Calls "./yourqttest -functions" and stores the results in the slots property.
|
|
116
116
|
*/
|
|
117
117
|
async parseAvailableSlots() {
|
|
118
|
+
if (await this.isGTest()) {
|
|
119
|
+
logMessage("qttest: Skipping -functions for GTest executable: " + this.filename);
|
|
120
|
+
this.slots = [];
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
118
123
|
let slotNames = [];
|
|
119
124
|
let output = "";
|
|
120
125
|
let err = "";
|
|
@@ -224,6 +229,33 @@ class QtTest {
|
|
|
224
229
|
});
|
|
225
230
|
});
|
|
226
231
|
}
|
|
232
|
+
/// Returns whether this executable is a Google Test by running it with --help
|
|
233
|
+
/// and checking if the output contains the GTest banner
|
|
234
|
+
async isGTest() {
|
|
235
|
+
return await new Promise((resolve) => {
|
|
236
|
+
if (!fs.existsSync(this.filename)) {
|
|
237
|
+
resolve(false);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const child = (0, child_process_1.spawn)(this.filename, ["--help"], {
|
|
241
|
+
env: this.buildSpawnEnv(),
|
|
242
|
+
});
|
|
243
|
+
let output = "";
|
|
244
|
+
let found = false;
|
|
245
|
+
child.stdout.on("data", (chunk) => {
|
|
246
|
+
if (!found) {
|
|
247
|
+
if (chunk
|
|
248
|
+
.toString()
|
|
249
|
+
.includes("This program contains tests written using Google Test")) {
|
|
250
|
+
found = true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
child.on("exit", () => {
|
|
255
|
+
resolve(found);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
227
259
|
slotByName(name) {
|
|
228
260
|
if (!this.slots) {
|
|
229
261
|
return undefined;
|
package/out/test.js
CHANGED
|
@@ -26,6 +26,7 @@ async function runTests(buildDirPath) {
|
|
|
26
26
|
"test/qt_test/build-dev/test2",
|
|
27
27
|
"test/qt_test/build-dev/test3",
|
|
28
28
|
"test/qt_test/build-dev/non_qttest",
|
|
29
|
+
"test/qt_test/build-dev/test_gtest",
|
|
29
30
|
];
|
|
30
31
|
if (qt.qtTestExecutables.length !== expectedExecutables.length) {
|
|
31
32
|
console.error("Expected " +
|
|
@@ -34,12 +35,38 @@ async function runTests(buildDirPath) {
|
|
|
34
35
|
qt.qtTestExecutables.length);
|
|
35
36
|
process.exit(1);
|
|
36
37
|
}
|
|
38
|
+
// Verify that test_gtest is detected as a GTest
|
|
39
|
+
const gtestExe = qt.qtTestExecutables.find((e) => e.filenameWithoutExtension().endsWith("test_gtest"));
|
|
40
|
+
if (!gtestExe) {
|
|
41
|
+
console.error("Expected to find test_gtest executable after discovery");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
if (!(await gtestExe.isGTest())) {
|
|
45
|
+
console.error("Expected test_gtest to be detected as a GTest");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
console.log("PASS: test_gtest detected as GTest");
|
|
49
|
+
// Verify that test_gtest has no slots after parseAvailableSlots (GTest is skipped)
|
|
50
|
+
await gtestExe.parseAvailableSlots();
|
|
51
|
+
if (!gtestExe.slots || gtestExe.slots.length !== 0) {
|
|
52
|
+
console.error("Expected test_gtest to have 0 slots, got " +
|
|
53
|
+
(gtestExe.slots?.length ?? "null"));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
console.log("PASS: test_gtest has 0 slots (no children)");
|
|
57
|
+
// Verify that a QtTest is not detected as a GTest
|
|
58
|
+
if (await test1Exe.isGTest()) {
|
|
59
|
+
console.error("Expected test1 to NOT be detected as a GTest");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
console.log("PASS: test1 (QtTest) not misdetected as GTest");
|
|
37
63
|
await qt.removeNonLinking();
|
|
38
64
|
/// On macOS and Windows we don't have ldd or equivalent, so we can't check if the test links to QtTest
|
|
39
65
|
/// Use the help way instead
|
|
40
66
|
await qt.removeByRunningHelp();
|
|
41
|
-
/// Remove the non-qttest
|
|
42
|
-
qt.qtTestExecutables = qt.qtTestExecutables.filter((e) => !e.filenameWithoutExtension().endsWith("non_qttest")
|
|
67
|
+
/// Remove the non-qttest and gtest executables from qt.qtTestExecutables
|
|
68
|
+
qt.qtTestExecutables = qt.qtTestExecutables.filter((e) => !e.filenameWithoutExtension().endsWith("non_qttest") &&
|
|
69
|
+
!e.filenameWithoutExtension().endsWith("test_gtest"));
|
|
43
70
|
if (qt.qtTestExecutables.length !== 3) {
|
|
44
71
|
console.error("Expected 3 executables, at this point got " +
|
|
45
72
|
qt.qtTestExecutables.length);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamsergio/qttest-utils",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "API for listing QtTest executables from a build directory and which individual test slots each executable contains. Useful for a Text Explorer VSCode extension.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.0.0",
|
|
35
|
-
"eslint": "^
|
|
35
|
+
"eslint": "^10.2.0",
|
|
36
36
|
"prettier": "3.8.1",
|
|
37
37
|
"ts-node": "^10.9.2",
|
|
38
38
|
"typescript": "^6.0.2",
|