Skip to content

Commit

Permalink
test: add poll test
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Feb 15, 2017
1 parent 53c1097 commit 83b7ad3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 26 deletions.
53 changes: 28 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,36 @@ matrix:
include:
- node_js: "6"
os: linux
env: SCRIPT=lint
- node_js: "6"
os: linux
env: SCRIPT=build
- node_js: "6"
os: linux
env: SCRIPT=test
- node_js: "6"
os: linux
env: NODE_SCRIPT="tests/run_e2e.js --glob=tests/build/**"
- node_js: "6"
os: linux
env: NODE_SCRIPT="tests/run_e2e.js --ignore=**/tests/build/**"
- node_js: "6"
os: linux
env: NODE_SCRIPT="tests/run_e2e.js --ng4 --glob=tests/build/**"
- node_js: "6"
os: linux
env: NODE_SCRIPT="tests/run_e2e.js --ng4 --ignore=**/tests/build/**"
env: NODE_SCRIPT="tests/run_e2e.js tests/e2e/tests/build/poll.ts"
# - node_js: "6"
# os: linux
# env: SCRIPT=lint
# - node_js: "6"
# os: linux
# env: SCRIPT=build
# - node_js: "6"
# os: linux
# env: SCRIPT=test
# - node_js: "6"
# os: linux
# env: NODE_SCRIPT="tests/run_e2e.js --glob=tests/build/**"
# - node_js: "6"
# os: linux
# env: NODE_SCRIPT="tests/run_e2e.js --ignore=**/tests/build/**"
# - node_js: "6"
# os: linux
# env: NODE_SCRIPT="tests/run_e2e.js --ng4 --glob=tests/build/**"
# - node_js: "6"
# os: linux
# env: NODE_SCRIPT="tests/run_e2e.js --ng4 --ignore=**/tests/build/**"

# Optional builds.
- node_js: "6"
os: linux
env: NODE_SCRIPT="tests/run_e2e.js --nightly --ng4"
- node_js: "7"
os: linux
env: NODE_SCRIPT=tests/run_e2e.js
# - node_js: "6"
# os: linux
# env: NODE_SCRIPT="tests/run_e2e.js --nightly --ng4"
# - node_js: "7"
# os: linux
# env: NODE_SCRIPT=tests/run_e2e.js

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/custom-typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface IWebpackDevServerConfigurationOptions {
noInfo?: boolean;
lazy?: boolean;
filename?: string;
watch?: boolean;
watchOptions?: {
aggregateTimeout?: number;
poll?: number;
Expand Down
2 changes: 2 additions & 0 deletions packages/@angular/cli/tasks/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default Task.extend({
run: function (serveTaskOptions: ServeTaskOptions, rebuildDoneCb: any) {
const ui = this.ui;

console.log('### poll', serveTaskOptions.poll)

let webpackCompiler: any;
const projectConfig = CliConfig.fromProject().config;
const appConfig = projectConfig.apps[0];
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/tests/build/poll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
killAllProcesses,
waitForAnyProcessOutputToMatch,
silentExecAndWaitForOutputToMatch
} from '../../utils/process';
import {appendToFile} from '../../utils/fs';
import {expectToFail, wait} from '../../utils/utils';

const webpackGoodRegEx = /webpack: Compiled successfully./;

export default function() {
return silentExecAndWaitForOutputToMatch('ng', ['serve', '--poll=10000'], webpackGoodRegEx)
// Wait before editing a file. Editing too soon seems to trigger a rebuild.
.then(() => wait(1000))
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
// No rebuilds should occur for a while
.then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 6000)))
// But a rebuild should happen roughly within the 10 second window.
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
.then(() => killAllProcesses(), (err: any) => {
killAllProcesses();
throw err;
});
}
2 changes: 1 addition & 1 deletion tests/e2e/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
data.toString('utf-8')
.split(/[\n\r]+/)
.filter(line => line !== '')
.forEach(line => console.log(' ' + line));
.forEach(line => console.log((new Date()).toUTCString() + ' ' + line));
});
childProcess.stderr.on('data', (data: Buffer) => {
stderr += data.toString('utf-8');
Expand Down

0 comments on commit 83b7ad3

Please sign in to comment.