@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/out/example.js CHANGED
@@ -2,77 +2,80 @@
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
  };
17
8
  Object.defineProperty(exports, "__esModule", { value: true });
18
9
  const qttest_1 = require("./qttest");
19
10
  const fs_1 = __importDefault(require("fs"));
20
- function example() {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const args = process.argv.slice(2);
23
- if (args.length != 1) {
24
- console.error("ERROR: Expected a single argument with the build-dir with cmake tests!");
25
- process.exit(2);
11
+ async function example() {
12
+ const args = process.argv.slice(2);
13
+ if (args.length !== 1) {
14
+ console.error("ERROR: Expected a single argument with the build-dir with cmake tests!");
15
+ process.exit(2);
16
+ }
17
+ let buildDirPath = args[0];
18
+ if (!fs_1.default.existsSync(buildDirPath)) {
19
+ console.error("Directory does not exist!");
20
+ process.exit(1);
21
+ }
22
+ let qt = new qttest_1.QtTests();
23
+ qt.setLogFunction((message) => {
24
+ console.log(message);
25
+ });
26
+ // Gather all tests that would be executed by CTest:
27
+ await qt.discoverViaCMake(buildDirPath);
28
+ // Filter-out the ones that don't link to QtTest (doctests and such)
29
+ await qt.removeNonLinking();
30
+ // Example of filtering out by regexp:
31
+ qt.removeMatching(/(tst_view|tst_window)/);
32
+ // Uncomment to see example of filtering out by regexp (inverted):
33
+ // qt.maintainMatching(/(tst_docks|tst_qtwidgets|tst_multisplitter)/);
34
+ qt.dumpExecutablePaths();
35
+ await qt.dumpTestSlots();
36
+ console.log("\nRunning tests...");
37
+ for (var executable of qt.qtTestExecutables) {
38
+ await executable.runTest();
39
+ if (executable.lastExitCode === 0) {
40
+ console.log(" PASS: " + executable.filename);
26
41
  }
27
- let buildDirPath = args[0];
28
- if (!fs_1.default.existsSync(buildDirPath)) {
29
- console.error('Directory does not exist!');
30
- process.exit(1);
42
+ else {
43
+ console.log(" FAIL: " +
44
+ executable.filename +
45
+ "; code=" +
46
+ executable.lastExitCode);
31
47
  }
32
- let qt = new qttest_1.QtTests();
33
- qt.setLogFunction((message) => {
34
- console.log(message);
35
- });
36
- // Gather all tests that would be executed by CTest:
37
- yield qt.discoverViaCMake(buildDirPath);
38
- // Filter-out the ones that don't link to QtTest (doctests and such)
39
- yield qt.removeNonLinking();
40
- // Example of filtering out by regexp:
41
- qt.removeMatching(/(tst_view|tst_window)/);
42
- // Uncomment to see example of filtering out by regexp (inverted):
43
- // qt.maintainMatching(/(tst_docks|tst_qtwidgets|tst_multisplitter)/);
44
- qt.dumpExecutablePaths();
45
- yield qt.dumpTestSlots();
46
- console.log("\nRunning tests...");
47
- for (var executable of qt.qtTestExecutables) {
48
- yield executable.runTest();
49
- if (executable.lastExitCode === 0)
50
- console.log(" PASS: " + executable.filename);
51
- else
52
- console.log(" FAIL: " + executable.filename + "; code=" + executable.lastExitCode);
53
- for (let slot of executable.slots) {
54
- if (slot.lastTestFailure) {
55
- console.log(" failed slot=" + slot.name + "; path=" + slot.lastTestFailure.filePath + "; line=" + slot.lastTestFailure.lineNumber);
56
- }
57
- else {
58
- console.log(" pass: " + slot.name);
59
- }
48
+ for (let slot of executable.slots) {
49
+ if (slot.lastTestFailure) {
50
+ console.log(" failed slot=" +
51
+ slot.name +
52
+ "; path=" +
53
+ slot.lastTestFailure.filePath +
54
+ "; line=" +
55
+ slot.lastTestFailure.lineNumber);
56
+ }
57
+ else {
58
+ console.log(" pass: " + slot.name);
60
59
  }
61
60
  }
62
- // Also run individual slots, just for example purposes:
63
- console.log("\nRunning single tests...");
64
- let slot = qt.qtTestExecutables[1].slots[0];
65
- yield slot.runTest();
66
- if (slot.lastTestFailure)
67
- console.log(" FAIL:" + JSON.stringify(slot.lastTestFailure));
68
- else
69
- console.log(" PASS:");
70
- let slot2 = qt.qtTestExecutables[1].slots[2];
71
- yield slot2.runTest();
72
- if (slot2.lastTestFailure)
73
- console.log(" FAIL:" + JSON.stringify(slot2.lastTestFailure));
74
- else
75
- console.log(" PASS");
76
- });
61
+ }
62
+ // Also run individual slots, just for example purposes:
63
+ console.log("\nRunning single tests...");
64
+ let slot = qt.qtTestExecutables[1].slots[0];
65
+ await slot.runTest();
66
+ if (slot.lastTestFailure) {
67
+ console.log(" FAIL:" + JSON.stringify(slot.lastTestFailure));
68
+ }
69
+ else {
70
+ console.log(" PASS:");
71
+ }
72
+ let slot2 = qt.qtTestExecutables[1].slots[2];
73
+ await slot2.runTest();
74
+ if (slot2.lastTestFailure) {
75
+ console.log(" FAIL:" + JSON.stringify(slot2.lastTestFailure));
76
+ }
77
+ else {
78
+ console.log(" PASS");
79
+ }
77
80
  }
78
81
  example();
package/out/index.js CHANGED
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const cmake_1 = require("./cmake");
7
7
  const qttest_1 = require("./qttest");
8
8
  const qttest = {
9
- QtTests: qttest_1.QtTests, QtTest: qttest_1.QtTest, QtTestSlot: qttest_1.QtTestSlot, CMakeTests: cmake_1.CMakeTests, CMakeTest: cmake_1.CMakeTest
9
+ QtTests: qttest_1.QtTests,
10
+ QtTest: qttest_1.QtTest,
11
+ QtTestSlot: qttest_1.QtTestSlot,
12
+ CMakeTests: cmake_1.CMakeTests,
13
+ CMakeTest: cmake_1.CMakeTest,
10
14
  };
11
15
  exports.default = qttest;
package/out/qttest.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare class QtTest {
10
10
  verbose: boolean;
11
11
  vscodeTestItem: any | undefined;
12
12
  slots: QtTestSlot[] | null;
13
+ environment: string[];
13
14
  lastExitCode: number;
14
15
  outputFunc: LoggerFunction | undefined;
15
16
  constructor(filename: string, buildDirPath: string);
@@ -17,6 +18,7 @@ export declare class QtTest {
17
18
  get label(): string;
18
19
  relativeFilename(): string;
19
20
  filenameWithoutExtension(): string;
21
+ private buildSpawnEnv;
20
22
  /**
21
23
  * Calls "./yourqttest -functions" and stores the results in the slots property.
22
24
  */