From c0b52655babc3f85ab1c6c848833eaaa85fb5ba0 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 24 Mar 2017 22:26:44 +0100 Subject: [PATCH] Fixes #23183: Cannot use mocha --run anymore --- scripts/test-int-mocha.bat | 2 +- scripts/test-int-mocha.sh | 2 +- test/all.js | 20 ++++++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/test-int-mocha.bat b/scripts/test-int-mocha.bat index a448bdd9218..482aadc5bd5 100644 --- a/scripts/test-int-mocha.bat +++ b/scripts/test-int-mocha.bat @@ -1 +1 @@ -.\scripts\test.bat --run **\*.integrationTest.js -g integration %* +.\scripts\test.bat --runGlob **\*.integrationTest.js -g integration %* diff --git a/scripts/test-int-mocha.sh b/scripts/test-int-mocha.sh index 0d31a4d17d0..c0a8913886a 100755 --- a/scripts/test-int-mocha.sh +++ b/scripts/test-int-mocha.sh @@ -1 +1 @@ -./scripts/test.sh --run **/*.integrationTest.js -g integration "$@" \ No newline at end of file +./scripts/test.sh --runGlob **/*.integrationTest.js -g integration "$@" \ No newline at end of file diff --git a/test/all.js b/test/all.js index 2d353c0d6c4..14c6897b197 100644 --- a/test/all.js +++ b/test/all.js @@ -144,7 +144,7 @@ function main() { var coveragePath = path.join(path.dirname(__dirname), '.build', 'coverage'); var reportTypes = []; - if (argv.run) { + if (argv.run || argv.runGlob) { // single file running coveragePath += '-single'; reportTypes = ['lcovonly']; @@ -178,7 +178,7 @@ function main() { var loadFunc = null; - if (argv.run) { + if (argv.runGlob) { loadFunc = cb => { const doRun = tests => { const modulesToLoad = tests.map(test => { @@ -191,11 +191,15 @@ function main() { define(modulesToLoad, () => cb(null), cb); }; - if (typeof argv.run === 'string') { - glob(argv.run, { cwd: src }, function (err, files) { doRun(files); }); - } else { - doRun(argv.run); - } + glob(argv.runGlob, { cwd: src }, function (err, files) { doRun(files); }); + }; + } else if (argv.run) { + var tests = (typeof argv.run === 'string') ? [argv.run] : argv.run; + var modulesToLoad = tests.map(function(test) { + return path.relative(src, path.resolve(test)).replace(/(\.js)|(\.d\.ts)|(\.js\.map)$/, ''); + }); + loadFunc = cb => { + define(modulesToLoad, () => cb(null), cb); }; } else if (argv['only-monaco-editor']) { loadFunc = function(cb) { @@ -238,7 +242,7 @@ function main() { process.stderr.write = write; - if (!argv.run) { + if (!argv.run && !argv.runGlob) { // set up last test suite('Loader', function () { test('should not explode while loading', function () {