From 8499aedf92f62637b9e792f9e0aed0e417b8c4ea Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Mon, 6 Jun 2016 15:38:06 -0400 Subject: [PATCH 01/30] fix(e2e): return exit codes on failure of e2e tests --- addon/ng2/tasks/e2e.ts | 4 +- tests/acceptance/e2e.spec.js | 101 +++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 tests/acceptance/e2e.spec.js diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 3d377db6ba80..fea4af5738d3 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -6,6 +6,7 @@ import {exec} from 'child_process'; module.exports = Task.extend({ run: function () { var ui = this.ui; + var exitCode = 0; return new Promise((resolve) => { exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => { @@ -13,10 +14,11 @@ module.exports = Task.extend({ if (err) { ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); + exitCode = err.code; } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); } - resolve(); + resolve(exitCode); }); }); } diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js new file mode 100644 index 000000000000..cbca49157553 --- /dev/null +++ b/tests/acceptance/e2e.spec.js @@ -0,0 +1,101 @@ +'use strict'; + +var ng = require('../helpers/ng'); +var path = require('path'); +var tmp = require('../helpers/tmp'); +var conf = require('ember-cli/tests/helpers/conf'); +var child_process = require('child_process'); +var treeKill = require('tree-kill'); + +const ngBin = `node ${path.join(process.cwd(), 'bin', 'ng')}`; + +describe('Acceptance: ng e2e', function () { + before(conf.setup); + + after(conf.restore); + + beforeEach(function () { + this.timeout(4200000); + + return tmp.setup('./tmp').then(function () { + process.chdir('./tmp'); + }); + }); + + it('ng e2e completes successfully after serving project', function () { + this.timeout(240000); + + var ngServePid; + var ngE2ePid; + var e2eProcess; + + function executor(resolve, reject) { + var serveProcess = child_process.exec(`${ngBin} serve`); + var startedProtractor = false; + ngServePid = serveProcess.pid; + + serveProcess.stdout.on('data', (data) => { + if (/Build successful/.test(data) && !startedProtractor) { + startedProtractor = true; + child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { + if (error !== null) { + reject(stderr) + } else { + resolve(); + } + }); + } else if (/ failed with:/.test(data)) { + reject(data); + } + }); + + serveProcess.stderr.on('data', (data) => { + reject(data); + }); + serveProcess.on('close', (code) => { + code === 0 ? resolve() : reject('ng serve command closed with error') + }); + } + + return ng(['new', 'foo', '--link-cli=true']) + .then(new Promise(executor) + .then(() => { + if (ngServePid) treeKill(ngServePid); + if (ngE2ePid) treeKill(ngE2ePid); + }) + .catch((msg) => { + if (ngServePid) treeKill(ngServePid); + if (ngE2ePid) treeKill(ngE2ePid); + throw new Error(msg); + })); + }); + + it('ng e2e fails with exit code', function () { + this.timeout(240000); + + var ngE2ePid; + var e2eProcess; + + function executor(resolve, reject) { + e2eProcess = child_process.exec(`${ngBin} e2e`); + + e2eProcess.stderr.on('data', (data) => { + reject(data); + }) + + e2eProcess.on('close', (code) => { + code !== 0 ? resolve() : reject('ng e2e command closed with error') + }); + + } + + return new Promise(executor) + .then(() => { + if (ngE2ePid) treeKill(ngE2ePid); + }) + .catch((msg) => { + if (ngE2ePid) treeKill(ngE2ePid); + throw new Error(msg); + }); + }); +}); From 0a5a23504d392f9c120fddd9425b7e76f1981150 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Mon, 6 Jun 2016 15:52:13 -0400 Subject: [PATCH 02/30] style: Remove unused variables in e2e command spec --- tests/acceptance/e2e.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index cbca49157553..92feb4b868db 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -27,7 +27,6 @@ describe('Acceptance: ng e2e', function () { var ngServePid; var ngE2ePid; - var e2eProcess; function executor(resolve, reject) { var serveProcess = child_process.exec(`${ngBin} serve`); From 58746eac2b71f45c0654b1f570bda902b37e8962 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Mon, 6 Jun 2016 18:11:17 -0400 Subject: [PATCH 03/30] fix(e2e): Fixed failing spec test for e2e command --- tests/acceptance/e2e.spec.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index 92feb4b868db..cfde8ab8ed00 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -12,7 +12,12 @@ const ngBin = `node ${path.join(process.cwd(), 'bin', 'ng')}`; describe('Acceptance: ng e2e', function () { before(conf.setup); - after(conf.restore); + after(function() { + this.timeout(4200000); + + conf.restore; + return tmp.teardown('./tmp'); + }); beforeEach(function () { this.timeout(4200000); @@ -56,7 +61,7 @@ describe('Acceptance: ng e2e', function () { }); } - return ng(['new', 'foo', '--link-cli=true']) + return ng(['new', 'test-project']) .then(new Promise(executor) .then(() => { if (ngServePid) treeKill(ngServePid); From 16a8d6a8692de5506547f10271a9a4b4f6aebf0f Mon Sep 17 00:00:00 2001 From: marc-sensenich Date: Mon, 6 Jun 2016 21:39:29 -0400 Subject: [PATCH 04/30] Update .travis.yml --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1483e447d760..3f4de4e1e4b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,9 @@ matrix: exclude: - os: osx env: NODE_VERSION=5 SCRIPT=lint - +branches: + only: + - e2e-exit-code script: - npm run-script $SCRIPT From 1231559c9710b1c63009fa4381bf46e60cf8cf1f Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Mon, 6 Jun 2016 22:02:18 -0400 Subject: [PATCH 05/30] style(e2e): Clean up the spec test Cleaning up the spec test in an attempt to resolve Travis OSX build issues --- tests/acceptance/e2e.spec.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index cfde8ab8ed00..103560d0fcb7 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -41,9 +41,12 @@ describe('Acceptance: ng e2e', function () { serveProcess.stdout.on('data', (data) => { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; - child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { + var e2eProcess = child_process.exec(`${ngBin} e2e`); + ngE2ePid = e2eProcess.pid; + + e2eProcess.then((error, stdout, stderr) => { if (error !== null) { - reject(stderr) + reject(stderr); } else { resolve(); } @@ -64,12 +67,12 @@ describe('Acceptance: ng e2e', function () { return ng(['new', 'test-project']) .then(new Promise(executor) .then(() => { - if (ngServePid) treeKill(ngServePid); - if (ngE2ePid) treeKill(ngE2ePid); + if (ngServePid) { treeKill(ngServePid); } + if (ngE2ePid) { treeKill(ngE2ePid); } }) .catch((msg) => { if (ngServePid) treeKill(ngServePid); - if (ngE2ePid) treeKill(ngE2ePid); + if (ngE2ePid) { treeKill(ngE2ePid); } throw new Error(msg); })); }); @@ -82,6 +85,7 @@ describe('Acceptance: ng e2e', function () { function executor(resolve, reject) { e2eProcess = child_process.exec(`${ngBin} e2e`); + ngE2ePid = e2eProcess.pid; e2eProcess.stderr.on('data', (data) => { reject(data); From 16aafd30e0a1daad04c0d9a3f4d4c388d226ba2c Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Mon, 6 Jun 2016 22:23:08 -0400 Subject: [PATCH 06/30] fix(e2e): Clear e2e spec --- tests/acceptance/e2e.spec.js | 158 ++++++++++++++++----------------- tests/e2e/e2e_workflow.spec.js | 1 + 2 files changed, 80 insertions(+), 79 deletions(-) diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index 103560d0fcb7..e8e97f9ba67b 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -27,83 +27,83 @@ describe('Acceptance: ng e2e', function () { }); }); - it('ng e2e completes successfully after serving project', function () { - this.timeout(240000); - - var ngServePid; - var ngE2ePid; - - function executor(resolve, reject) { - var serveProcess = child_process.exec(`${ngBin} serve`); - var startedProtractor = false; - ngServePid = serveProcess.pid; - - serveProcess.stdout.on('data', (data) => { - if (/Build successful/.test(data) && !startedProtractor) { - startedProtractor = true; - var e2eProcess = child_process.exec(`${ngBin} e2e`); - ngE2ePid = e2eProcess.pid; - - e2eProcess.then((error, stdout, stderr) => { - if (error !== null) { - reject(stderr); - } else { - resolve(); - } - }); - } else if (/ failed with:/.test(data)) { - reject(data); - } - }); - - serveProcess.stderr.on('data', (data) => { - reject(data); - }); - serveProcess.on('close', (code) => { - code === 0 ? resolve() : reject('ng serve command closed with error') - }); - } - - return ng(['new', 'test-project']) - .then(new Promise(executor) - .then(() => { - if (ngServePid) { treeKill(ngServePid); } - if (ngE2ePid) { treeKill(ngE2ePid); } - }) - .catch((msg) => { - if (ngServePid) treeKill(ngServePid); - if (ngE2ePid) { treeKill(ngE2ePid); } - throw new Error(msg); - })); - }); - - it('ng e2e fails with exit code', function () { - this.timeout(240000); - - var ngE2ePid; - var e2eProcess; - - function executor(resolve, reject) { - e2eProcess = child_process.exec(`${ngBin} e2e`); - ngE2ePid = e2eProcess.pid; - - e2eProcess.stderr.on('data', (data) => { - reject(data); - }) - - e2eProcess.on('close', (code) => { - code !== 0 ? resolve() : reject('ng e2e command closed with error') - }); - - } - - return new Promise(executor) - .then(() => { - if (ngE2ePid) treeKill(ngE2ePid); - }) - .catch((msg) => { - if (ngE2ePid) treeKill(ngE2ePid); - throw new Error(msg); - }); - }); + // it('ng e2e completes successfully after serving project', function () { + // this.timeout(240000); + + // var ngServePid; + // var ngE2ePid; + + // function executor(resolve, reject) { + // var serveProcess = child_process.exec(`${ngBin} serve`); + // var startedProtractor = false; + // ngServePid = serveProcess.pid; + + // serveProcess.stdout.on('data', (data) => { + // if (/Build successful/.test(data) && !startedProtractor) { + // startedProtractor = true; + // var e2eProcess = child_process.exec(`${ngBin} e2e`); + // ngE2ePid = e2eProcess.pid; + + // e2eProcess.then((error, stdout, stderr) => { + // if (error !== null) { + // reject(stderr); + // } else { + // resolve(); + // } + // }); + // } else if (/ failed with:/.test(data)) { + // reject(data); + // } + // }); + + // serveProcess.stderr.on('data', (data) => { + // reject(data); + // }); + // serveProcess.on('close', (code) => { + // code === 0 ? resolve() : reject('ng serve command closed with error') + // }); + // } + + // return ng(['new', 'test-project']) + // .then(new Promise(executor) + // .then(() => { + // if (ngServePid) treeKill(ngServePid); + // if (ngE2ePid) treeKill(ngE2ePid); + // }) + // .catch((msg) => { + // if (ngServePid) treeKill(ngServePid); + // if (ngE2ePid) treeKill(ngE2ePid); + // throw new Error(msg); + // })); + // }); + + // it('ng e2e fails with exit code', function () { + // this.timeout(240000); + + // var ngE2ePid; + // var e2eProcess; + + // function executor(resolve, reject) { + // e2eProcess = child_process.exec(`${ngBin} e2e`); + // ngE2ePid = e2eProcess.pid; + + // e2eProcess.stderr.on('data', (data) => { + // reject(data); + // }) + + // e2eProcess.on('close', (code) => { + // code !== 0 ? resolve() : reject('ng e2e command closed with error') + // }); + + // } + + // return new Promise(executor) + // .then(() => { + // if (ngE2ePid) treeKill(ngE2ePid); + // }) + // .catch((msg) => { + // if (ngE2ePid) treeKill(ngE2ePid); + // throw new Error(msg); + // }); + // }); }); diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 309264802ee4..154d856e6009 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -152,6 +152,7 @@ describe('Basic end-to-end Workflow', function () { if (ngServePid) treeKill(ngServePid); }) .catch((msg) => { + console.log(msg); if (ngServePid) treeKill(ngServePid); throw new Error(msg); }); From 5dcaaaf8e4b4071c52712345b136207b1b1061f3 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Mon, 6 Jun 2016 22:33:08 -0400 Subject: [PATCH 07/30] Add e2e spec back in --- tests/acceptance/e2e.spec.js | 158 ++++++++++++++++----------------- tests/e2e/e2e_workflow.spec.js | 1 - 2 files changed, 79 insertions(+), 80 deletions(-) diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index e8e97f9ba67b..7758fb887db6 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -27,83 +27,83 @@ describe('Acceptance: ng e2e', function () { }); }); - // it('ng e2e completes successfully after serving project', function () { - // this.timeout(240000); - - // var ngServePid; - // var ngE2ePid; - - // function executor(resolve, reject) { - // var serveProcess = child_process.exec(`${ngBin} serve`); - // var startedProtractor = false; - // ngServePid = serveProcess.pid; - - // serveProcess.stdout.on('data', (data) => { - // if (/Build successful/.test(data) && !startedProtractor) { - // startedProtractor = true; - // var e2eProcess = child_process.exec(`${ngBin} e2e`); - // ngE2ePid = e2eProcess.pid; - - // e2eProcess.then((error, stdout, stderr) => { - // if (error !== null) { - // reject(stderr); - // } else { - // resolve(); - // } - // }); - // } else if (/ failed with:/.test(data)) { - // reject(data); - // } - // }); - - // serveProcess.stderr.on('data', (data) => { - // reject(data); - // }); - // serveProcess.on('close', (code) => { - // code === 0 ? resolve() : reject('ng serve command closed with error') - // }); - // } - - // return ng(['new', 'test-project']) - // .then(new Promise(executor) - // .then(() => { - // if (ngServePid) treeKill(ngServePid); - // if (ngE2ePid) treeKill(ngE2ePid); - // }) - // .catch((msg) => { - // if (ngServePid) treeKill(ngServePid); - // if (ngE2ePid) treeKill(ngE2ePid); - // throw new Error(msg); - // })); - // }); - - // it('ng e2e fails with exit code', function () { - // this.timeout(240000); - - // var ngE2ePid; - // var e2eProcess; - - // function executor(resolve, reject) { - // e2eProcess = child_process.exec(`${ngBin} e2e`); - // ngE2ePid = e2eProcess.pid; - - // e2eProcess.stderr.on('data', (data) => { - // reject(data); - // }) - - // e2eProcess.on('close', (code) => { - // code !== 0 ? resolve() : reject('ng e2e command closed with error') - // }); - - // } - - // return new Promise(executor) - // .then(() => { - // if (ngE2ePid) treeKill(ngE2ePid); - // }) - // .catch((msg) => { - // if (ngE2ePid) treeKill(ngE2ePid); - // throw new Error(msg); - // }); - // }); + it('ng e2e completes successfully after serving project', function () { + this.timeout(240000); + + var ngServePid; + var ngE2ePid; + + function executor(resolve, reject) { + var serveProcess = child_process.exec(`${ngBin} serve`); + var startedProtractor = false; + ngServePid = serveProcess.pid; + + serveProcess.stdout.on('data', (data) => { + if (/Build successful/.test(data) && !startedProtractor) { + startedProtractor = true; + var e2eProcess = child_process.exec(`${ngBin} e2e`); + ngE2ePid = e2eProcess.pid; + + e2eProcess.then((error, stdout, stderr) => { + if (error !== null) { + reject(stderr); + } else { + resolve(); + } + }); + } else if (/ failed with:/.test(data)) { + reject(data); + } + }); + + serveProcess.stderr.on('data', (data) => { + reject(data); + }); + serveProcess.on('close', (code) => { + code === 0 ? resolve() : reject('ng serve command closed with error') + }); + } + + return ng(['new', 'test-project']) + .then(new Promise(executor) + .then(() => { + if (ngServePid) treeKill(ngServePid); + if (ngE2ePid) treeKill(ngE2ePid); + }) + .catch((msg) => { + if (ngServePid) treeKill(ngServePid); + if (ngE2ePid) treeKill(ngE2ePid); + throw new Error(msg); + })); + }); + + it('ng e2e fails with exit code', function () { + this.timeout(240000); + + var ngE2ePid; + var e2eProcess; + + function executor(resolve, reject) { + e2eProcess = child_process.exec(`${ngBin} e2e`); + ngE2ePid = e2eProcess.pid; + + e2eProcess.stderr.on('data', (data) => { + reject(data); + }) + + e2eProcess.on('close', (code) => { + code !== 0 ? resolve() : reject('ng e2e command closed with error') + }); + + } + + return new Promise(executor) + .then(() => { + if (ngE2ePid) treeKill(ngE2ePid); + }) + .catch((msg) => { + if (ngE2ePid) treeKill(ngE2ePid); + throw new Error(msg); + }); + }); }); diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 154d856e6009..309264802ee4 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -152,7 +152,6 @@ describe('Basic end-to-end Workflow', function () { if (ngServePid) treeKill(ngServePid); }) .catch((msg) => { - console.log(msg); if (ngServePid) treeKill(ngServePid); throw new Error(msg); }); From c16c552ef6cb2bad8ad1b6ee54a82a7d1b158e15 Mon Sep 17 00:00:00 2001 From: marc-sensenich Date: Mon, 6 Jun 2016 22:33:45 -0400 Subject: [PATCH 08/30] Update .travis.yml --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f4de4e1e4b5..c1d5e68a4720 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,7 @@ matrix: exclude: - os: osx env: NODE_VERSION=5 SCRIPT=lint -branches: - only: - - e2e-exit-code + script: - npm run-script $SCRIPT From ab049a7ad4d3d043ace21bf85dedf58e9cc6f16c Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Tue, 7 Jun 2016 15:09:15 -0400 Subject: [PATCH 09/30] feat: Implementation of flag to install Angular Material on `new` or `init` This features adds a `--material` flag to the `new` and `init` options. This streamlines the process of the adding of Angular Material to a new project --- addon/ng2/blueprints/ng2/files/__path__/system-config.ts | 8 +++++++- addon/ng2/blueprints/ng2/files/angular-cli-build.js | 3 ++- addon/ng2/blueprints/ng2/files/package.json | 3 ++- addon/ng2/blueprints/ng2/index.js | 6 ++++-- addon/ng2/commands/init.js | 6 ++++-- addon/ng2/commands/new.ts | 3 ++- lib/config/schema.json | 3 ++- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/addon/ng2/blueprints/ng2/files/__path__/system-config.ts b/addon/ng2/blueprints/ng2/files/__path__/system-config.ts index cc549606a2a4..8fcafd72a350 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/system-config.ts +++ b/addon/ng2/blueprints/ng2/files/__path__/system-config.ts @@ -38,13 +38,19 @@ barrels.forEach((barrelName: string) => { cliSystemConfigPackages[barrelName] = { main: 'index' }; }); +<% if(isMaterial) { %> +cliSystemConfigPackages['@angular2-material/core'] + = { format: 'cjs', defaultExtenstion: 'js', main: 'core.js' }; +<% } %> + /** Type declaration for ambient System. */ declare var System: any; // Apply the CLI SystemJS configuration. System.config({ map: { - '@angular': 'vendor/@angular', + '@angular': 'vendor/@angular', <% if(isMaterial) { %> + '@angular2-material': 'vendor/@angular2-material', <% } %> 'rxjs': 'vendor/rxjs', 'main': 'main.js' }, diff --git a/addon/ng2/blueprints/ng2/files/angular-cli-build.js b/addon/ng2/blueprints/ng2/files/angular-cli-build.js index daa7a4b54124..2e2199ab671f 100644 --- a/addon/ng2/blueprints/ng2/files/angular-cli-build.js +++ b/addon/ng2/blueprints/ng2/files/angular-cli-build.js @@ -11,7 +11,8 @@ module.exports = function(defaults) { 'es6-shim/es6-shim.js', 'reflect-metadata/**/*.+(ts|js|js.map)', 'rxjs/**/*.+(js|js.map)', - '@angular/**/*.+(js|js.map)' + '@angular/**/*.+(js|js.map)'<% if(isMaterial) { %>, + '@angular2-material/**/*.js' <% } %> ] }); }; diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index f477c2e6d1f1..0e92c3f7c5ff 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -19,7 +19,8 @@ "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", - "@angular/router": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1",<% if(isMaterial) { %> + "@angular2-material/core": "2.0.0-alpha.5-2", <% } %> "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", diff --git a/addon/ng2/blueprints/ng2/index.js b/addon/ng2/blueprints/ng2/index.js index 146ef7c50023..761fc83f449d 100644 --- a/addon/ng2/blueprints/ng2/index.js +++ b/addon/ng2/blueprints/ng2/index.js @@ -10,7 +10,8 @@ module.exports = { { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'style', type: String, default: 'css' }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'material', type: Boolean, default: false } ], afterInstall: function (options) { @@ -38,7 +39,8 @@ module.exports = { prefix: options.prefix, styleExt: this.styleExt, refToTypings: refToTypings, - isMobile: options.mobile + isMobile: options.mobile, + isMaterial: options.material }; }, diff --git a/addon/ng2/commands/init.js b/addon/ng2/commands/init.js index f77a1c2852b7..5f4f13e019c0 100644 --- a/addon/ng2/commands/init.js +++ b/addon/ng2/commands/init.js @@ -25,7 +25,8 @@ module.exports = Command.extend({ { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'material', type: Boolean, default: false } ], anonymousOptions: [''], @@ -103,7 +104,8 @@ module.exports = Command.extend({ sourceDir: commandOptions.sourceDir, style: commandOptions.style, prefix: commandOptions.prefix, - mobile: commandOptions.mobile + mobile: commandOptions.mobile, + material: commandOptions.material }; if (!validProjectName(packageName)) { diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index 685e4e3e1124..fa7f194eccb7 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -24,7 +24,8 @@ const NewCommand = Command.extend({ { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'material', type: Boolean, default: false } ], run: function (commandOptions, rawArgs) { diff --git a/lib/config/schema.json b/lib/config/schema.json index d8598052dd14..d14bd5d8c741 100644 --- a/lib/config/schema.json +++ b/lib/config/schema.json @@ -24,7 +24,8 @@ "properties": { "main": "string", "tsconfig": "string", - "mobile": "boolean" + "mobile": "boolean", + "material": "boolean" }, "additionalProperties": false }, From 6976eb05bcb3395121c60e2bd550156c9054c09b Mon Sep 17 00:00:00 2001 From: marc-sensenich Date: Tue, 7 Jun 2016 15:25:53 -0400 Subject: [PATCH 10/30] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1d5e68a4720..54e1caeaaf58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ matrix: exclude: - os: osx env: NODE_VERSION=5 SCRIPT=lint - script: - npm run-script $SCRIPT From 44fc045b2cc81d4fd57e0087607ad6f23153f90d Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Tue, 7 Jun 2016 15:29:17 -0400 Subject: [PATCH 11/30] Revert "Update .travis.yml" This reverts commit c16c552ef6cb2bad8ad1b6ee54a82a7d1b158e15. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1d5e68a4720..3f4de4e1e4b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,9 @@ matrix: exclude: - os: osx env: NODE_VERSION=5 SCRIPT=lint - +branches: + only: + - e2e-exit-code script: - npm run-script $SCRIPT From 94321cb31dddc069139238211378114cb13be71d Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Tue, 7 Jun 2016 15:29:25 -0400 Subject: [PATCH 12/30] Revert "Update .travis.yml" This reverts commit 16a8d6a8692de5506547f10271a9a4b4f6aebf0f. --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f4de4e1e4b5..1483e447d760 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,7 @@ matrix: exclude: - os: osx env: NODE_VERSION=5 SCRIPT=lint -branches: - only: - - e2e-exit-code + script: - npm run-script $SCRIPT From d0c4bf0d6f2eb8aeb27752a39bef0edc0c78b3ac Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Tue, 7 Jun 2016 15:09:15 -0400 Subject: [PATCH 13/30] feat: Implementation of flag to install Angular Material on `new` or `init` This features adds a `--material` flag to the `new` and `init` options. This streamlines the process of the adding of Angular Material to a new project --- addon/ng2/blueprints/ng2/files/__path__/system-config.ts | 8 +++++++- addon/ng2/blueprints/ng2/files/angular-cli-build.js | 3 ++- addon/ng2/blueprints/ng2/files/package.json | 3 ++- addon/ng2/blueprints/ng2/index.js | 6 ++++-- addon/ng2/commands/init.js | 6 ++++-- addon/ng2/commands/new.ts | 3 ++- lib/config/schema.json | 3 ++- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/addon/ng2/blueprints/ng2/files/__path__/system-config.ts b/addon/ng2/blueprints/ng2/files/__path__/system-config.ts index cc549606a2a4..8fcafd72a350 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/system-config.ts +++ b/addon/ng2/blueprints/ng2/files/__path__/system-config.ts @@ -38,13 +38,19 @@ barrels.forEach((barrelName: string) => { cliSystemConfigPackages[barrelName] = { main: 'index' }; }); +<% if(isMaterial) { %> +cliSystemConfigPackages['@angular2-material/core'] + = { format: 'cjs', defaultExtenstion: 'js', main: 'core.js' }; +<% } %> + /** Type declaration for ambient System. */ declare var System: any; // Apply the CLI SystemJS configuration. System.config({ map: { - '@angular': 'vendor/@angular', + '@angular': 'vendor/@angular', <% if(isMaterial) { %> + '@angular2-material': 'vendor/@angular2-material', <% } %> 'rxjs': 'vendor/rxjs', 'main': 'main.js' }, diff --git a/addon/ng2/blueprints/ng2/files/angular-cli-build.js b/addon/ng2/blueprints/ng2/files/angular-cli-build.js index daa7a4b54124..2e2199ab671f 100644 --- a/addon/ng2/blueprints/ng2/files/angular-cli-build.js +++ b/addon/ng2/blueprints/ng2/files/angular-cli-build.js @@ -11,7 +11,8 @@ module.exports = function(defaults) { 'es6-shim/es6-shim.js', 'reflect-metadata/**/*.+(ts|js|js.map)', 'rxjs/**/*.+(js|js.map)', - '@angular/**/*.+(js|js.map)' + '@angular/**/*.+(js|js.map)'<% if(isMaterial) { %>, + '@angular2-material/**/*.js' <% } %> ] }); }; diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index f477c2e6d1f1..0e92c3f7c5ff 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -19,7 +19,8 @@ "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", - "@angular/router": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1",<% if(isMaterial) { %> + "@angular2-material/core": "2.0.0-alpha.5-2", <% } %> "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", diff --git a/addon/ng2/blueprints/ng2/index.js b/addon/ng2/blueprints/ng2/index.js index 146ef7c50023..761fc83f449d 100644 --- a/addon/ng2/blueprints/ng2/index.js +++ b/addon/ng2/blueprints/ng2/index.js @@ -10,7 +10,8 @@ module.exports = { { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'style', type: String, default: 'css' }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'material', type: Boolean, default: false } ], afterInstall: function (options) { @@ -38,7 +39,8 @@ module.exports = { prefix: options.prefix, styleExt: this.styleExt, refToTypings: refToTypings, - isMobile: options.mobile + isMobile: options.mobile, + isMaterial: options.material }; }, diff --git a/addon/ng2/commands/init.js b/addon/ng2/commands/init.js index f77a1c2852b7..5f4f13e019c0 100644 --- a/addon/ng2/commands/init.js +++ b/addon/ng2/commands/init.js @@ -25,7 +25,8 @@ module.exports = Command.extend({ { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'material', type: Boolean, default: false } ], anonymousOptions: [''], @@ -103,7 +104,8 @@ module.exports = Command.extend({ sourceDir: commandOptions.sourceDir, style: commandOptions.style, prefix: commandOptions.prefix, - mobile: commandOptions.mobile + mobile: commandOptions.mobile, + material: commandOptions.material }; if (!validProjectName(packageName)) { diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index 685e4e3e1124..fa7f194eccb7 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -24,7 +24,8 @@ const NewCommand = Command.extend({ { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'material', type: Boolean, default: false } ], run: function (commandOptions, rawArgs) { diff --git a/lib/config/schema.json b/lib/config/schema.json index d8598052dd14..d14bd5d8c741 100644 --- a/lib/config/schema.json +++ b/lib/config/schema.json @@ -24,7 +24,8 @@ "properties": { "main": "string", "tsconfig": "string", - "mobile": "boolean" + "mobile": "boolean", + "material": "boolean" }, "additionalProperties": false }, From 203719841cf96ea2e6ca2be11060fa754f337ae0 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 17:18:09 -0400 Subject: [PATCH 14/30] fix(e2e): if error on e2e, reject to get proper error On a failing e2e test, reject the promise so that the exit code is not 0. --- addon/ng2/tasks/e2e.ts | 5 +-- tests/acceptance/e2e.spec.ts | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 tests/acceptance/e2e.spec.ts diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 3d377db6ba80..6547dc959fa9 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -7,16 +7,17 @@ module.exports = Task.extend({ run: function () { var ui = this.ui; - return new Promise((resolve) => { + return new Promise((resolve, reject) => { exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => { ui.writeLine(stdout); if (err) { ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); + reject(); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); + resolve(); } - resolve(); }); }); } diff --git a/tests/acceptance/e2e.spec.ts b/tests/acceptance/e2e.spec.ts new file mode 100644 index 000000000000..840cc15f244a --- /dev/null +++ b/tests/acceptance/e2e.spec.ts @@ -0,0 +1,70 @@ +'use strict'; + +var ng = require('../helpers/ng'); +var path = require('path'); +var tmp = require('../helpers/tmp'); +var conf = require('ember-cli/tests/helpers/conf'); +var expect = require('chai').expect; +var child_process = require('child_process'); +var treeKill = require('tree-kill'); +var root = path.join(process.cwd(), 'tmp'); + +const ngBin = `node ${path.join(process.cwd(), 'bin', 'ng')}`; + +describe('Acceptance ng e2e: ', function () { + before(function () { + this.timeout(100000); + + conf.setup(); + + return tmp.setup('./tmp').then(function () { + process.chdir('./tmp'); + }) + }); + + after(function () { + this.timeout(100000); + + conf.restore(); + return tmp.teardown('./tmp'); + }); + + it('Fails to execute outside of project', function () { + this.timeout(100000); + + expect(ng(['e2e'])).to.throw; + }); + + it('Fails to execute without running project', function () { + this.timeout(240000); + + var ngE2ePid; + var e2eProcess; + + function executor(resolve, reject) { + ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { + process.chdir(path.join(root, 'test-project')); + }).then(function () { + e2eProcess = child_process.exec(`${ngBin} e2e`); + ngE2ePid = e2eProcess.pid; + + e2eProcess.stderr.on('data', (data) => { + reject(data); + }); + + e2eProcess.on('close', (code) => { + code !== 0 ? resolve() : reject('ng e2e command closed with error') + }); + }); + } + + return new Promise(executor) + .then(() => { + if (ngE2ePid) treeKill(ngE2ePid); + }) + .catch((msg) => { + if (ngE2ePid) treeKill(ngE2ePid); + throw new Error(msg); + }); + }); +}); \ No newline at end of file From bf74208486ef9c60fa9fa43763e8e98a9d82ce1f Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 17:42:15 -0400 Subject: [PATCH 15/30] fix(e2e): move resolve out of if/else to resolve OSX build issues --- addon/ng2/tasks/e2e.ts | 2 +- tests/acceptance/e2e.spec.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 6547dc959fa9..5e5234088ed0 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -16,8 +16,8 @@ module.exports = Task.extend({ reject(); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); - resolve(); } + resolve(); }); }); } diff --git a/tests/acceptance/e2e.spec.ts b/tests/acceptance/e2e.spec.ts index 840cc15f244a..759edb917334 100644 --- a/tests/acceptance/e2e.spec.ts +++ b/tests/acceptance/e2e.spec.ts @@ -29,13 +29,13 @@ describe('Acceptance ng e2e: ', function () { return tmp.teardown('./tmp'); }); - it('Fails to execute outside of project', function () { + it('ng e2e fails outside of angular-cli project', function () { this.timeout(100000); expect(ng(['e2e'])).to.throw; }); - it('Fails to execute without running project', function () { + it('ng e2e fails without a locally running angular-cli project', function () { this.timeout(240000); var ngE2ePid; From 0408eca9cf08b389618442dad6f512ae91c7fb09 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 17:54:23 -0400 Subject: [PATCH 16/30] fix(e2e): add logging to e2e_suite to find OSX issues --- tests/e2e/e2e_workflow.spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 309264802ee4..abda1697389e 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -128,6 +128,14 @@ describe('Basic end-to-end Workflow', function () { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { + console.log('stdout:'); + console.log(stdout); + + console.log('stderr:'); + console.log(stderr); + + console.log('error:'); + console.log(error); if (error !== null) { reject(stderr) } else { From 8701b1866b3cfb456e55a01aea5857dbeee8999c Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 18:22:04 -0400 Subject: [PATCH 17/30] fix(e2e): change e2e running in spec in attempt to resolve sequence issues --- addon/ng2/tasks/e2e.ts | 2 +- tests/acceptance/e2e.spec.ts | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 5e5234088ed0..6547dc959fa9 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -16,8 +16,8 @@ module.exports = Task.extend({ reject(); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); + resolve(); } - resolve(); }); }); } diff --git a/tests/acceptance/e2e.spec.ts b/tests/acceptance/e2e.spec.ts index 759edb917334..5056f0cdd97d 100644 --- a/tests/acceptance/e2e.spec.ts +++ b/tests/acceptance/e2e.spec.ts @@ -38,32 +38,21 @@ describe('Acceptance ng e2e: ', function () { it('ng e2e fails without a locally running angular-cli project', function () { this.timeout(240000); - var ngE2ePid; - var e2eProcess; - function executor(resolve, reject) { ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { process.chdir(path.join(root, 'test-project')); }).then(function () { - e2eProcess = child_process.exec(`${ngBin} e2e`); - ngE2ePid = e2eProcess.pid; - - e2eProcess.stderr.on('data', (data) => { - reject(data); - }); - - e2eProcess.on('close', (code) => { - code !== 0 ? resolve() : reject('ng e2e command closed with error') - }); + ng(['e2e']).then(function(code) { + const exitCode = typeof code === 'number' ? code : 0; + exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); + }) }); } return new Promise(executor) .then(() => { - if (ngE2ePid) treeKill(ngE2ePid); }) .catch((msg) => { - if (ngE2ePid) treeKill(ngE2ePid); throw new Error(msg); }); }); From 25412db501fe71c4affb1517f5d279a8c77794d4 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 18:47:30 -0400 Subject: [PATCH 18/30] fix(e2e): remove e2e test with error --- tests/acceptance/e2e.spec.ts | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/acceptance/e2e.spec.ts b/tests/acceptance/e2e.spec.ts index 5056f0cdd97d..132d7efab2e8 100644 --- a/tests/acceptance/e2e.spec.ts +++ b/tests/acceptance/e2e.spec.ts @@ -35,25 +35,25 @@ describe('Acceptance ng e2e: ', function () { expect(ng(['e2e'])).to.throw; }); - it('ng e2e fails without a locally running angular-cli project', function () { - this.timeout(240000); - - function executor(resolve, reject) { - ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { - process.chdir(path.join(root, 'test-project')); - }).then(function () { - ng(['e2e']).then(function(code) { - const exitCode = typeof code === 'number' ? code : 0; - exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); - }) - }); - } - - return new Promise(executor) - .then(() => { - }) - .catch((msg) => { - throw new Error(msg); - }); - }); + // it('ng e2e fails without a locally running angular-cli project', function () { + // this.timeout(240000); + + // function executor(resolve, reject) { + // ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { + // process.chdir(path.join(root, 'test-project')); + // }).then(function () { + // ng(['e2e']).then(function(code) { + // const exitCode = typeof code === 'number' ? code : 0; + // exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); + // }) + // }); + // } + + // return new Promise(executor) + // .then(() => { + // }) + // .catch((msg) => { + // throw new Error(msg); + // }); + // }); }); \ No newline at end of file From 4386a683d2d1a8e818a4e9bc6d4040fe54f32fa5 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 18:59:21 -0400 Subject: [PATCH 19/30] fix(e2e): remove reject from task --- addon/ng2/tasks/e2e.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 6547dc959fa9..61bd4c9a1c4c 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -13,7 +13,8 @@ module.exports = Task.extend({ if (err) { ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); - reject(); + // reject(); + resolve(); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); resolve(); From 03661879909e363ff24e9718bebc06f64a58a885 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 19:21:51 -0400 Subject: [PATCH 20/30] fix(e2e): remove change reject to resolve with exit code --- addon/ng2/tasks/e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 61bd4c9a1c4c..b1765888c4f3 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -13,8 +13,8 @@ module.exports = Task.extend({ if (err) { ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); - // reject(); - resolve(); + const exitCode = typeof err.code === 'number' ? err.code ? 1; + resolve(exitCode); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); resolve(); From 030fca7c900a1821bf55fa1cc23878cee3cbbaa0 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 19:26:17 -0400 Subject: [PATCH 21/30] fix(e2e): syntax error --- addon/ng2/tasks/e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index b1765888c4f3..ff65c1f058d7 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -13,7 +13,7 @@ module.exports = Task.extend({ if (err) { ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); - const exitCode = typeof err.code === 'number' ? err.code ? 1; + const exitCode = typeof err.code === 'number' ? err.code : 1; resolve(exitCode); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); From d30ce0846548d03cf1e4efabd185c4db5b38f8c0 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 19:36:20 -0400 Subject: [PATCH 22/30] fix(e2e): no e2e tests, increased debugging, reject and resolve --- addon/ng2/tasks/e2e.ts | 4 +++- tests/acceptance/e2e.spec.ts | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index ff65c1f058d7..0ce5e785ece8 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -11,10 +11,12 @@ module.exports = Task.extend({ exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => { ui.writeLine(stdout); if (err) { + ui.writeLine(err.name); + ui.writeLine(err.message); ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); const exitCode = typeof err.code === 'number' ? err.code : 1; - resolve(exitCode); + reject(); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); resolve(); diff --git a/tests/acceptance/e2e.spec.ts b/tests/acceptance/e2e.spec.ts index 132d7efab2e8..78030be77762 100644 --- a/tests/acceptance/e2e.spec.ts +++ b/tests/acceptance/e2e.spec.ts @@ -29,11 +29,11 @@ describe('Acceptance ng e2e: ', function () { return tmp.teardown('./tmp'); }); - it('ng e2e fails outside of angular-cli project', function () { - this.timeout(100000); + // it('ng e2e fails outside of angular-cli project', function () { + // this.timeout(100000); - expect(ng(['e2e'])).to.throw; - }); + // expect(ng(['e2e'])).to.throw; + // }); // it('ng e2e fails without a locally running angular-cli project', function () { // this.timeout(240000); From 68c11e5490d2e12cb3a1bf7351440b41b0a52a55 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 19:48:58 -0400 Subject: [PATCH 23/30] fix(e2e): additional logging --- tests/e2e/e2e_workflow.spec.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index abda1697389e..ad9d3535b525 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -130,7 +130,7 @@ describe('Basic end-to-end Workflow', function () { child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { console.log('stdout:'); console.log(stdout); - + console.log('stderr:'); console.log(stderr); @@ -438,6 +438,15 @@ describe('Basic end-to-end Workflow', function () { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { + console.log('stdout:'); + console.log(stdout); + + console.log('stderr:'); + console.log(stderr); + + console.log('error:'); + console.log(error); + if (error !== null) { reject(stderr) } else { From 5812b6adf46639d5ab7bb11f3e9d6f40c92c6b8b Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 20:05:18 -0400 Subject: [PATCH 24/30] fix(e2e): single resolve --- addon/ng2/tasks/e2e.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 0ce5e785ece8..048df8c20b48 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -16,11 +16,10 @@ module.exports = Task.extend({ ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); const exitCode = typeof err.code === 'number' ? err.code : 1; - reject(); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); - resolve(); } + resolve(); }); }); } From 3c1760649fff0a1cba42b463f58d14bf5d1f67ba Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 20:20:53 -0400 Subject: [PATCH 25/30] fix(e2e): change e2e_suite test --- addon/ng2/tasks/e2e.ts | 3 ++- tests/e2e/e2e_workflow.spec.js | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 048df8c20b48..1073ab6c23a9 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -16,10 +16,11 @@ module.exports = Task.extend({ ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); const exitCode = typeof err.code === 'number' ? err.code : 1; + reject(exitCode); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); + resolve(); } - resolve(); }); }); } diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index ad9d3535b525..5497db99ca5f 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -127,21 +127,25 @@ describe('Basic end-to-end Workflow', function () { serveProcess.stdout.on('data', (data) => { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; - child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { - console.log('stdout:'); - console.log(stdout); + ng(['e2e']).then(function(code) { + const exitCode = typeof code === 'number' ? code : 1; + exitCode === 0 ? resolve() : reject(); + }); + // child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { + // console.log('stdout:'); + // console.log(stdout); - console.log('stderr:'); - console.log(stderr); + // console.log('stderr:'); + // console.log(stderr); - console.log('error:'); - console.log(error); - if (error !== null) { - reject(stderr) - } else { - resolve(); - } - }); + // console.log('error:'); + // console.log(error); + // if (error !== null) { + // reject(stderr) + // } else { + // resolve(); + // } + // }); } else if (/ failed with:/.test(data)) { reject(data); } From bbbf68b5556a9429ea71c50594fd6a7f8d39f858 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 21:33:26 -0400 Subject: [PATCH 26/30] Matching changed .travis.yml --- .travis.yml | 2 +- tests/acceptance/e2e.spec.ts | 52 +++++++++++++++++----------------- tests/e2e/e2e_workflow.spec.js | 30 +++++++++----------- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1483e447d760..8a9876e669c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source ~/.nvm/nvm-exec; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap caskroom/cask; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install google-chrome; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install google-chrome --force; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CHROME_BIN=chromium-browser; fi diff --git a/tests/acceptance/e2e.spec.ts b/tests/acceptance/e2e.spec.ts index 78030be77762..5056f0cdd97d 100644 --- a/tests/acceptance/e2e.spec.ts +++ b/tests/acceptance/e2e.spec.ts @@ -29,31 +29,31 @@ describe('Acceptance ng e2e: ', function () { return tmp.teardown('./tmp'); }); - // it('ng e2e fails outside of angular-cli project', function () { - // this.timeout(100000); + it('ng e2e fails outside of angular-cli project', function () { + this.timeout(100000); - // expect(ng(['e2e'])).to.throw; - // }); - - // it('ng e2e fails without a locally running angular-cli project', function () { - // this.timeout(240000); - - // function executor(resolve, reject) { - // ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { - // process.chdir(path.join(root, 'test-project')); - // }).then(function () { - // ng(['e2e']).then(function(code) { - // const exitCode = typeof code === 'number' ? code : 0; - // exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); - // }) - // }); - // } - - // return new Promise(executor) - // .then(() => { - // }) - // .catch((msg) => { - // throw new Error(msg); - // }); - // }); + expect(ng(['e2e'])).to.throw; + }); + + it('ng e2e fails without a locally running angular-cli project', function () { + this.timeout(240000); + + function executor(resolve, reject) { + ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { + process.chdir(path.join(root, 'test-project')); + }).then(function () { + ng(['e2e']).then(function(code) { + const exitCode = typeof code === 'number' ? code : 0; + exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); + }) + }); + } + + return new Promise(executor) + .then(() => { + }) + .catch((msg) => { + throw new Error(msg); + }); + }); }); \ No newline at end of file diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 5497db99ca5f..ad9d3535b525 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -127,25 +127,21 @@ describe('Basic end-to-end Workflow', function () { serveProcess.stdout.on('data', (data) => { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; - ng(['e2e']).then(function(code) { - const exitCode = typeof code === 'number' ? code : 1; - exitCode === 0 ? resolve() : reject(); - }); - // child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { - // console.log('stdout:'); - // console.log(stdout); + child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { + console.log('stdout:'); + console.log(stdout); - // console.log('stderr:'); - // console.log(stderr); + console.log('stderr:'); + console.log(stderr); - // console.log('error:'); - // console.log(error); - // if (error !== null) { - // reject(stderr) - // } else { - // resolve(); - // } - // }); + console.log('error:'); + console.log(error); + if (error !== null) { + reject(stderr) + } else { + resolve(); + } + }); } else if (/ failed with:/.test(data)) { reject(data); } From 46762e35d11b120d631ea7fbfec7ecb3b4c109a2 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 21:41:02 -0400 Subject: [PATCH 27/30] Matching changed .travis.yml --- addon/ng2/tasks/e2e.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 1073ab6c23a9..218f31252c7c 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -6,21 +6,19 @@ import {exec} from 'child_process'; module.exports = Task.extend({ run: function () { var ui = this.ui; + var exitCode = 0; return new Promise((resolve, reject) => { exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => { ui.writeLine(stdout); - if (err) { - ui.writeLine(err.name); - ui.writeLine(err.message); + if (err) { ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); - const exitCode = typeof err.code === 'number' ? err.code : 1; - reject(exitCode); + exitCode = typeof err.code === 'number' ? err.code : 1; } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); - resolve(); } + resolve(exitCode); }); }); } From 26eadff86d826f7a7fdc946eabb89133faaa03f2 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 21:56:36 -0400 Subject: [PATCH 28/30] fix(e2e): return exit codes --- addon/ng2/tasks/e2e.ts | 5 +++-- tests/e2e/e2e_workflow.spec.js | 17 ----------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 218f31252c7c..ad5fda68568d 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -6,7 +6,7 @@ import {exec} from 'child_process'; module.exports = Task.extend({ run: function () { var ui = this.ui; - var exitCode = 0; + var exitCode; return new Promise((resolve, reject) => { exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => { @@ -15,10 +15,11 @@ module.exports = Task.extend({ ui.writeLine(stderr); ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); exitCode = typeof err.code === 'number' ? err.code : 1; + reject(exitCode); } else { ui.writeLine(chalk.green('All end-to-end tests pass.')); + resolve(exitCode); } - resolve(exitCode); }); }); } diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index ad9d3535b525..309264802ee4 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -128,14 +128,6 @@ describe('Basic end-to-end Workflow', function () { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { - console.log('stdout:'); - console.log(stdout); - - console.log('stderr:'); - console.log(stderr); - - console.log('error:'); - console.log(error); if (error !== null) { reject(stderr) } else { @@ -438,15 +430,6 @@ describe('Basic end-to-end Workflow', function () { if (/Build successful/.test(data) && !startedProtractor) { startedProtractor = true; child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => { - console.log('stdout:'); - console.log(stdout); - - console.log('stderr:'); - console.log(stderr); - - console.log('error:'); - console.log(error); - if (error !== null) { reject(stderr) } else { From 61bd6d2e7cbc9a969d1d28836e92d4295f7d3f7e Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 22:07:44 -0400 Subject: [PATCH 29/30] fix(e2e): return exit codes --- tests/acceptance/e2e.spec.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index 777e1869bda9..5b9ce9584598 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -5,12 +5,8 @@ var path = require('path'); var tmp = require('../helpers/tmp'); var conf = require('ember-cli/tests/helpers/conf'); var expect = require('chai').expect; -var child_process = require('child_process'); -var treeKill = require('tree-kill'); var root = path.join(process.cwd(), 'tmp'); -const ngBin = `node ${path.join(process.cwd(), 'bin', 'ng')}`; - describe('Acceptance ng e2e: ', function () { before(function () { this.timeout(100000); @@ -41,11 +37,12 @@ describe('Acceptance ng e2e: ', function () { function executor(resolve, reject) { ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () { process.chdir(path.join(root, 'test-project')); - }).then(function () { - ng(['e2e']).then(function(code) { - const exitCode = typeof code === 'number' ? code : 0; - exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); - }) + }) + .then(function () { + ng(['e2e']).then(function(code) { + const exitCode = typeof code === 'number' ? code : 0; + exitCode !== 0 ? resolve() : reject('ng e2e command closed with error'); + }) }); } From 74aea154890e5534df78db111c2cae5d225c56d0 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Wed, 8 Jun 2016 22:16:19 -0400 Subject: [PATCH 30/30] fix(e2e): return exit codes remove extraneous reject from task --- addon/ng2/tasks/e2e.ts | 2 +- tests/acceptance/e2e.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/ng2/tasks/e2e.ts b/addon/ng2/tasks/e2e.ts index 218f31252c7c..ed8e50d3d0e2 100644 --- a/addon/ng2/tasks/e2e.ts +++ b/addon/ng2/tasks/e2e.ts @@ -8,7 +8,7 @@ module.exports = Task.extend({ var ui = this.ui; var exitCode = 0; - return new Promise((resolve, reject) => { + return new Promise((resolve) => { exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => { ui.writeLine(stdout); if (err) { diff --git a/tests/acceptance/e2e.spec.js b/tests/acceptance/e2e.spec.js index 5b9ce9584598..31a6848c7aa4 100644 --- a/tests/acceptance/e2e.spec.js +++ b/tests/acceptance/e2e.spec.js @@ -51,4 +51,4 @@ describe('Acceptance ng e2e: ', function () { throw new Error(msg); }); }); -}); \ No newline at end of file +});