Skip to content

Commit a5c5545

Browse files
committed
ci: fix component-child-dir E2E test on Windows CI
Windows CI is failing when trying to use the common test cleanup routine for the `generate/component/component-child-dir` E2E test. This fix manually removes the newly created directory within the test. (cherry picked from commit 5c3d9cd)
1 parent daa6981 commit a5c5545

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed
Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
import {join} from 'path';
2-
import {ng} from '../../../utils/process';
3-
import {createDir, expectFileToExist} from '../../../utils/fs';
1+
import { join } from 'path';
2+
import { ng } from '../../../utils/process';
3+
import { createDir, expectFileToExist, rimraf } from '../../../utils/fs';
44

5+
export default async function () {
6+
const currentDirectory = process.cwd();
7+
const childDirectory = join('src', 'app', 'sub-dir');
58

6-
export default function() {
7-
const subDir = 'sub-dir';
8-
const componentDir = join('src', 'app', subDir, 'test-component');
9+
try {
10+
// Create and enter a child directory inside the project
11+
await createDir(childDirectory);
12+
process.chdir(childDirectory);
913

10-
return Promise.resolve()
11-
.then(() => process.chdir('src'))
12-
.then(() => process.chdir('app'))
13-
.then(() => createDir(subDir))
14-
.then(() => process.chdir(subDir))
15-
.then(() => ng('generate', 'component', 'test-component'))
16-
.then(() => process.chdir('../../..'))
17-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.ts')))
18-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.spec.ts')))
19-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.html')))
20-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))
14+
// Generate a component inside the child directory
15+
await ng('generate', 'component', 'test-component');
2116

22-
// Try to run the unit tests.
23-
.then(() => ng('test', '--watch=false'));
17+
// Move back to the root of the workspacee
18+
process.chdir(currentDirectory);
19+
20+
// Ensure component is created in the correct location relative to the workspace root
21+
const componentDirectory = join(childDirectory, 'test-component');
22+
await expectFileToExist(join(componentDirectory, 'test-component.component.ts'));
23+
await expectFileToExist(join(componentDirectory, 'test-component.component.spec.ts'));
24+
await expectFileToExist(join(componentDirectory, 'test-component.component.html'));
25+
await expectFileToExist(join(componentDirectory, 'test-component.component.css'));
26+
27+
// Ensure unit test execute and pass
28+
await ng('test', '--watch=false');
29+
} finally {
30+
// Windows CI may fail to clean up the created directory
31+
// Resolves: "Error: Running "cmd.exe /c git clean -df" returned error code 1"
32+
await rimraf(childDirectory);
33+
}
2434
}

0 commit comments

Comments
 (0)