@iamsergio/qttest-utils 1.2.0 โ 1.4.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/CONTRIBUTING.md +1 -1
- package/Changelog +36 -0
- package/out/cmake.d.ts +1 -0
- package/out/cmake.js +54 -0
- package/out/qttest.d.ts +1 -1
- package/out/qttest.js +13 -3
- package/out/test.js +21 -0
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -27,7 +27,7 @@ cargo install git-cliff
|
|
|
27
27
|
|
|
28
28
|
(Replace 1.0.0 with actual version used)
|
|
29
29
|
|
|
30
|
-
export NEW_VERSION=v1.
|
|
30
|
+
export NEW_VERSION=v1.0.0
|
|
31
31
|
- Make sure Github Actions CI is green
|
|
32
32
|
- Optional: To get a version compatible with semver, run `git cliff --bump`
|
|
33
33
|
- Increase version in package.json and package-lock.json.
|
package/Changelog
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [1.4.0] - 2024-04-24
|
|
6
|
+
|
|
7
|
+
### ๐ Features
|
|
8
|
+
|
|
9
|
+
- Allow the caller to pass a output callback
|
|
10
|
+
|
|
11
|
+
### ๐ Bug Fixes
|
|
12
|
+
|
|
13
|
+
- When running a qttest, output to stdout
|
|
14
|
+
|
|
15
|
+
## [1.3.0] - 2024-04-23
|
|
16
|
+
|
|
17
|
+
### ๐ Features
|
|
18
|
+
|
|
19
|
+
- Add cppFilesForExecutable(executable, codemodel)
|
|
20
|
+
|
|
21
|
+
### ๐งช Testing
|
|
22
|
+
|
|
23
|
+
- Add an example cmake code model
|
|
24
|
+
- Normalize paths
|
|
25
|
+
- Simplify some code
|
|
26
|
+
- Fix replacing slashes
|
|
27
|
+
|
|
28
|
+
### โ๏ธ Miscellaneous Tasks
|
|
29
|
+
|
|
30
|
+
- Add more logging
|
|
31
|
+
- Bump version
|
|
32
|
+
|
|
5
33
|
## [1.2.0] - 2024-04-22
|
|
6
34
|
|
|
7
35
|
### ๐ Features
|
|
@@ -13,6 +41,14 @@
|
|
|
13
41
|
- Minor CONTRIBUTIND.md improvement
|
|
14
42
|
- Minor CONTRIBUTIND.md improvement
|
|
15
43
|
|
|
44
|
+
### ๐งช Testing
|
|
45
|
+
|
|
46
|
+
- Fix test on windows
|
|
47
|
+
|
|
48
|
+
### โ๏ธ Miscellaneous Tasks
|
|
49
|
+
|
|
50
|
+
- Bump version
|
|
51
|
+
|
|
16
52
|
## [1.1.2] - 2024-04-07
|
|
17
53
|
|
|
18
54
|
### โ๏ธ Miscellaneous Tasks
|
package/out/cmake.d.ts
CHANGED
package/out/cmake.js
CHANGED
|
@@ -72,6 +72,60 @@ class CMakeTests {
|
|
|
72
72
|
});
|
|
73
73
|
return tests;
|
|
74
74
|
}
|
|
75
|
+
// Returns the list of .cpp files for the specified executable
|
|
76
|
+
// codemodel is the CMake codemodel JSON object
|
|
77
|
+
cppFilesForExecutable(executable, codemodel) {
|
|
78
|
+
// simplify:
|
|
79
|
+
if (executable.endsWith(".exe")) {
|
|
80
|
+
executable = executable.substring(0, executable.length - 4);
|
|
81
|
+
}
|
|
82
|
+
let projects = codemodel["projects"];
|
|
83
|
+
if (!projects) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
for (let project of projects) {
|
|
87
|
+
let targets = project["targets"];
|
|
88
|
+
if (!targets) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
for (let target of targets) {
|
|
92
|
+
let sourceDir = target["sourceDirectory"];
|
|
93
|
+
let artifacts = target["artifacts"];
|
|
94
|
+
if (!artifacts || !sourceDir) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
for (let artifact of artifacts) {
|
|
98
|
+
if (artifact.endsWith(".exe")) {
|
|
99
|
+
artifact = artifact.substring(0, artifact.length - 4);
|
|
100
|
+
}
|
|
101
|
+
if (artifact == executable) {
|
|
102
|
+
let fileGroups = target["fileGroups"];
|
|
103
|
+
if (!fileGroups) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
for (let fileGroup of fileGroups) {
|
|
107
|
+
if (fileGroup["language"] != "CXX" || fileGroup["isGenerated"]) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
let sources = fileGroup["sources"];
|
|
111
|
+
if (!sources) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
let cppFiles = [];
|
|
115
|
+
for (let source of sources) {
|
|
116
|
+
if (!source.endsWith("mocs_compilation.cpp")) {
|
|
117
|
+
cppFiles.push(path_1.default.join(sourceDir, source));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return cppFiles;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
(0, qttest_1.logMessage)("cppFilesForExecutable: Could not find cpp files for executable " + executable);
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
75
129
|
}
|
|
76
130
|
exports.CMakeTests = CMakeTests;
|
|
77
131
|
/// Represents an inividual CTest test
|
package/out/qttest.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class QtTest {
|
|
|
30
30
|
linksToQtTestLib(): Promise<boolean> | undefined;
|
|
31
31
|
isQtTestViaHelp(): Promise<boolean | undefined>;
|
|
32
32
|
slotByName(name: string): QtTestSlot | undefined;
|
|
33
|
-
runTest(slot?: QtTestSlot, cwd?: string): Promise<boolean>;
|
|
33
|
+
runTest(slot?: QtTestSlot, cwd?: string, outputFunc?: LoggerFunction | undefined): Promise<boolean>;
|
|
34
34
|
tapOutputFileName(slot?: QtTestSlot): string;
|
|
35
35
|
txtOutputFileName(slot?: QtTestSlot): string;
|
|
36
36
|
command(): {
|
package/out/qttest.js
CHANGED
|
@@ -201,7 +201,7 @@ class QtTest {
|
|
|
201
201
|
return undefined;
|
|
202
202
|
}
|
|
203
203
|
/// Runs this test
|
|
204
|
-
runTest(slot, cwd = "") {
|
|
204
|
+
runTest(slot, cwd = "", outputFunc = undefined) {
|
|
205
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
206
|
let args = [];
|
|
207
207
|
if (slot) {
|
|
@@ -211,15 +211,25 @@ class QtTest {
|
|
|
211
211
|
else {
|
|
212
212
|
this.clearSubTestStates();
|
|
213
213
|
}
|
|
214
|
-
// log to file
|
|
214
|
+
// log to file and to stdout
|
|
215
215
|
args = args.concat("-o").concat(this.tapOutputFileName(slot) + ",tap");
|
|
216
216
|
args = args.concat("-o").concat(this.txtOutputFileName(slot) + ",txt");
|
|
217
|
+
args = args.concat("-o").concat("-,txt");
|
|
217
218
|
return yield new Promise((resolve, reject) => {
|
|
218
219
|
let cwdDir = cwd.length > 0 ? cwd : this.buildDirPath;
|
|
219
220
|
logMessage("Running " + this.filename + " " + args.join(" ") + " with cwd=" + cwdDir);
|
|
220
221
|
const child = (0, child_process_1.spawn)(this.filename, args, { cwd: cwdDir });
|
|
222
|
+
if (outputFunc) {
|
|
223
|
+
// Callers wants the process output:
|
|
224
|
+
child.stdout.on("data", (chunk) => {
|
|
225
|
+
outputFunc(chunk.toString());
|
|
226
|
+
});
|
|
227
|
+
child.stderr.on("data", (chunk) => {
|
|
228
|
+
outputFunc(chunk.toString());
|
|
229
|
+
});
|
|
230
|
+
}
|
|
221
231
|
child.on("exit", (code) => __awaiter(this, void 0, void 0, function* () {
|
|
222
|
-
///
|
|
232
|
+
/// Can code even be null ?
|
|
223
233
|
if (code == undefined)
|
|
224
234
|
code = -1;
|
|
225
235
|
if (!slot) {
|
package/out/test.js
CHANGED
|
@@ -12,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const cmake_1 = require("./cmake");
|
|
15
16
|
const qttest_1 = require("./qttest");
|
|
16
17
|
// Be sure to build the Qt tests with CMake first
|
|
17
18
|
// See .github/workflows/ci.yml
|
|
@@ -109,4 +110,24 @@ function runTests(buildDirPath) {
|
|
|
109
110
|
}
|
|
110
111
|
});
|
|
111
112
|
}
|
|
113
|
+
function runCodeModelTests(codeModelFile) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const fs = require('fs');
|
|
116
|
+
let codemodelStr = fs.readFileSync(codeModelFile, 'utf8');
|
|
117
|
+
let codemodelJson = JSON.parse(codemodelStr);
|
|
118
|
+
let cmake = new cmake_1.CMakeTests("random");
|
|
119
|
+
let files = cmake.cppFilesForExecutable("/vscode-qttest/test/qt_test/build-dev/test1", codemodelJson);
|
|
120
|
+
if (files.length != 1) {
|
|
121
|
+
console.error("Expected 1 file, got " + files.length);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
let expected = "/vscode-qttest/test/qt_test/test1.cpp";
|
|
125
|
+
let got = files[0].replace(/\\/g, "/");
|
|
126
|
+
if (got != expected) {
|
|
127
|
+
console.error("Expected " + expected + ", got " + got);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
112
132
|
runTests("test/qt_test/build-dev/");
|
|
133
|
+
runCodeModelTests("test/test_cmake_codemodel.json");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamsergio/qttest-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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",
|