@iamsergio/qttest-utils 1.1.2 โ 1.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/CONTRIBUTING.md +1 -4
- package/Changelog +37 -0
- package/out/cmake.d.ts +1 -0
- package/out/cmake.js +54 -0
- package/out/qttest.d.ts +2 -0
- package/out/qttest.js +20 -1
- package/out/test.js +36 -0
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -32,7 +32,4 @@ export NEW_VERSION=v1.0.0
|
|
|
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.
|
|
34
34
|
- git cliff --tag $NEW_VERSION > Changelog
|
|
35
|
-
- git add Changelog package.json package-lock.json && git commit -m "chore: bump version"
|
|
36
|
-
- git tag -a ${NEW_VERSION} -m "${NEW_VERSION}"
|
|
37
|
-
- git push && git push --tags
|
|
38
|
-
- npm publish
|
|
35
|
+
- git add Changelog package.json package-lock.json && git commit -m "chore: bump version" && git tag -a ${NEW_VERSION} -m "${NEW_VERSION}" && git push && git push --tags && npm publish
|
package/Changelog
CHANGED
|
@@ -2,11 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [1.3.0] - 2024-04-23
|
|
6
|
+
|
|
7
|
+
### ๐ Features
|
|
8
|
+
|
|
9
|
+
- Add cppFilesForExecutable(executable, codemodel)
|
|
10
|
+
|
|
11
|
+
### ๐งช Testing
|
|
12
|
+
|
|
13
|
+
- Add an example cmake code model
|
|
14
|
+
- Normalize paths
|
|
15
|
+
- Simplify some code
|
|
16
|
+
- Fix replacing slashes
|
|
17
|
+
|
|
18
|
+
### โ๏ธ Miscellaneous Tasks
|
|
19
|
+
|
|
20
|
+
- Add more logging
|
|
21
|
+
|
|
22
|
+
## [1.2.0] - 2024-04-22
|
|
23
|
+
|
|
24
|
+
### ๐ Features
|
|
25
|
+
|
|
26
|
+
- Added executablesContainingSlot(name) public method
|
|
27
|
+
|
|
28
|
+
### ๐ Documentation
|
|
29
|
+
|
|
30
|
+
- Minor CONTRIBUTIND.md improvement
|
|
31
|
+
- Minor CONTRIBUTIND.md improvement
|
|
32
|
+
|
|
33
|
+
### ๐งช Testing
|
|
34
|
+
|
|
35
|
+
- Fix test on windows
|
|
36
|
+
|
|
37
|
+
### โ๏ธ Miscellaneous Tasks
|
|
38
|
+
|
|
39
|
+
- Bump version
|
|
40
|
+
|
|
5
41
|
## [1.1.2] - 2024-04-07
|
|
6
42
|
|
|
7
43
|
### โ๏ธ Miscellaneous Tasks
|
|
8
44
|
|
|
9
45
|
- Add more logging
|
|
46
|
+
- Bump version
|
|
10
47
|
|
|
11
48
|
## [1.1.1] - 2024-04-07
|
|
12
49
|
|
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
|
@@ -15,6 +15,7 @@ export declare class QtTest {
|
|
|
15
15
|
get id(): string;
|
|
16
16
|
get label(): string;
|
|
17
17
|
relativeFilename(): string;
|
|
18
|
+
filenameWithoutExtension(): string;
|
|
18
19
|
/**
|
|
19
20
|
* Calls "./yourqttest -functions" and stores the results in the slots property.
|
|
20
21
|
*/
|
|
@@ -71,6 +72,7 @@ export declare class QtTests {
|
|
|
71
72
|
maintainMatching(regex: RegExp): void;
|
|
72
73
|
dumpExecutablePaths(): void;
|
|
73
74
|
dumpTestSlots(): Promise<void>;
|
|
75
|
+
executablesContainingSlot(slotName: string): QtTest[];
|
|
74
76
|
}
|
|
75
77
|
export interface TestFailure {
|
|
76
78
|
name: string;
|
package/out/qttest.js
CHANGED
|
@@ -80,6 +80,13 @@ class QtTest {
|
|
|
80
80
|
result = result.replace(/\\/g, "/");
|
|
81
81
|
return result;
|
|
82
82
|
}
|
|
83
|
+
/// returns filename without .exe extension
|
|
84
|
+
filenameWithoutExtension() {
|
|
85
|
+
let result = this.filename;
|
|
86
|
+
if (result.endsWith(".exe"))
|
|
87
|
+
result = result.slice(0, -4);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
83
90
|
/**
|
|
84
91
|
* Calls "./yourqttest -functions" and stores the results in the slots property.
|
|
85
92
|
*/
|
|
@@ -134,6 +141,8 @@ class QtTest {
|
|
|
134
141
|
return undefined;
|
|
135
142
|
}
|
|
136
143
|
return new Promise((resolve, reject) => {
|
|
144
|
+
if (this.verbose)
|
|
145
|
+
logMessage("qttest: Running ldd on " + this.filename);
|
|
137
146
|
const child = (0, child_process_1.spawn)("ldd", [this.filename]);
|
|
138
147
|
let output = "";
|
|
139
148
|
let result = false;
|
|
@@ -144,7 +153,7 @@ class QtTest {
|
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
if (this.verbose)
|
|
147
|
-
|
|
156
|
+
logMessage(chunk.toString());
|
|
148
157
|
});
|
|
149
158
|
child.on("exit", (code) => {
|
|
150
159
|
if (code === 0) {
|
|
@@ -390,5 +399,15 @@ class QtTests {
|
|
|
390
399
|
}
|
|
391
400
|
});
|
|
392
401
|
}
|
|
402
|
+
/// Returns all executables that contain a Qt test slot with the specified name
|
|
403
|
+
executablesContainingSlot(slotName) {
|
|
404
|
+
let result = [];
|
|
405
|
+
for (let ex of this.qtTestExecutables) {
|
|
406
|
+
if (ex.slotByName(slotName)) {
|
|
407
|
+
result.push(ex);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return result;
|
|
411
|
+
}
|
|
393
412
|
}
|
|
394
413
|
exports.QtTests = QtTests;
|
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
|
|
@@ -92,6 +93,41 @@ function runTests(buildDirPath) {
|
|
|
92
93
|
console.error("Expected test to fail: " + slot2.name);
|
|
93
94
|
process.exit(1);
|
|
94
95
|
}
|
|
96
|
+
// 5. Test executablesContainingSlot
|
|
97
|
+
let executables = qt.executablesContainingSlot("testB");
|
|
98
|
+
if (executables.length != 1) {
|
|
99
|
+
console.error("Expected 1 executable, got " + executables.length);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
if (!executables[0].filenameWithoutExtension().endsWith("test1")) {
|
|
103
|
+
console.error("Expected filename to end with test1");
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
executables = qt.executablesContainingSlot("non_existing");
|
|
107
|
+
if (executables.length != 0) {
|
|
108
|
+
console.error("Expected 0 executables, got " + executables.length);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
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
|
+
}
|
|
95
130
|
});
|
|
96
131
|
}
|
|
97
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.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",
|