@iamsergio/qttest-utils 2.1.0 → 2.2.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 CHANGED
@@ -29,6 +29,6 @@ cargo install git-cliff
29
29
  - Get a version compatible with semver, run ` git cliff --bump | head -n 5`, replace NEW_VERSION
30
30
  - export NEW_VERSION=v1.0.0
31
31
  - Make sure Github Actions CI is green
32
- - npm version $NEW_VERSION
32
+ - npm version $NEW_VERSION # ignore the error
33
33
  - git cliff --tag $NEW_VERSION > Changelog
34
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,6 +2,23 @@
2
2
 
3
3
 
4
4
 
5
+ ## [2.2.0] - 2024-04-25
6
+
7
+ ### 🚀 Features
8
+
9
+ - Allow to workaround microsoft/vscode-cmake-tools-api/issues/7
10
+
11
+ ## [2.1.1] - 2024-04-25
12
+
13
+ ### 🐛 Bug Fixes
14
+
15
+ - Allow for backslashes in the cmake codemodel
16
+
17
+ ### ⚙️ Miscellaneous Tasks
18
+
19
+ - Improve CONTRIBUTING.md
20
+ - Bump version
21
+
5
22
  ## [2.1.0] - 2024-04-25
6
23
 
7
24
  ### 🚀 Features
@@ -18,6 +35,7 @@
18
35
  - Update CONTRIBUTING.md file
19
36
  - Fix build on macOS
20
37
  - Improve CONTRIBUTING.md
38
+ - Bump version
21
39
 
22
40
  ## [2.0.0] - 2024-04-24
23
41
 
package/out/cmake.d.ts CHANGED
@@ -13,8 +13,9 @@ export declare class CMakeTests {
13
13
  */
14
14
  tests(): Promise<CMakeTest[] | undefined>;
15
15
  private ctestJsonToList;
16
- targetNameForExecutable(executable: string, codemodel: any): string | undefined;
17
- cppFilesForExecutable(executable: string, codemodel: any): string[];
16
+ targetNameForExecutable(executable: string, codemodel: any, workaround?: boolean): string | undefined;
17
+ filenamesAreEqual(file1: string, file2: string, workaround?: boolean): boolean;
18
+ cppFilesForExecutable(executable: string, codemodel: any, workaround?: boolean): string[];
18
19
  }
19
20
  export declare class CMakeTest {
20
21
  command: string[];
package/out/cmake.js CHANGED
@@ -73,11 +73,8 @@ class CMakeTests {
73
73
  return tests;
74
74
  }
75
75
  /// Returns the cmake target name for the specified executable
76
- targetNameForExecutable(executable, codemodel) {
77
- // simplify:
78
- if (executable.endsWith(".exe")) {
79
- executable = executable.substring(0, executable.length - 4);
80
- }
76
+ /// codemodel should have a "projects" key at root.
77
+ targetNameForExecutable(executable, codemodel, workaround = false) {
81
78
  let projects = codemodel["projects"];
82
79
  if (!projects)
83
80
  return undefined;
@@ -93,7 +90,7 @@ class CMakeTests {
93
90
  if (artifact.endsWith(".exe")) {
94
91
  artifact = artifact.substring(0, artifact.length - 4);
95
92
  }
96
- if (artifact == executable) {
93
+ if (this.filenamesAreEqual(executable, artifact, workaround)) {
97
94
  let name = target["name"];
98
95
  if (name) {
99
96
  // We found the target name
@@ -105,13 +102,39 @@ class CMakeTests {
105
102
  }
106
103
  return undefined;
107
104
  }
108
- // Returns the list of .cpp files for the specified executable
109
- // codemodel is the CMake codemodel JSON object
110
- cppFilesForExecutable(executable, codemodel) {
111
- // simplify:
112
- if (executable.endsWith(".exe")) {
113
- executable = executable.substring(0, executable.length - 4);
105
+ /// Returns whether the two filenames are equal
106
+ /// If workaround is true, then we workaround microsoft/vscode-cmake-tools-api/issues/7 where
107
+ /// the basename is correct but the path is bogus, and we only compare the basenames
108
+ filenamesAreEqual(file1, file2, workaround = false) {
109
+ if (file1.endsWith(".exe"))
110
+ file1 = file1.substring(0, file1.length - 4);
111
+ if (file2.endsWith(".exe"))
112
+ file2 = file2.substring(0, file2.length - 4);
113
+ file1 = file1.replace(/\\/g, "/");
114
+ file2 = file2.replace(/\\/g, "/");
115
+ if (process.platform === "win32") {
116
+ file1 = file1.toLowerCase();
117
+ file2 = file2.toLowerCase();
118
+ }
119
+ if (file1 == file2)
120
+ return true;
121
+ if (!workaround) {
122
+ // files aren't equal!
123
+ return false;
114
124
  }
125
+ const fs = require('fs');
126
+ if (fs.existsSync(file2)) {
127
+ // It's a real file, not bogus.
128
+ return false;
129
+ }
130
+ /// Compare only basename, since path is bogus
131
+ return path_1.default.basename(file1, ".exe") == path_1.default.basename(file2, ".exe");
132
+ }
133
+ /// Returns the list of .cpp files for the specified executable
134
+ /// codemodel is the CMake codemodel JSON object
135
+ /// codemodel should have a "projects" key at root.
136
+ /// @param workaround If true, worksaround https://github.com/microsoft/vscode-cmake-tools-api/issues/7
137
+ cppFilesForExecutable(executable, codemodel, workaround = false) {
115
138
  let projects = codemodel["projects"];
116
139
  if (!projects)
117
140
  return [];
@@ -131,7 +154,9 @@ class CMakeTests {
131
154
  if (artifact.endsWith(".exe")) {
132
155
  artifact = artifact.substring(0, artifact.length - 4);
133
156
  }
134
- if (artifact == executable) {
157
+ // replace backslashes with forward slashes
158
+ artifact = artifact.replace(/\\/g, "/");
159
+ if (this.filenamesAreEqual(executable, artifact, workaround)) {
135
160
  let fileGroups = target["fileGroups"];
136
161
  if (!fileGroups)
137
162
  continue;
package/out/test.js CHANGED
@@ -132,6 +132,38 @@ function runCodeModelTests(codeModelFile) {
132
132
  console.error("Expected test1, got " + targetName);
133
133
  process.exit(1);
134
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
+ }
146
+ // test workaround for microsoft/vscode-cmake-tools-api/issues/7
147
+ files = cmake.cppFilesForExecutable("/vscode-qttest/test/qt_test/build-dev/test3", codemodelJson, /*workaround=*/ false);
148
+ if (files.length !== 0) {
149
+ console.error("Expected 0 files, got " + files.length);
150
+ process.exit(1);
151
+ }
152
+ files = cmake.cppFilesForExecutable("/vscode-qttest/test/qt_test/build-dev/test3", codemodelJson, /*workaround=*/ true);
153
+ if (files.length !== 1) {
154
+ console.error("Expected 0 files, got " + files.length);
155
+ process.exit(1);
156
+ }
157
+ targetName = cmake.targetNameForExecutable("/vscode-qttest/test/qt_test/build-dev/test3", codemodelJson, /*workaround=*/ false);
158
+ if (targetName) {
159
+ console.error("Expected null, got " + targetName);
160
+ process.exit(1);
161
+ }
162
+ targetName = cmake.targetNameForExecutable("/vscode-qttest/test/qt_test/build-dev/test3", codemodelJson, /*workaround=*/ true);
163
+ if (targetName != "test3") {
164
+ console.error("Expected null, got " + targetName);
165
+ process.exit(1);
166
+ }
135
167
  });
136
168
  }
137
169
  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.1.0",
3
+ "version": "2.2.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",