Skip to content

Commit bdb2958

Browse files
devversionmmalerba
authored andcommitted
chore: properly exit e2e tasks (#2064)
* Instead of manually exiting the process we should just ensure that everything is properly cleaned up and then gulp can take care of the exit codes. * If we have the `e2e:done` task at the end of the sequence it will be never called when an error occurred before
1 parent 2701aae commit bdb2958

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

tools/gulp/tasks/ci.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ task('ci:forbidden-identifiers', function() {
1010

1111
// Travis sometimes does not exit the process and times out. This is to prevent that.
1212
task('ci:test', ['test:single-run'], () => process.exit(0));
13-
// Travis sometimes does not exit the process and times out. This is to prevent that.
14-
task('ci:e2e', ['e2e:single-run'], () => process.exit(0));
13+
14+
task('ci:e2e', ['e2e:single-run']);

tools/gulp/tasks/e2e.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import {
77
vendorTask, sequenceTask, serverTask
88
} from '../task_helpers';
99

10+
const gulpRunSequence = require('run-sequence');
1011

1112
const appDir = path.join(SOURCE_ROOT, 'e2e-app');
1213
const outDir = DIST_ROOT;
1314
const PROTRACTOR_CONFIG_PATH = path.join(PROJECT_ROOT, 'test/protractor.conf.js');
1415

16+
/** Method to stop a running e2e web server, which may have not exited properly */
17+
let stopE2eServer = () => {};
1518

1619
task(':watch:e2eapp', () => {
1720
watch(path.join(appDir, '**/*.ts'), [':build:e2eapp:ts']);
@@ -39,17 +42,6 @@ task(':test:protractor:setup', execNodeTask('protractor', 'webdriver-manager', [
3942
/** Runs protractor tests (assumes that server is already running. */
4043
task(':test:protractor', execNodeTask('protractor', [PROTRACTOR_CONFIG_PATH]));
4144

42-
/**
43-
* Forces process termination.
44-
*
45-
* This task is used because, in some cases, protractor will block and not exit the process,
46-
* causing Travis to timeout. This task should always be used in a synchronous sequence as
47-
* the last step.
48-
*/
49-
task(':e2e:done', () => process.exit(0));
50-
51-
let stopE2eServer: () => void = null;
52-
5345
/** Starts up the e2e app server. */
5446
task(':serve:e2eapp', serverTask(false, stream => { stopE2eServer = () => stream.emit('kill'); }));
5547

@@ -70,23 +62,27 @@ task('serve:e2eapp:watch', ['serve:e2eapp', ':watch:components', ':watch:e2eapp'
7062
*
7163
* This task should only be used when running the e2e tests locally.
7264
*/
73-
task('e2e', sequenceTask(
74-
':test:protractor:setup',
75-
'serve:e2eapp:watch',
76-
':test:protractor',
77-
':serve:e2eapp:stop',
78-
':e2e:done',
79-
));
65+
task('e2e', (done: (err?: string) => void) => {
66+
gulpRunSequence(
67+
':test:protractor:setup',
68+
'serve:e2eapp:watch',
69+
':test:protractor',
70+
':serve:e2eapp:stop',
71+
(err: any) => stopE2eServer() && done(err)
72+
);
73+
});
8074

8175
/**
8276
* Runs the e2e once. Does not watch for changes.
8377
*
8478
* This task should be used when running tests on the CI server.
8579
*/
86-
task('e2e:single-run', sequenceTask(
87-
':test:protractor:setup',
88-
'serve:e2eapp',
89-
':test:protractor',
90-
':serve:e2eapp:stop',
91-
':e2e:done',
92-
));
80+
task('e2e:single-run', (done: (err?: string) => void) => {
81+
gulpRunSequence(
82+
':test:protractor:setup',
83+
'serve:e2eapp',
84+
':test:protractor',
85+
':serve:e2eapp:stop',
86+
(err: any) => stopE2eServer() && done(err)
87+
);
88+
});

0 commit comments

Comments
 (0)