Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ jobs:
- attach_workspace: *attach_options
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ng-snapshots

e2e-cli-ivy-snapshots:
<<: *defaults
environment:
BASH_ENV: ~/.profile
resource_class: xlarge
parallelism: 4
steps:
- attach_workspace: *attach_options
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ng-snapshots --ivy

build:
<<: *defaults
steps:
Expand Down Expand Up @@ -200,6 +210,12 @@ workflows:
filters:
branches:
only: master
- e2e-cli-ivy-snapshots:
requires:
- build
filters:
branches:
only: master
- snapshot_publish:
requires:
- test
Expand Down
45 changes: 12 additions & 33 deletions tests/legacy-cli/e2e/setup/500-create-project.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import {join} from 'path';
import {git, ng, silentNpm} from '../utils/process';
import { expectFileToExist, writeFile } from '../utils/fs';
import {
useSha,
useNgVersion,
useCIChrome,
useCIDefaults,
useBuiltPackages,
useDevKit,
useDevKitSnapshots,
updateJsonFile,
} from '../utils/project';
import {gitClean, gitCommit} from '../utils/git';
import {ng} from '../utils/process';
import {expectFileToExist} from '../utils/fs';
import {prepareProjectForE2e} from '../utils/project';
import {gitClean} from '../utils/git';
import {getGlobalVariable} from '../utils/env';


export default async function() {
const argv = getGlobalVariable('argv');
const extraArgs = [];

if (argv['ivy']) {
extraArgs.push('--experimentalIvy');
}

if (argv.noproject) {
return;
Expand All @@ -26,28 +22,11 @@ export default async function() {
process.chdir(argv.reuse);
await gitClean();
} else {
await ng('new', 'test-project', '--skip-install');
await ng('new', 'test-project', '--skip-install', ...extraArgs);
await expectFileToExist(join(process.cwd(), 'test-project'));
process.chdir('./test-project');
}

return Promise.resolve()
.then(() => useBuiltPackages())
.then(() => argv.devkit ? useDevKit(argv.devkit) : useDevKitSnapshots())
.then(() => useCIChrome('e2e'))
.then(() => useCIChrome('src'))
.then(() => argv['ng-version'] ? useNgVersion(argv['ng-version']) : Promise.resolve())
.then(() => argv['ng-snapshots'] || argv['ng-tag'] ? useSha() : Promise.resolve())
// npm link on Circle CI is very noisy.
.then(() => silentNpm('install'))
.then(() => ng('version'))
// Force sourcemaps to be from the root of the filesystem.
.then(() => updateJsonFile('tsconfig.json', json => {
json['compilerOptions']['sourceRoot'] = '/';
}))
.then(() => git('config', 'user.email', 'angular-core+e2e@google.com'))
.then(() => git('config', 'user.name', 'Angular CLI E2e'))
.then(() => git('config', 'commit.gpgSign', 'false'))
.then(() => useCIDefaults())
.then(() => gitCommit('tsconfig-e2e-update'));
await prepareProjectForE2e('test-project');
await ng('version');
}
3 changes: 2 additions & 1 deletion tests/legacy-cli/e2e/tests/build/build-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export default function () {
.then(() => expectToFail(() => ng('build', '--aot')))
.then(({ message }) => {
if (!message.includes('Function calls are not supported')
&& !message.includes('Function expressions are not supported in decorators')) {
&& !message.includes('Function expressions are not supported in decorators')
&& !message.includes('selector must be a string')) {
throw new Error(`Expected static analysis error, got this instead:\n${message}`);
}
if (extraErrors.some((e) => message.includes(e))) {
Expand Down
51 changes: 35 additions & 16 deletions tests/legacy-cli/e2e/utils/project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as fs from 'fs-extra';
import { readFile, writeFile, replaceInFile, prependToFile } from './fs';
import { execAndWaitForOutputToMatch, npm, silentNpm, ng } from './process';
import { execAndWaitForOutputToMatch, npm, silentNpm, ng, git } from './process';
import { getGlobalVariable } from './env';
import { gitCommit } from './git';

const packages = require('../../../../lib/packages').packages;

Expand Down Expand Up @@ -32,23 +33,41 @@ export function ngServe(...args: string[]) {
}


export function createProject(name: string, ...args: string[]) {
export async function createProject(name: string, ...args: string[]) {
const argv: any = getGlobalVariable('argv');
const extraArgs = [];

return Promise.resolve()
.then(() => process.chdir(getGlobalVariable('tmp-root')))
.then(() => ng('new', name, '--skip-install', ...args))
.then(() => process.chdir(name))
.then(() => useBuiltPackages())
.then(() => useCIChrome('e2e'))
.then(() => useCIChrome('src'))
.then(() => useDevKitSnapshots())
.then(() => argv['ng2'] ? useNg2() : Promise.resolve())
.then(() => argv['ng4'] ? useNg4() : Promise.resolve())
.then(() => argv['ng-snapshots'] || argv['ng-tag'] ? useSha() : Promise.resolve())
.then(() => console.log(`Project ${name} created... Installing npm.`))
.then(() => silentNpm('install'))
.then(() => useCIDefaults(name));
if (argv['ivy']) {
extraArgs.push('--experimentalIvy');
}

process.chdir(getGlobalVariable('tmp-root'));
await ng('new', name, '--skip-install', ...extraArgs, ...args);
process.chdir(name);
await prepareProjectForE2e(name);
}

export async function prepareProjectForE2e(name) {
const argv: any = getGlobalVariable('argv');

await git('config', 'user.email', 'angular-core+e2e@google.com');
await git('config', 'user.name', 'Angular CLI E2e');
await git('config', 'commit.gpgSign', 'false');
await useBuiltPackages();
await useCIChrome('e2e');
await useCIChrome('src');
await useDevKitSnapshots();
await argv['ng2'] ? useNg2() : Promise.resolve();
await argv['ng4'] ? useNg4() : Promise.resolve();
await argv['ng-snapshots'] || argv['ng-tag'] ? useSha() : Promise.resolve();
await console.log(`Project ${name} created... Installing npm.`);
await silentNpm('install');
await useCIDefaults(name);
// Force sourcemaps to be from the root of the filesystem.
await updateJsonFile('tsconfig.json', json => {
json['compilerOptions']['sourceRoot'] = '/';
});
await gitCommit('prepare-project-for-e2e');
}


Expand Down
29 changes: 25 additions & 4 deletions tests/legacy-cli/e2e_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Error.stackTraceLimit = Infinity;
* --ng-tag=TAG Use a specific tag for build snapshots. Similar to ng-snapshots but point to a
* tag of using the latest master.
* --ng-snapshots Install angular snapshot builds in the test project.
* --ivy Use the Ivy compiler.
* --glob Run tests matching this glob pattern (relative to tests/e2e/).
* --ignore Ignore tests matching this glob pattern.
* --reuse=/path Use a path instead of create a new project. That project should have been
Expand All @@ -51,6 +52,7 @@ const argv = minimist(process.argv.slice(2), {
'nosilent',
'noproject',
'verbose',
'ivy',
],
'string': ['devkit', 'glob', 'ignore', 'reuse', 'ng-tag', 'tmpdir', 'ng-version'],
'number': ['nb-shards', 'shard'],
Expand Down Expand Up @@ -108,11 +110,14 @@ const e2eRoot = path.join(__dirname, 'e2e');
const allSetups = glob.sync(path.join(e2eRoot, 'setup/**/*.ts'), { nodir: true })
.map(name => path.relative(e2eRoot, name))
.sort();
const allTests = glob.sync(path.join(e2eRoot, testGlob), { nodir: true, ignore: argv.ignore })
let allTests = glob.sync(path.join(e2eRoot, testGlob), { nodir: true, ignore: argv.ignore })
.map(name => path.relative(e2eRoot, name))
// TODO: UPDATE TESTS
// Replace windows slashes.
.map(name => name.replace(/\\/g, '/'))
.sort();

// TODO: either update or remove these tests.
allTests = allTests
.filter(name => !name.endsWith('/build-app-shell-with-schematic.ts'))
// IS this test still valid? \/
.filter(name => !name.endsWith('/module-id.ts'))
Expand All @@ -125,8 +130,24 @@ const allTests = glob.sync(path.join(e2eRoot, testGlob), { nodir: true, ignore:
// NEEDS devkit change
.filter(name => !name.endsWith('/existing-directory.ts'))
// Disabled on rc.0 due to needed sync with devkit for changes.
.filter(name => !name.endsWith('/service-worker.ts'))
.sort();
.filter(name => !name.endsWith('/service-worker.ts'));

if (argv.ivy) {
// These tests are disabled on the Ivy-only CI job because:
// - Ivy doesn't support the functionality yet
// - The test itself is not applicable to Ivy
// As we transition into using Ivy as the default this list should be reassessed.
allTests = allTests
// The basic AOT check is different with Ivy and being checked in /experimental/ivy.ts.
.filter(name => !name.endsWith('tests/basic/aot.ts'))
// Ivy doesn't support i18n externally at the moment.
.filter(name => !name.includes('tests/i18n/'))
.filter(name => !name.endsWith('tests/build/aot/aot-i18n.ts'))
// Lazy load support is WIP https://github.com/angular/angular-cli/pull/13524
.filter(name => !name.endsWith('tests/misc/lazy-module.ts'))
// We don't have a library consumption story yet for Ivy.
.filter(name => !name.endsWith('tests/generate/library/library-consumption.ts'));
}

const shardId = ('shard' in argv) ? argv['shard'] : null;
const nbShards = (shardId === null ? 1 : argv['nb-shards']) || 2;
Expand Down