Commit 683d0e0
fix(@angular/build): correctly handle absolute paths and casing in test discovery
The `findTests` function's path normalization logic had two flaws that affected cross-platform compatibility and user experience:
1. Absolute paths provided in the `include` patterns were incorrectly processed. The leading slash was removed, causing the globber to fail to find the specified test files.
2. The prefix removal logic was case-sensitive, which would fail to normalize workspace-relative paths on case-insensitive filesystems (like Windows and macOS) if the user's input casing for the project path differed from the actual directory casing.
This commit corrects both issues:
- The `normalizePattern` function now uses `isAbsolute` to detect and preserve absolute paths, ensuring they are passed to the globber unmodified.
- The `removePrefix` helper function is now conditionally case-insensitive based on the host operating system (`win32`, `darwin`), aligning its behavior with the underlying filesystem and making path normalization more robust.
- Minor code style refactoring and JSDoc comments have been added for clarity.1 parent 9efcb03 commit 683d0e0
File tree
2 files changed
+62
-18
lines changed- packages/angular/build/src/builders
- karma
- unit-test
2 files changed
+62
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 40 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
164 | 165 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
169 | 187 | | |
170 | 188 | | |
171 | 189 | | |
| |||
177 | 195 | | |
178 | 196 | | |
179 | 197 | | |
180 | | - | |
181 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
182 | 202 | | |
183 | 203 | | |
184 | 204 | | |
| |||
194 | 214 | | |
195 | 215 | | |
196 | 216 | | |
197 | | - | |
198 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
199 | 223 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
204 | 227 | | |
205 | | - | |
| 228 | + | |
206 | 229 | | |
207 | 230 | | |
208 | 231 | | |
| |||
0 commit comments