Add --grep flag to gulp test task (passed to mocha --grep)

This commit is contained in:
manishb 2018-07-27 15:23:52 -04:00
parent c5469dcbfe
commit 1cf8dc70d1
2 changed files with 28 additions and 6 deletions

View File

@ -178,6 +178,12 @@ gulp.task('forceprettier', function(done) {
// test
gulp.task('test', function(done) {
var knownOptions = {
string: 'grep',
default: { grep: '' },
};
var options = minimist(process.argv.slice(2), knownOptions);
var spawn = require('child_process').spawn;
const dockerTag = 'vscodevim';
@ -201,10 +207,22 @@ gulp.task('test', function(done) {
}
console.log('Running tests inside container...');
var dockerRunCmd = spawn('docker', ['run', '-it', '-v', process.cwd() + ':/app', dockerTag], {
cwd: process.cwd(),
stdio: 'inherit',
});
var dockerRunCmd = spawn(
'docker',
[
'run',
'-it',
'--env',
`MOCHA_GREP=${options.grep}`,
'-v',
process.cwd() + ':/app',
dockerTag,
],
{
cwd: process.cwd(),
stdio: 'inherit',
}
);
dockerRunCmd.on('exit', function(exitCode) {
done(exitCode);

View File

@ -17,10 +17,14 @@ Globals.mockConfiguration = new Configuration();
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
var testRunner = require('vscode/lib/testrunner');
testRunner.configure({
const mochaGrep = new RegExp(process.env.MOCHA_GREP || '');
const testRunnerConfiguration = {
ui: 'tdd',
useColors: true,
timeout: 10000,
});
grep: mochaGrep,
};
testRunner.configure(testRunnerConfiguration);
module.exports = testRunner;