@iamsergio/qttest-utils 2.2.2 → 2.3.0
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/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +15 -0
- package/CONTRIBUTING.md +2 -3
- package/out/cmake.js +9 -2
- package/out/qttest.js +45 -11
- package/out/test.js +41 -2
- package/package.json +4 -1
- package/release-please-config.json +16 -0
- package/test.sh +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.3.0](https://github.com/KDAB/qttest-utils/compare/v2.2.2...v2.3.0) (2024-06-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Add support for QEXPECT_FAIL ([0037921](https://github.com/KDAB/qttest-utils/commit/003792112bd6093640e772dcfd109812f38324bd))
|
|
9
|
+
* Add support for XPASS ([a60be6b](https://github.com/KDAB/qttest-utils/commit/a60be6b81f22d3a18ee624e2414e91c37e2c607f))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* Fix JSON output from ctest not being received ([9cea2c3](https://github.com/KDAB/qttest-utils/commit/9cea2c3dd4b5798f7f6f0bf382e5eca1694f0eb2))
|
|
15
|
+
* Use tap-parser instead of regexp to parse tap files ([3d9f1f5](https://github.com/KDAB/qttest-utils/commit/3d9f1f5abc77d2af1a57ba6a75b89c8a3ad424ed))
|
package/CONTRIBUTING.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Prepare your development environment
|
|
4
4
|
|
|
5
|
-
Just follow `.devcontainer/Dockerfile` to see what's needed.<br
|
|
5
|
+
Just follow `.devcontainer/Dockerfile` to see what's needed.<br>
|
|
6
6
|
Basically it's just `nodejs` >= v18 `tsc` and `npm`. <br>
|
|
7
7
|
Qt5, cmake and ninja if you want to run the tests.
|
|
8
8
|
|
|
@@ -10,8 +10,7 @@ Qt5, cmake and ninja if you want to run the tests.
|
|
|
10
10
|
## Running tests
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
|
|
14
|
-
node out/test.js
|
|
13
|
+
sh test.sh
|
|
15
14
|
```
|
|
16
15
|
|
|
17
16
|
Or simply let GitHub actions run the tests for you.<br>
|
package/out/cmake.js
CHANGED
|
@@ -49,9 +49,16 @@ class CMakeTests {
|
|
|
49
49
|
child.stdout.on("data", (chunk) => {
|
|
50
50
|
output += chunk.toString();
|
|
51
51
|
});
|
|
52
|
-
child.on("
|
|
52
|
+
child.on("close", (code) => {
|
|
53
53
|
if (code === 0) {
|
|
54
|
-
|
|
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
|
+
}
|
|
55
62
|
}
|
|
56
63
|
else {
|
|
57
64
|
reject(new Error("Failed to run ctest"));
|
package/out/qttest.js
CHANGED
|
@@ -43,6 +43,7 @@ const child_process_1 = require("child_process");
|
|
|
43
43
|
const path_1 = __importDefault(require("path"));
|
|
44
44
|
const fs = __importStar(require("fs"));
|
|
45
45
|
const cmake_1 = require("./cmake");
|
|
46
|
+
const tap_parser_1 = require("tap-parser");
|
|
46
47
|
var gLogFunction;
|
|
47
48
|
function logMessage(message) {
|
|
48
49
|
if (gLogFunction) {
|
|
@@ -211,8 +212,8 @@ class QtTest {
|
|
|
211
212
|
return undefined;
|
|
212
213
|
}
|
|
213
214
|
/// Runs this test
|
|
214
|
-
runTest(
|
|
215
|
-
return __awaiter(this,
|
|
215
|
+
runTest(slot_1) {
|
|
216
|
+
return __awaiter(this, arguments, void 0, function* (slot, cwd = "") {
|
|
216
217
|
let args = [];
|
|
217
218
|
if (slot) {
|
|
218
219
|
// Runs a single Qt test instead
|
|
@@ -302,15 +303,48 @@ class QtTest {
|
|
|
302
303
|
reject(error);
|
|
303
304
|
}
|
|
304
305
|
else {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
306
|
+
let failedResults = [];
|
|
307
|
+
try {
|
|
308
|
+
const tap_events = tap_parser_1.Parser.parse(data);
|
|
309
|
+
for (let event of tap_events) {
|
|
310
|
+
try {
|
|
311
|
+
if (event.length < 2)
|
|
312
|
+
continue;
|
|
313
|
+
if (event.at(0) != "assert")
|
|
314
|
+
continue;
|
|
315
|
+
var obj = event.at(1);
|
|
316
|
+
let pass = obj["ok"] === true;
|
|
317
|
+
let xfail = !pass && obj["todo"] !== false;
|
|
318
|
+
if (xfail) {
|
|
319
|
+
// This is a QEXPECT_FAIL test, all good.
|
|
320
|
+
// QtTest outputs it as "todo"
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
// There's an QEXPECT_FAIL but test passed, not good.
|
|
324
|
+
let xpass = pass && obj["todo"].includes("returned TRUE unexpectedly");
|
|
325
|
+
if (!pass || xpass) {
|
|
326
|
+
// We found a failure
|
|
327
|
+
var name = obj["name"].replace(/\(.*\)/, "");
|
|
328
|
+
var filename = "";
|
|
329
|
+
var lineNumber = -1;
|
|
330
|
+
if (obj["diag"]) {
|
|
331
|
+
filename = obj["diag"]["file"];
|
|
332
|
+
lineNumber = obj["diag"]["line"];
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
// A XPASS for example misses file:line info. Nothing we can do, it's a Qt bug arguably.
|
|
336
|
+
}
|
|
337
|
+
failedResults.push({
|
|
338
|
+
name: name,
|
|
339
|
+
filePath: filename,
|
|
340
|
+
lineNumber: lineNumber,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
catch (e) { }
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (e) { }
|
|
314
348
|
resolve(failedResults);
|
|
315
349
|
}
|
|
316
350
|
});
|
package/out/test.js
CHANGED
|
@@ -57,8 +57,14 @@ function runTests(buildDirPath) {
|
|
|
57
57
|
// 2. Test that the discovered slots are correct:
|
|
58
58
|
yield qt.dumpTestSlots();
|
|
59
59
|
let expected_slots = {
|
|
60
|
-
"test/qt_test/build-dev/test1": ["testA", "testB", "testC"],
|
|
61
|
-
"test/qt_test/build-dev/test2": [
|
|
60
|
+
"test/qt_test/build-dev/test1": ["testA", "testB", "testC", "testXFAIL"],
|
|
61
|
+
"test/qt_test/build-dev/test2": [
|
|
62
|
+
"testD",
|
|
63
|
+
"testE",
|
|
64
|
+
"testF",
|
|
65
|
+
"testXPASS",
|
|
66
|
+
"testMixXFAILWithFAIL",
|
|
67
|
+
],
|
|
62
68
|
"test/qt_test/build-dev/test3": ["testAbortsEverythig", "testH", "testI"],
|
|
63
69
|
};
|
|
64
70
|
for (var executable of qt.qtTestExecutables) {
|
|
@@ -122,6 +128,39 @@ function runTests(buildDirPath) {
|
|
|
122
128
|
console.error("Expected 0 executables, got " + executables.length);
|
|
123
129
|
process.exit(1);
|
|
124
130
|
}
|
|
131
|
+
// 6. Run a slot that has XFAIL
|
|
132
|
+
slot = qt.qtTestExecutables[0].slots[3];
|
|
133
|
+
if (slot.name != "testXFAIL") {
|
|
134
|
+
console.error("Expected slot name to be testXFAIL");
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
yield slot.runTest();
|
|
138
|
+
if (slot.lastTestFailure) {
|
|
139
|
+
console.error("Expected test to pass: " + slot.name);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
// 7. Run a slot that has XPASS
|
|
143
|
+
slot = qt.qtTestExecutables[1].slots[3];
|
|
144
|
+
if (slot.name != "testXPASS") {
|
|
145
|
+
console.error("Expected slot name to be testXPASS");
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
yield slot.runTest();
|
|
149
|
+
if (!slot.lastTestFailure) {
|
|
150
|
+
console.error("Expected test to fail: " + slot.name);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
// 8. Run a slot that has both XFAIL and FAIL
|
|
154
|
+
slot = qt.qtTestExecutables[1].slots[4];
|
|
155
|
+
if (slot.name != "testMixXFAILWithFAIL") {
|
|
156
|
+
console.error("Expected slot name to be testMixXFAILWithFAIL");
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
yield slot.runTest();
|
|
160
|
+
if (!slot.lastTestFailure) {
|
|
161
|
+
console.error("Expected test to fail: " + slot.name);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
125
164
|
});
|
|
126
165
|
}
|
|
127
166
|
function runCodeModelTests(codeModelFile) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamsergio/qttest-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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",
|
|
@@ -22,5 +22,8 @@
|
|
|
22
22
|
"@types/node": "^18.15.0",
|
|
23
23
|
"ts-node": "^10.9.1",
|
|
24
24
|
"typescript": "^5.4.4"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"tap-parser": "^16.0.1"
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"packages": {
|
|
3
|
+
".": {
|
|
4
|
+
"package-name": "",
|
|
5
|
+
"component": "",
|
|
6
|
+
"changelog-path": "Changelog",
|
|
7
|
+
"release-type": "node",
|
|
8
|
+
"bump-minor-pre-major": false,
|
|
9
|
+
"bump-patch-for-minor-pre-major": false,
|
|
10
|
+
"draft": false,
|
|
11
|
+
"prerelease": false,
|
|
12
|
+
"pull-request-title-pattern": "chore: Bump to v${version}"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
|
16
|
+
}
|
package/test.sh
ADDED