Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --grep flag to gulp test #2904

Merged
merged 9 commits into from
Jul 28, 2018
Merged
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
7 changes: 4 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ When submitting a PR, please fill out the template that is presented by GitHub w
# Or run tests by selecting the appropriate drop down option

# Alternatively, build and run tests through gulp and npm scripts
gulp build # build
npm test # test
gulp test # run tests inside Docker container
gulp build # build
npm test # test
gulp test # run tests inside Docker container
gulp test --grep testSuite # run only tests/suites filtered by js regex inside container
```

## Code Architecture
Expand Down
18 changes: 17 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ gulp.task('forceprettier', function(done) {

// test
gulp.task('test', function(done) {
// the flag --grep takes js regex as a string and filters by test and test suite names
var knownOptions = {
string: 'grep',
default: { grep: '' },
};
var options = minimist(process.argv.slice(2), knownOptions);

var spawn = require('child_process').spawn;
const dockerTag = 'vscodevim';

Expand All @@ -200,8 +207,17 @@ gulp.task('test', function(done) {
);
}

const dockerRunArgs = [
'run',
'-it',
'--env',
`MOCHA_GREP=${options.grep}`,
'-v',
process.cwd() + ':/app',
dockerTag,
];
console.log('Running tests inside container...');
var dockerRunCmd = spawn('docker', ['run', '-it', '-v', process.cwd() + ':/app', dockerTag], {
var dockerRunCmd = spawn('docker', dockerRunArgs, {
cwd: process.cwd(),
stdio: 'inherit',
});
Expand Down
9 changes: 7 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ 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({
// create new RegExp to catch errors early, ie before passing it to mocha
const mochaGrep = new RegExp(process.env.MOCHA_GREP || '');
const testRunnerConfiguration: MochaSetupOptions = {
ui: 'tdd',
useColors: true,
timeout: 10000,
});
grep: mochaGrep,
};

testRunner.configure(testRunnerConfiguration);

module.exports = testRunner;