Skip to content

test: verify that link in outputpath is not deleted at source #16066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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


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

it('deletes output path and unlink symbolic link', async () => {
// Write a file to the output path to later verify it was deleted.
host.writeMultipleFiles({
'src-link/dummy.txt': '',
'dist/file.txt': virtualFs.stringToFileBuffer('file'),
});

const distLinked = join(host.root(), 'dist', 'linked');

// create symbolic link
fs.symlinkSync(
getSystemPath(join(host.root(), 'src-link')),
getSystemPath(distLinked),
'junction',
);

expect(await host.exists(distLinked).toPromise()).toBe(true);

// Delete an app file to force a failed compilation.
// Failed compilations still delete files, but don't output any.
await host.delete(join(host.root(), 'src', 'app', 'app.component.ts')).toPromise();
const run = await architect.scheduleTarget(target);
const output = await run.result;
expect(output.success).toBe(false);

expect(await host.exists(join(host.root(), 'dist')).toPromise()).toBe(false);
expect(await host.exists(join(host.root(), 'src-link')).toPromise()).toBe(true);
});

it('does not allow output path to be project root', async () => {
const overrides = { outputPath: './' };
const run = await architect.scheduleTarget(target, overrides);
try {
await run.result;
expect('THE ABOVE LINE SHOULD THROW').toBe('');
} catch {}
} catch { }
await run.stop();
});

Expand Down