Skip to content

Commit

Permalink
fix(server-tests): errored tests after Node 15.3.0 update (#5744)
Browse files Browse the repository at this point in the history
* fix(server-tests): errored tests after Node 15.3.0 update

* move domain helpers functions to separate dir

* update .dockerignore file with gulp scripts dir
  • Loading branch information
wentwrong authored Nov 26, 2020
1 parent 75fb241 commit 4010584
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*
!docker
!gulp
!test
!Gulpfile.js
!.publishrc
!*.tgz
!*.tgz
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ package-lock.json
Gemfile.lock
.npmrc
.DS_Store
!gulp
91 changes: 50 additions & 41 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
const gulp = require('gulp');
const gulpStep = require('gulp-step');
const data = require('gulp-data');
const less = require('gulp-less');
const qunitHarness = require('gulp-qunit-harness');
const git = require('gulp-git');
const mocha = require('gulp-mocha-simple');
const mustache = require('gulp-mustache');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const ll = require('gulp-ll-next');
const clone = require('gulp-clone');
const mergeStreams = require('merge-stream');
const del = require('del');
const fs = require('fs');
const path = require('path');
const { Transform } = require('stream');
const { promisify } = require('util');
const globby = require('globby');
const open = require('open');
const connect = require('connect');
const execa = require('execa');
const serveStatic = require('serve-static');
const markdownlint = require('markdownlint');
const minimist = require('minimist');
const prompt = require('gulp-prompt');
const functionalTestConfig = require('./test/functional/config');
const { assignIn, castArray } = require('lodash');
const yaml = require('js-yaml');
const childProcess = require('child_process');
const listBrowsers = require('testcafe-browser-tools').getInstallations;
const npmAuditor = require('npm-auditor');
const checkLicenses = require('./test/dependency-licenses-checker');
const packageInfo = require('./package');
const getPublishTags = require('./docker/get-publish-tags');
const isDockerDaemonRunning = require('./docker/is-docker-daemon-running');
const gulp = require('gulp');
const gulpStep = require('gulp-step');
const data = require('gulp-data');
const less = require('gulp-less');
const qunitHarness = require('gulp-qunit-harness');
const git = require('gulp-git');
const mocha = require('gulp-mocha-simple');
const mustache = require('gulp-mustache');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const ll = require('gulp-ll-next');
const clone = require('gulp-clone');
const mergeStreams = require('merge-stream');
const del = require('del');
const fs = require('fs');
const path = require('path');
const { Transform } = require('stream');
const { promisify } = require('util');
const globby = require('globby');
const open = require('open');
const connect = require('connect');
const execa = require('execa');
const serveStatic = require('serve-static');
const markdownlint = require('markdownlint');
const minimist = require('minimist');
const prompt = require('gulp-prompt');
const functionalTestConfig = require('./test/functional/config');
const { assignIn, castArray } = require('lodash');
const yaml = require('js-yaml');
const childProcess = require('child_process');
const listBrowsers = require('testcafe-browser-tools').getInstallations;
const npmAuditor = require('npm-auditor');
const checkLicenses = require('./test/dependency-licenses-checker');
const packageInfo = require('./package');
const getPublishTags = require('./docker/get-publish-tags');
const isDockerDaemonRunning = require('./docker/is-docker-daemon-running');
const { exitDomains, enterDomains } = require('./gulp/helpers/domain');

const readFile = promisify(fs.readFile);

Expand Down Expand Up @@ -377,11 +378,19 @@ gulp.task('build', DEV_MODE ? gulp.registry().get('fast-build') : gulp.parallel(
gulp.step('prepare-tests', gulp.registry().get(SKIP_BUILD ? 'lint' : 'build'));

gulp.step('test-server-run', () => {
return gulp
.src('test/server/*-test.js', { read: false })
.pipe(mocha({
timeout: typeof v8debug !== 'undefined' || !!process.debugPort ? Infinity : 2000 // NOTE: disable timeouts in debug
}));
// HACK: We have to exit from all Gulp's error domains to avoid conflicts with error handling inside mocha tests
const domains = exitDomains();

try {
return gulp
.src('test/server/*-test.js', { read: false })
.pipe(mocha({
timeout: typeof v8debug !== 'undefined' || !!process.debugPort ? Infinity : 2000 // NOTE: disable timeouts in debug
}));
}
finally {
enterDomains(domains);
}
});

gulp.step('test-server-bootstrap', gulp.series('prepare-tests', 'test-server-run'));
Expand Down
26 changes: 26 additions & 0 deletions gulp/helpers/domain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function exitDomains () {
const domains = [];

while (process.domain) {
domains.push(process.domain);

process.domain.exit();
}

return domains;
}

function enterDomains (domains) {
let domain = domains.pop();

while (domain) {
domain.enter();

domain = domains.pop();
}
}

module.exports = {
exitDomains: exitDomains,
enterDomains: enterDomains
};

0 comments on commit 4010584

Please sign in to comment.