@iamsergio/qttest-utils 2.3.0 โ†’ 2.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.0](https://github.com/KDAB/qttest-utils/compare/v2.5.0...v2.6.0) (2026-04-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * propagate CTest ENVIRONMENT to spawned test processes ([ea24d96](https://github.com/KDAB/qttest-utils/commit/ea24d96545c3ac9d68fc9cfea8ab6b372055b804))
9
+ * propagate CTest ENVIRONMENT to spawned test processes ([6a68cc7](https://github.com/KDAB/qttest-utils/commit/6a68cc7db40f53f3631579477deb780d36b36685))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * made eslint pass ([6740d61](https://github.com/KDAB/qttest-utils/commit/6740d618843a9a0a55fd73b7cc9e0c9f2412788e))
15
+
16
+ ## [2.5.0](https://github.com/KDAB/qttest-utils/compare/v2.4.4...v2.5.0) (2026-04-04)
17
+
18
+
19
+ ### Features
20
+
21
+ * move to node22 ([9918007](https://github.com/KDAB/qttest-utils/commit/9918007bb7765d0363452afdab06856d8505cf18))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * Remove the npm publish stuff from CI ([84069f5](https://github.com/KDAB/qttest-utils/commit/84069f594073c1ea54fe58915aa1beb70353d7e0))
27
+
28
+ ## [2.4.4](https://github.com/KDAB/qttest-utils/compare/v2.4.3...v2.4.4) (2026-04-04)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * Add verbose flag to publish ([1db610e](https://github.com/KDAB/qttest-utils/commit/1db610e9a372c88435460140e6e31769649bfcd0))
34
+
35
+ ## [2.4.3](https://github.com/KDAB/qttest-utils/compare/v2.4.2...v2.4.3) (2026-04-04)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * normalize repository url for npm provenance ([4c74b4b](https://github.com/KDAB/qttest-utils/commit/4c74b4b47bb170840be6a1b3ae6e7d70ed333b97))
41
+
42
+ ## [2.4.2](https://github.com/KDAB/qttest-utils/compare/v2.4.1...v2.4.2) (2026-04-04)
43
+
44
+
45
+ ### Bug Fixes
46
+
47
+ * Testing release process ([01e5b2e](https://github.com/KDAB/qttest-utils/commit/01e5b2e608289f9dc86ff553459276e4fc83a801))
48
+
49
+ ## [2.4.1](https://github.com/KDAB/qttest-utils/compare/v2.4.0...v2.4.1) (2026-04-04)
50
+
51
+
52
+ ### Bug Fixes
53
+
54
+ * Remove cliff and update to new release-please action ([7480c13](https://github.com/KDAB/qttest-utils/commit/7480c132962de8274a7ccfaf84b19a8a5f192bfa))
55
+ * Remove unneeded cruft from package ([b33c153](https://github.com/KDAB/qttest-utils/commit/b33c1538da9177ea11c1fd546075e149e32a6738))
56
+
57
+ ## [2.4.0](https://github.com/KDAB/qttest-utils/compare/v2.3.0...v2.4.0) (2026-04-03)
58
+
59
+
60
+ ### Features
61
+
62
+ * bump TypeScript target to ES2022 and add engines field ([9d44860](https://github.com/KDAB/qttest-utils/commit/9d44860dc40b48373b3eaed22abf577e191a84c1))
63
+ * rename cmake presets, make Qt6 the default ([#6](https://github.com/KDAB/qttest-utils/issues/6)) ([f60b6e7](https://github.com/KDAB/qttest-utils/commit/f60b6e72fdc1d6b3e86fb840c80aa8498c5bac94))
64
+
65
+
66
+ ### Bug Fixes
67
+
68
+ * add rootDir to tsconfig to fix TS5011 with ES2022 target ([d921982](https://github.com/KDAB/qttest-utils/commit/d921982bbbda550f22aa764b6e138bd5fe761771))
69
+
3
70
  ## [2.3.0](https://github.com/KDAB/qttest-utils/compare/v2.2.2...v2.3.0) (2024-06-06)
4
71
 
5
72
 
@@ -13,3 +80,232 @@
13
80
 
14
81
  * Fix JSON output from ctest not being received ([9cea2c3](https://github.com/KDAB/qttest-utils/commit/9cea2c3dd4b5798f7f6f0bf382e5eca1694f0eb2))
15
82
  * Use tap-parser instead of regexp to parse tap files ([3d9f1f5](https://github.com/KDAB/qttest-utils/commit/3d9f1f5abc77d2af1a57ba6a75b89c8a3ad424ed))
83
+
84
+ # Changelog
85
+
86
+
87
+
88
+ ## [2.2.2] - 2024-05-02
89
+
90
+ ### ๐Ÿ› Bug Fixes
91
+
92
+ - Filter out weird tests
93
+
94
+ ### โš™๏ธ Miscellaneous Tasks
95
+
96
+ - Code format cmake.ts
97
+
98
+ ## [2.2.1] - 2024-05-02
99
+
100
+ ### ๐Ÿ› Bug Fixes
101
+
102
+ - Fix running non-Qt tests
103
+ - Harden code against exception when reading .tap file
104
+
105
+ ### ๐Ÿงช Testing
106
+
107
+ - Try fixing tests on macOS/Windows
108
+ - Try harder to fix macOS/Windows tests
109
+
110
+ ### โš™๏ธ Miscellaneous Tasks
111
+
112
+ - Ran code format on tests
113
+ - Run codeformat on qttest.ts
114
+ - Bump version
115
+
116
+ ## [2.2.0] - 2024-04-25
117
+
118
+ ### ๐Ÿš€ Features
119
+
120
+ - Allow to workaround microsoft/vscode-cmake-tools-api/issues/7
121
+
122
+ ### โš™๏ธ Miscellaneous Tasks
123
+
124
+ - Bump version
125
+
126
+ ## [2.1.1] - 2024-04-25
127
+
128
+ ### ๐Ÿ› Bug Fixes
129
+
130
+ - Allow for backslashes in the cmake codemodel
131
+
132
+ ### โš™๏ธ Miscellaneous Tasks
133
+
134
+ - Improve CONTRIBUTING.md
135
+ - Bump version
136
+
137
+ ## [2.1.0] - 2024-04-25
138
+
139
+ ### ๐Ÿš€ Features
140
+
141
+ - Add targetNameForExecutable()
142
+
143
+ ### ๐Ÿ› Bug Fixes
144
+
145
+ - Ignore non-executable targets
146
+
147
+ ### โš™๏ธ Miscellaneous Tasks
148
+
149
+ - Coding style improvement
150
+ - Update CONTRIBUTING.md file
151
+ - Fix build on macOS
152
+ - Improve CONTRIBUTING.md
153
+ - Bump version
154
+
155
+ ## [2.0.0] - 2024-04-24
156
+
157
+ ### ๐Ÿš€ Features
158
+
159
+ - [**breaking**] Use a member to hold the output function
160
+
161
+ ### โš™๏ธ Miscellaneous Tasks
162
+
163
+ - Bump version
164
+
165
+ ## [1.4.0] - 2024-04-24
166
+
167
+ ### ๐Ÿš€ Features
168
+
169
+ - Allow the caller to pass a output callback
170
+
171
+ ### ๐Ÿ› Bug Fixes
172
+
173
+ - When running a qttest, output to stdout
174
+
175
+ ### โš™๏ธ Miscellaneous Tasks
176
+
177
+ - Bump version
178
+
179
+ ## [1.3.0] - 2024-04-23
180
+
181
+ ### ๐Ÿš€ Features
182
+
183
+ - Add cppFilesForExecutable(executable, codemodel)
184
+
185
+ ### ๐Ÿงช Testing
186
+
187
+ - Add an example cmake code model
188
+ - Normalize paths
189
+ - Simplify some code
190
+ - Fix replacing slashes
191
+
192
+ ### โš™๏ธ Miscellaneous Tasks
193
+
194
+ - Add more logging
195
+ - Bump version
196
+
197
+ ## [1.2.0] - 2024-04-22
198
+
199
+ ### ๐Ÿš€ Features
200
+
201
+ - Added executablesContainingSlot(name) public method
202
+
203
+ ### ๐Ÿ“š Documentation
204
+
205
+ - Minor CONTRIBUTIND.md improvement
206
+ - Minor CONTRIBUTIND.md improvement
207
+
208
+ ### ๐Ÿงช Testing
209
+
210
+ - Fix test on windows
211
+
212
+ ### โš™๏ธ Miscellaneous Tasks
213
+
214
+ - Bump version
215
+
216
+ ## [1.1.2] - 2024-04-07
217
+
218
+ ### โš™๏ธ Miscellaneous Tasks
219
+
220
+ - Add more logging
221
+ - Bump version
222
+
223
+ ## [1.1.1] - 2024-04-07
224
+
225
+ ### ๐Ÿ› Bug Fixes
226
+
227
+ - Verbose logging not appearing in vscode
228
+
229
+ ### โš™๏ธ Miscellaneous Tasks
230
+
231
+ - Improve CONTRIBUTING.md
232
+ - Bump version
233
+
234
+ ## [1.1.0] - 2024-04-07
235
+
236
+ ### ๐Ÿš€ Features
237
+
238
+ - Added QtTest.verbose property
239
+
240
+ ### ๐Ÿงช Testing
241
+
242
+ - Add a QBENCHMARK
243
+ - Fix tests on windows
244
+ - Fix more cases of wrong slashes
245
+ - Test linksToQtTestLib too
246
+
247
+ ### โš™๏ธ Miscellaneous Tasks
248
+
249
+ - Minor readme comment
250
+ - Update .npmignore
251
+ - Fix typo in README
252
+ - Fix badge urls in README
253
+ - Mention the vscode extension in the README
254
+ - Remove duplicate vscode workspace file
255
+ - Add macOS and Windows to CI
256
+ - Make npm install be verose
257
+ - Trying fixing the path for tsc on macos
258
+ - Update packages
259
+ - Bump version
260
+
261
+ ## [1.0.0] - 2024-04-04
262
+
263
+ ### ๐Ÿงช Testing
264
+
265
+ - Add a proper test and add it to cI
266
+
267
+ ### โš™๏ธ Miscellaneous Tasks
268
+
269
+ - Add a git-cliff configuration file
270
+ - Add pre-commit support
271
+ - README improvements
272
+ - Add installation instructions to README
273
+ - Add a Dockerfile with nodejs 18
274
+ - *(ci)* Make pre-commit run on master branch
275
+ - Update version in package-lock.json
276
+ - *(docker)* Install npm, Qt5 and typescript
277
+ - *(ci)* Run tsc in ci
278
+ - *(ci)* Fix typo in yml file
279
+ - *(ci)* Bump to checkout v4
280
+ - *(ci)* Bump to setup-node v4
281
+ - *(ci)* Rename main ci job to 'build'
282
+ - *(vscode)* Add a workspace file
283
+ - Formatted some code automatically
284
+ - Fix typo in comment
285
+ - *(ci)* Install Qt and ninja
286
+ - Bump to version 1.0.0
287
+ - Regenerate out/
288
+ - Add a CONTRIBUTING.md file
289
+ - Update changelog
290
+ - Add ci badges to readme
291
+
292
+ ## [0.4.9] - 2023-04-06
293
+
294
+ ### ๐Ÿงช Testing
295
+
296
+ - Make test3 abort at the beginning
297
+
298
+ ## [0.4.7] - 2023-04-02
299
+
300
+ ### ๐Ÿงช Testing
301
+
302
+ - Rename the test slots
303
+
304
+ ### README
305
+
306
+ - Explain how to run the example
307
+
308
+ ### Minor
309
+
310
+ - Ran formatting
311
+ - Pass the entire slot
package/out/cmake.d.ts CHANGED
@@ -20,6 +20,7 @@ export declare class CMakeTests {
20
20
  export declare class CMakeTest {
21
21
  command: string[];
22
22
  cwd: string;
23
+ environment: string[];
23
24
  id(): string;
24
25
  label(): string;
25
26
  executablePath(): string;
package/out/cmake.js CHANGED
@@ -2,15 +2,6 @@
2
2
  // SPDX-FileCopyrightText: 2023 Klarรคlvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3
3
  // Author: Sergio Martins <sergio.martins@kdab.com>
4
4
  // SPDX-License-Identifier: MIT
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
5
  var __importDefault = (this && this.__importDefault) || function (mod) {
15
6
  return (mod && mod.__esModule) ? mod : { "default": mod };
16
7
  };
@@ -25,6 +16,8 @@ const qttest_1 = require("./qttest");
25
16
  * Contains methods to discover Qt Tests via CMake
26
17
  */
27
18
  class CMakeTests {
19
+ // The build dir where we'll run
20
+ buildDirPath;
28
21
  constructor(buildDirPath) {
29
22
  this.buildDirPath = buildDirPath;
30
23
  }
@@ -33,39 +26,37 @@ class CMakeTests {
33
26
  *
34
27
  * @returns a promise with the list of tests
35
28
  */
36
- tests() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- // TODO: Check if folder exists
39
- if (this.buildDirPath.length == 0) {
40
- console.error("Could not find out cmake build dir");
41
- return undefined;
42
- }
43
- return new Promise((resolve, reject) => {
44
- (0, qttest_1.logMessage)("Running ctest --show-only=json-v1 with cwd=" + this.buildDirPath);
45
- const child = (0, child_process_1.spawn)("ctest", ["--show-only=json-v1"], {
46
- cwd: this.buildDirPath,
47
- });
48
- let output = "";
49
- child.stdout.on("data", (chunk) => {
50
- output += chunk.toString();
51
- });
52
- child.on("close", (code) => {
53
- if (code === 0) {
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
- }
29
+ async tests() {
30
+ // TODO: Check if folder exists
31
+ if (this.buildDirPath.length === 0) {
32
+ console.error("Could not find out cmake build dir");
33
+ return undefined;
34
+ }
35
+ return new Promise((resolve, reject) => {
36
+ (0, qttest_1.logMessage)("Running ctest --show-only=json-v1 with cwd=" + this.buildDirPath);
37
+ const child = (0, child_process_1.spawn)("ctest", ["--show-only=json-v1"], {
38
+ cwd: this.buildDirPath,
39
+ });
40
+ let output = "";
41
+ child.stdout.on("data", (chunk) => {
42
+ output += chunk.toString();
43
+ });
44
+ child.on("close", (code) => {
45
+ if (code === 0) {
46
+ if (output.length === 0) {
47
+ console.error("ctestJsonToList: Empty json output. Command was ctest --show-only=json-v1 , in " +
48
+ this.buildDirPath);
49
+ reject(new Error("Failed to get ctest JSON output"));
62
50
  }
63
51
  else {
64
- reject(new Error("Failed to run ctest"));
52
+ resolve(this.ctestJsonToList(output));
65
53
  }
66
- });
67
- return undefined;
54
+ }
55
+ else {
56
+ reject(new Error("Failed to run ctest"));
57
+ }
68
58
  });
59
+ return undefined;
69
60
  });
70
61
  }
71
62
  ctestJsonToList(json) {
@@ -77,20 +68,76 @@ class CMakeTests {
77
68
  let test = new CMakeTest();
78
69
  test.command = testJSON.command;
79
70
  test.cwd = testJSON.cwd;
71
+ // Extract environment information if present in ctest JSON.
72
+ // ctest may expose environment as `environment` (string or array),
73
+ // or embed it into `properties` either as an object or array.
74
+ try {
75
+ let envArr = undefined;
76
+ if (testJSON.environment) {
77
+ envArr = Array.isArray(testJSON.environment)
78
+ ? testJSON.environment
79
+ : [testJSON.environment];
80
+ }
81
+ if (!envArr && testJSON.properties) {
82
+ const props = testJSON.properties;
83
+ // properties might be an object with ENVIRONMENT key or an array of {name,value} entries
84
+ if (!Array.isArray(props) && props.ENVIRONMENT) {
85
+ const val = props.ENVIRONMENT;
86
+ if (typeof val === "string") {
87
+ envArr = [val];
88
+ }
89
+ else if (Array.isArray(val)) {
90
+ envArr = val;
91
+ }
92
+ }
93
+ else if (Array.isArray(props)) {
94
+ for (const p of props) {
95
+ if (!p || !p.name) {
96
+ continue;
97
+ }
98
+ if (p.name === "ENVIRONMENT" || p.name === "Environment") {
99
+ const v = p.value;
100
+ if (typeof v === "string") {
101
+ envArr = [v];
102
+ }
103
+ else if (Array.isArray(v)) {
104
+ envArr = v;
105
+ }
106
+ break;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ if (envArr) {
112
+ test.environment = envArr;
113
+ }
114
+ }
115
+ catch (e) {
116
+ try {
117
+ (0, qttest_1.logMessage)("ctest: failed to parse environment for test: " +
118
+ JSON.stringify(testJSON) +
119
+ " error: " +
120
+ e);
121
+ }
122
+ catch (_) { }
123
+ }
80
124
  return test;
81
125
  });
82
126
  // filter invalid tests:
83
127
  tests = tests.filter((test) => {
84
128
  // pretty print test
85
- if (!test.command || test.command.length == 0)
129
+ if (!test.command || test.command.length === 0) {
86
130
  return false;
131
+ }
87
132
  let testExecutablePath = test.executablePath();
88
133
  let baseName = path_1.default.basename(testExecutablePath).toLowerCase();
89
- if (baseName.endsWith(".exe"))
134
+ if (baseName.endsWith(".exe")) {
90
135
  baseName = baseName.substring(0, baseName.length - 4);
136
+ }
91
137
  // People doing complicated things in add_test()
92
- if (baseName == "ctest" || baseName === "cmake")
138
+ if (baseName === "ctest" || baseName === "cmake") {
93
139
  return false;
140
+ }
94
141
  return true;
95
142
  });
96
143
  return tests;
@@ -99,16 +146,19 @@ class CMakeTests {
99
146
  /// codemodel should have a "projects" key at root.
100
147
  targetNameForExecutable(executable, codemodel, workaround = false) {
101
148
  let projects = codemodel["projects"];
102
- if (!projects)
149
+ if (!projects) {
103
150
  return undefined;
151
+ }
104
152
  for (let project of projects) {
105
153
  let targets = project["targets"];
106
- if (!targets)
154
+ if (!targets) {
107
155
  continue;
156
+ }
108
157
  for (let target of targets) {
109
158
  let artifacts = target["artifacts"];
110
- if (!artifacts)
159
+ if (!artifacts) {
111
160
  continue;
161
+ }
112
162
  for (let artifact of artifacts) {
113
163
  if (artifact.endsWith(".exe")) {
114
164
  artifact = artifact.substring(0, artifact.length - 4);
@@ -129,18 +179,21 @@ class CMakeTests {
129
179
  /// If workaround is true, then we workaround microsoft/vscode-cmake-tools-api/issues/7 where
130
180
  /// the basename is correct but the path is bogus, and we only compare the basenames
131
181
  filenamesAreEqual(file1, file2, workaround = false) {
132
- if (file1.endsWith(".exe"))
182
+ if (file1.endsWith(".exe")) {
133
183
  file1 = file1.substring(0, file1.length - 4);
134
- if (file2.endsWith(".exe"))
184
+ }
185
+ if (file2.endsWith(".exe")) {
135
186
  file2 = file2.substring(0, file2.length - 4);
187
+ }
136
188
  file1 = file1.replace(/\\/g, "/");
137
189
  file2 = file2.replace(/\\/g, "/");
138
190
  if (process.platform === "win32") {
139
191
  file1 = file1.toLowerCase();
140
192
  file2 = file2.toLowerCase();
141
193
  }
142
- if (file1 == file2)
194
+ if (file1 === file2) {
143
195
  return true;
196
+ }
144
197
  if (!workaround) {
145
198
  // files aren't equal!
146
199
  return false;
@@ -151,7 +204,7 @@ class CMakeTests {
151
204
  return false;
152
205
  }
153
206
  /// Compare only basename, since path is bogus
154
- return path_1.default.basename(file1, ".exe") == path_1.default.basename(file2, ".exe");
207
+ return path_1.default.basename(file1, ".exe") === path_1.default.basename(file2, ".exe");
155
208
  }
156
209
  /// Returns the list of .cpp files for the specified executable
157
210
  /// codemodel is the CMake codemodel JSON object
@@ -159,20 +212,24 @@ class CMakeTests {
159
212
  /// @param workaround If true, worksaround https://github.com/microsoft/vscode-cmake-tools-api/issues/7
160
213
  cppFilesForExecutable(executable, codemodel, workaround = false) {
161
214
  let projects = codemodel["projects"];
162
- if (!projects)
215
+ if (!projects) {
163
216
  return [];
217
+ }
164
218
  for (let project of projects) {
165
219
  let targets = project["targets"];
166
- if (!targets)
220
+ if (!targets) {
167
221
  continue;
222
+ }
168
223
  for (let target of targets) {
169
224
  let sourceDir = target["sourceDirectory"];
170
225
  let artifacts = target["artifacts"];
171
- if (!artifacts || !sourceDir)
226
+ if (!artifacts || !sourceDir) {
172
227
  continue;
228
+ }
173
229
  let targetType = target["type"];
174
- if (targetType != "EXECUTABLE")
230
+ if (targetType !== "EXECUTABLE") {
175
231
  continue;
232
+ }
176
233
  for (let artifact of artifacts) {
177
234
  if (artifact.endsWith(".exe")) {
178
235
  artifact = artifact.substring(0, artifact.length - 4);
@@ -181,14 +238,17 @@ class CMakeTests {
181
238
  artifact = artifact.replace(/\\/g, "/");
182
239
  if (this.filenamesAreEqual(executable, artifact, workaround)) {
183
240
  let fileGroups = target["fileGroups"];
184
- if (!fileGroups)
241
+ if (!fileGroups) {
185
242
  continue;
243
+ }
186
244
  for (let fileGroup of fileGroups) {
187
- if (fileGroup["language"] != "CXX" || fileGroup["isGenerated"])
245
+ if (fileGroup["language"] !== "CXX" || fileGroup["isGenerated"]) {
188
246
  continue;
247
+ }
189
248
  let sources = fileGroup["sources"];
190
- if (!sources)
249
+ if (!sources) {
191
250
  continue;
251
+ }
192
252
  let cppFiles = [];
193
253
  for (let source of sources) {
194
254
  if (!source.endsWith("mocs_compilation.cpp")) {
@@ -209,10 +269,9 @@ class CMakeTests {
209
269
  exports.CMakeTests = CMakeTests;
210
270
  /// Represents an inividual CTest test
211
271
  class CMakeTest {
212
- constructor() {
213
- this.command = [];
214
- this.cwd = "";
215
- }
272
+ command = [];
273
+ cwd = "";
274
+ environment = [];
216
275
  id() {
217
276
  return this.command.join(",");
218
277
  }