@iamsergio/qttest-utils 2.0.0 → 2.1.1

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 CHANGED
@@ -26,10 +26,9 @@ cargo install git-cliff
26
26
  ## Releasing
27
27
 
28
28
  (Replace 1.0.0 with actual version used)
29
-
30
- export NEW_VERSION=v1.0.0
29
+ - Get a version compatible with semver, run ` git cliff --bump | head -n 5`, replace NEW_VERSION
30
+ - export NEW_VERSION=v1.0.0
31
31
  - Make sure Github Actions CI is green
32
- - Optional: To get a version compatible with semver, run `git cliff --bump`
33
- - Increase version in package.json and package-lock.json.
32
+ - npm version $NEW_VERSION # ignore the error
34
33
  - git cliff --tag $NEW_VERSION > Changelog
35
34
  - 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,12 +2,44 @@
2
2
 
3
3
 
4
4
 
5
+ ## [2.1.1] - 2024-04-25
6
+
7
+ ### 🐛 Bug Fixes
8
+
9
+ - Allow for backslashes in the cmake codemodel
10
+
11
+ ### ⚙️ Miscellaneous Tasks
12
+
13
+ - Improve CONTRIBUTING.md
14
+
15
+ ## [2.1.0] - 2024-04-25
16
+
17
+ ### 🚀 Features
18
+
19
+ - Add targetNameForExecutable()
20
+
21
+ ### 🐛 Bug Fixes
22
+
23
+ - Ignore non-executable targets
24
+
25
+ ### ⚙️ Miscellaneous Tasks
26
+
27
+ - Coding style improvement
28
+ - Update CONTRIBUTING.md file
29
+ - Fix build on macOS
30
+ - Improve CONTRIBUTING.md
31
+ - Bump version
32
+
5
33
  ## [2.0.0] - 2024-04-24
6
34
 
7
35
  ### 🚀 Features
8
36
 
9
37
  - [**breaking**] Use a member to hold the output function
10
38
 
39
+ ### ⚙️ Miscellaneous Tasks
40
+
41
+ - Bump version
42
+
11
43
  ## [1.4.0] - 2024-04-24
12
44
 
13
45
  ### 🚀 Features
package/out/cmake.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare class CMakeTests {
13
13
  */
14
14
  tests(): Promise<CMakeTest[] | undefined>;
15
15
  private ctestJsonToList;
16
+ targetNameForExecutable(executable: string, codemodel: any): string | undefined;
16
17
  cppFilesForExecutable(executable: string, codemodel: any): string[];
17
18
  }
18
19
  export declare class CMakeTest {
package/out/cmake.js CHANGED
@@ -72,45 +72,85 @@ 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
75
+ /// Returns the cmake target name for the specified executable
76
+ /// codemodel should have a "projects" key at root.
77
+ targetNameForExecutable(executable, codemodel) {
78
+ // simplify:
79
+ if (executable.endsWith(".exe")) {
80
+ executable = executable.substring(0, executable.length - 4);
81
+ }
82
+ // replace backslashes with forward slashes
83
+ executable = executable.replace(/\\/g, "/");
84
+ let projects = codemodel["projects"];
85
+ if (!projects)
86
+ return undefined;
87
+ for (let project of projects) {
88
+ let targets = project["targets"];
89
+ if (!targets)
90
+ continue;
91
+ for (let target of targets) {
92
+ let artifacts = target["artifacts"];
93
+ if (!artifacts)
94
+ continue;
95
+ for (let artifact of artifacts) {
96
+ if (artifact.endsWith(".exe")) {
97
+ artifact = artifact.substring(0, artifact.length - 4);
98
+ }
99
+ // replace backslashes with forward slashes
100
+ artifact = artifact.replace(/\\/g, "/");
101
+ if (artifact == executable) {
102
+ let name = target["name"];
103
+ if (name) {
104
+ // We found the target name
105
+ return name;
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ return undefined;
112
+ }
113
+ /// Returns the list of .cpp files for the specified executable
114
+ /// codemodel is the CMake codemodel JSON object
115
+ /// codemodel should have a "projects" key at root.
77
116
  cppFilesForExecutable(executable, codemodel) {
78
117
  // simplify:
79
118
  if (executable.endsWith(".exe")) {
80
119
  executable = executable.substring(0, executable.length - 4);
81
120
  }
121
+ // replace backslashes with forward slashes
122
+ executable = executable.replace(/\\/g, "/");
82
123
  let projects = codemodel["projects"];
83
- if (!projects) {
124
+ if (!projects)
84
125
  return [];
85
- }
86
126
  for (let project of projects) {
87
127
  let targets = project["targets"];
88
- if (!targets) {
128
+ if (!targets)
89
129
  continue;
90
- }
91
130
  for (let target of targets) {
92
131
  let sourceDir = target["sourceDirectory"];
93
132
  let artifacts = target["artifacts"];
94
- if (!artifacts || !sourceDir) {
133
+ if (!artifacts || !sourceDir)
134
+ continue;
135
+ let targetType = target["type"];
136
+ if (targetType != "EXECUTABLE")
95
137
  continue;
96
- }
97
138
  for (let artifact of artifacts) {
98
139
  if (artifact.endsWith(".exe")) {
99
140
  artifact = artifact.substring(0, artifact.length - 4);
100
141
  }
142
+ // replace backslashes with forward slashes
143
+ artifact = artifact.replace(/\\/g, "/");
101
144
  if (artifact == executable) {
102
145
  let fileGroups = target["fileGroups"];
103
- if (!fileGroups) {
146
+ if (!fileGroups)
104
147
  continue;
105
- }
106
148
  for (let fileGroup of fileGroups) {
107
- if (fileGroup["language"] != "CXX" || fileGroup["isGenerated"]) {
149
+ if (fileGroup["language"] != "CXX" || fileGroup["isGenerated"])
108
150
  continue;
109
- }
110
151
  let sources = fileGroup["sources"];
111
- if (!sources) {
152
+ if (!sources)
112
153
  continue;
113
- }
114
154
  let cppFiles = [];
115
155
  for (let source of sources) {
116
156
  if (!source.endsWith("mocs_compilation.cpp")) {
package/out/test.js CHANGED
@@ -127,6 +127,22 @@ function runCodeModelTests(codeModelFile) {
127
127
  console.error("Expected " + expected + ", got " + got);
128
128
  process.exit(1);
129
129
  }
130
+ let targetName = cmake.targetNameForExecutable("/vscode-qttest/test/qt_test/build-dev/test1", codemodelJson);
131
+ if (targetName != "test1") {
132
+ console.error("Expected test1, got " + targetName);
133
+ process.exit(1);
134
+ }
135
+ // test windows back slashes:
136
+ files = cmake.cppFilesForExecutable("/vscode-qttest/test/qt_test/build-dev/test2", codemodelJson);
137
+ if (files.length != 1) {
138
+ console.error("Expected 1 file, got " + files.length);
139
+ process.exit(1);
140
+ }
141
+ targetName = cmake.targetNameForExecutable("/vscode-qttest/test/qt_test/build-dev/test2", codemodelJson);
142
+ if (targetName != "test2") {
143
+ console.error("Expected test2, got " + targetName);
144
+ process.exit(1);
145
+ }
130
146
  });
131
147
  }
132
148
  runTests("test/qt_test/build-dev/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamsergio/qttest-utils",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
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",