mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
Merge pull request #2904 from xmbhasin/mocha-grep
Add --grep flag to gulp test
This commit is contained in:
commit
1e1e8b0533
7
.github/CONTRIBUTING.md
vendored
7
.github/CONTRIBUTING.md
vendored
@ -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
|
||||
|
18
gulpfile.js
18
gulpfile.js
@ -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';
|
||||
|
||||
@ -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',
|
||||
});
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user