Skip to content

Commit 83b7ad3

Browse files
committed
test: add poll test
1 parent 53c1097 commit 83b7ad3

File tree

5 files changed

+58
-26
lines changed

5 files changed

+58
-26
lines changed

.travis.yml

+28-25
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,36 @@ matrix:
1515
include:
1616
- node_js: "6"
1717
os: linux
18-
env: SCRIPT=lint
19-
- node_js: "6"
20-
os: linux
21-
env: SCRIPT=build
22-
- node_js: "6"
23-
os: linux
24-
env: SCRIPT=test
25-
- node_js: "6"
26-
os: linux
27-
env: NODE_SCRIPT="tests/run_e2e.js --glob=tests/build/**"
28-
- node_js: "6"
29-
os: linux
30-
env: NODE_SCRIPT="tests/run_e2e.js --ignore=**/tests/build/**"
31-
- node_js: "6"
32-
os: linux
33-
env: NODE_SCRIPT="tests/run_e2e.js --ng4 --glob=tests/build/**"
34-
- node_js: "6"
35-
os: linux
36-
env: NODE_SCRIPT="tests/run_e2e.js --ng4 --ignore=**/tests/build/**"
18+
env: NODE_SCRIPT="tests/run_e2e.js tests/e2e/tests/build/poll.ts"
19+
# - node_js: "6"
20+
# os: linux
21+
# env: SCRIPT=lint
22+
# - node_js: "6"
23+
# os: linux
24+
# env: SCRIPT=build
25+
# - node_js: "6"
26+
# os: linux
27+
# env: SCRIPT=test
28+
# - node_js: "6"
29+
# os: linux
30+
# env: NODE_SCRIPT="tests/run_e2e.js --glob=tests/build/**"
31+
# - node_js: "6"
32+
# os: linux
33+
# env: NODE_SCRIPT="tests/run_e2e.js --ignore=**/tests/build/**"
34+
# - node_js: "6"
35+
# os: linux
36+
# env: NODE_SCRIPT="tests/run_e2e.js --ng4 --glob=tests/build/**"
37+
# - node_js: "6"
38+
# os: linux
39+
# env: NODE_SCRIPT="tests/run_e2e.js --ng4 --ignore=**/tests/build/**"
3740

3841
# Optional builds.
39-
- node_js: "6"
40-
os: linux
41-
env: NODE_SCRIPT="tests/run_e2e.js --nightly --ng4"
42-
- node_js: "7"
43-
os: linux
44-
env: NODE_SCRIPT=tests/run_e2e.js
42+
# - node_js: "6"
43+
# os: linux
44+
# env: NODE_SCRIPT="tests/run_e2e.js --nightly --ng4"
45+
# - node_js: "7"
46+
# os: linux
47+
# env: NODE_SCRIPT=tests/run_e2e.js
4548

4649
before_install:
4750
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi

packages/@angular/cli/custom-typings.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface IWebpackDevServerConfigurationOptions {
99
noInfo?: boolean;
1010
lazy?: boolean;
1111
filename?: string;
12+
watch?: boolean;
1213
watchOptions?: {
1314
aggregateTimeout?: number;
1415
poll?: number;

packages/@angular/cli/tasks/serve.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default Task.extend({
1919
run: function (serveTaskOptions: ServeTaskOptions, rebuildDoneCb: any) {
2020
const ui = this.ui;
2121

22+
console.log('### poll', serveTaskOptions.poll)
23+
2224
let webpackCompiler: any;
2325
const projectConfig = CliConfig.fromProject().config;
2426
const appConfig = projectConfig.apps[0];

tests/e2e/tests/build/poll.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {
2+
killAllProcesses,
3+
waitForAnyProcessOutputToMatch,
4+
silentExecAndWaitForOutputToMatch
5+
} from '../../utils/process';
6+
import {appendToFile} from '../../utils/fs';
7+
import {expectToFail, wait} from '../../utils/utils';
8+
9+
const webpackGoodRegEx = /webpack: Compiled successfully./;
10+
11+
export default function() {
12+
return silentExecAndWaitForOutputToMatch('ng', ['serve', '--poll=10000'], webpackGoodRegEx)
13+
// Wait before editing a file. Editing too soon seems to trigger a rebuild.
14+
.then(() => wait(1000))
15+
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
16+
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
17+
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
18+
// No rebuilds should occur for a while
19+
.then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 6000)))
20+
// But a rebuild should happen roughly within the 10 second window.
21+
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
22+
.then(() => killAllProcesses(), (err: any) => {
23+
killAllProcesses();
24+
throw err;
25+
});
26+
}

tests/e2e/utils/process.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
5353
data.toString('utf-8')
5454
.split(/[\n\r]+/)
5555
.filter(line => line !== '')
56-
.forEach(line => console.log(' ' + line));
56+
.forEach(line => console.log((new Date()).toUTCString() + ' ' + line));
5757
});
5858
childProcess.stderr.on('data', (data: Buffer) => {
5959
stderr += data.toString('utf-8');

0 commit comments

Comments
 (0)