forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoll.ts
More file actions
42 lines (36 loc) · 1.66 KB
/
poll.ts
File metadata and controls
42 lines (36 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
killAllProcesses,
waitForAnyProcessOutputToMatch,
execAndWaitForOutputToMatch
} from '../../utils/process';
import {appendToFile} from '../../utils/fs';
import {expectToFail, wait} from '../../utils/utils';
const webpackGoodRegEx = /: Compiled successfully./;
export default function() {
// TODO(architect): This test is behaving oddly both here and in devkit/build-angular.
// It seems to be because of file watchers.
return;
// @filipesilva: This test doesn't work correctly on CircleCI while being ran by the test script.
// Polling time seems to be ignored and several builds are fired per second.
// Debugging showed that webpack things the `src/` directory changed on each rebuild.
// Disabling for now.
if (process.env['CIRCLECI']) {
return;
}
return execAndWaitForOutputToMatch('ng', ['build', '--watch', '--poll=10000'], webpackGoodRegEx)
// Wait before editing a file.
// Editing too soon seems to trigger a rebuild and throw polling out of whack.
.then(() => wait(3000))
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
// We have to wait poll time + rebuild build time for the regex match.
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 14000))
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
// No rebuilds should occur for a while
.then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000)))
// But a rebuild should happen roughly within the 10 second window.
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000))
.then(() => killAllProcesses(), (err: any) => {
killAllProcesses();
throw err;
});
}