Skip to content

Commit 1b5e920

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@angular-devkit/build-angular): handle codeCoverageExclude correctly in Windows
Previously, `codeCoverageExclude` didn't work correct on Windows Closes #23403 (cherry picked from commit 0f02b00)
1 parent 060f56d commit 1b5e920

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

packages/angular_devkit/build_angular/src/webpack/utils/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ export function getInstrumentationExcludedPaths(
126126

127127
for (const excludeGlob of excludedPaths) {
128128
glob
129-
.sync(path.join(sourceRoot, excludeGlob), { nodir: true })
130-
.forEach((p) => excluded.add(path.normalize(p)));
129+
.sync(excludeGlob, { nodir: true, cwd: sourceRoot })
130+
.forEach((p) => excluded.add(path.join(sourceRoot, p)));
131131
}
132132

133133
return excluded;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expectFileToExist, rimraf } from '../../utils/fs';
2+
import { silentNg } from '../../utils/process';
3+
import { expectToFail } from '../../utils/utils';
4+
5+
export default async function () {
6+
// This test is already in build-angular, but that doesn't run on Windows.
7+
await silentNg('test', '--no-watch', '--code-coverage');
8+
await expectFileToExist('coverage/test-project/app.component.ts.html');
9+
// Delete coverage directory
10+
await rimraf('coverage');
11+
12+
await silentNg(
13+
'test',
14+
'--no-watch',
15+
'--code-coverage',
16+
`--code-coverage-exclude='src/**/app.component.ts'`,
17+
);
18+
19+
// Doesn't include excluded.
20+
await expectFileToExist('coverage/test-project/index.html');
21+
await expectToFail(() => expectFileToExist('coverage/test-project/app.component.ts.html'));
22+
}

0 commit comments

Comments
 (0)