Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const gulp = require('gulp');
const gulpStep = require('gulp-step');
const data = require('gulp-data');
const less = require('gulp-less');
const mocha = require('gulp-mocha-simple');
const mustache = require('gulp-mustache');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
Expand All @@ -28,6 +27,7 @@ const promisifyStream = require('./gulp/helpers/promisify-stream')
const testFunctional = require('./gulp/helpers/test-functional');
const moduleExportsTransform = require('./gulp/helpers/module-exports-transform');
const createPackageFilesForTests = require('./gulp/helpers/create-package-files-for-tests');
const { runCommands } = require('./gulp/helpers/run-shell-commands');

const {
TESTS_GLOB,
Expand Down Expand Up @@ -84,7 +84,7 @@ gulp.task('lint', () => {
'gulp/**/*.js',
'!test/client/vendor/**/*.*',
'!test/functional/fixtures/api/es-next/custom-client-scripts/data/*.js',
'Gulpfile.js',
'[Gg]ulpfile.js',
])
.pipe(eslint())
.pipe(eslint.format(process.env.ESLINT_FORMATTER))
Expand Down Expand Up @@ -254,7 +254,7 @@ gulp.step('clean-functional-tests', async () => {

gulp.step('prepare-tests', gulp.registry().get(SKIP_BUILD ? 'lint' : 'build'));

gulp.step('test-server-run', () => {
gulp.step('test-server-run', async () => {
const chai = require('chai');

chai.use(require('chai-string'));
Expand All @@ -264,11 +264,11 @@ gulp.step('test-server-run', () => {
const domains = exitDomains();

try {
return gulp
.src('test/server/*-test.js', { read: false })
.pipe(mocha({
timeout: getTimeout(4_000),
}));
const timeout = getTimeout(4_000) === Infinity ? 0 : getTimeout(4_000);

await runCommands([
`npx --no-install mocha --full-trace --timeout ${timeout} "test/server/*-test.js"`,
]);
}
finally {
enterDomains(domains);
Expand Down
19 changes: 19 additions & 0 deletions gulp/helpers/run-shell-commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const childProcess = require('child_process');

async function runCommands (commands) {
for (const command of commands) {
const commandExitCode = await new Promise((resolve, reject) => {
const child = childProcess.spawn(command, { shell: true, stdio: 'inherit' });

child.on('error', reject);
child.on('close', code => {
resolve(code ?? 1);
});
});

if (commandExitCode !== 0)
throw new Error(`Command "${command}" exited with code ${commandExitCode}`);
}
}

exports.runCommands = runCommands;
3 changes: 1 addition & 2 deletions gulp/helpers/test-functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ module.exports = async function testFunctional (src, testingEnvironmentName, { n
tests.unshift(SETUP_TESTS_GLOB);

const opts = {
reporter: 'mocha-reporter-spec-with-retries',
timeout: getTimeout(3 * 60 * 1000),
timeout: getTimeout(3 * 60 * 1000),
};

if (process.env.RETRY_FAILED_TESTS === 'true')
Expand Down
Loading
Loading