Skip to content

Commit 3f7691e

Browse files
alan-agius4vikerman
authored andcommitted
test: verify that link in outputpath is not deleted at source
Closes: #15183
1 parent db08558 commit 3f7691e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

packages/angular_devkit/build_angular/test/browser/output-path_spec_large.ts

+31-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { Architect } from '@angular-devkit/architect';
1010
import { getSystemPath, join, virtualFs } from '@angular-devkit/core';
11+
import * as fs from 'fs';
1112
import { browserBuild, createArchitect, host } from '../utils';
1213

1314

@@ -39,13 +40,42 @@ describe('Browser Builder output path', () => {
3940
await run.stop();
4041
});
4142

43+
it('deletes output path and unlink symbolic link', async () => {
44+
// Write a file to the output path to later verify it was deleted.
45+
host.writeMultipleFiles({
46+
'src-link/dummy.txt': '',
47+
'dist/file.txt': virtualFs.stringToFileBuffer('file'),
48+
});
49+
50+
const distLinked = join(host.root(), 'dist', 'linked');
51+
52+
// create symbolic link
53+
fs.symlinkSync(
54+
getSystemPath(join(host.root(), 'src-link')),
55+
getSystemPath(distLinked),
56+
'junction',
57+
);
58+
59+
expect(await host.exists(distLinked).toPromise()).toBe(true);
60+
61+
// Delete an app file to force a failed compilation.
62+
// Failed compilations still delete files, but don't output any.
63+
await host.delete(join(host.root(), 'src', 'app', 'app.component.ts')).toPromise();
64+
const run = await architect.scheduleTarget(target);
65+
const output = await run.result;
66+
expect(output.success).toBe(false);
67+
68+
expect(await host.exists(join(host.root(), 'dist')).toPromise()).toBe(false);
69+
expect(await host.exists(join(host.root(), 'src-link')).toPromise()).toBe(true);
70+
});
71+
4272
it('does not allow output path to be project root', async () => {
4373
const overrides = { outputPath: './' };
4474
const run = await architect.scheduleTarget(target, overrides);
4575
try {
4676
await run.result;
4777
expect('THE ABOVE LINE SHOULD THROW').toBe('');
48-
} catch {}
78+
} catch { }
4979
await run.stop();
5080
});
5181

0 commit comments

Comments
 (0)