Skip to content

Commit

Permalink
Other: Removed support for --only-root, --include-root and `--fil…
Browse files Browse the repository at this point in the history
…es=/` options. In order to run tests from the main repository, type `--files=ckeditor5`. Closes #570.


BREAKING CHANGE: Removed support for `--only-root`, `--include-root` and `--files=/` options. Use `--files=ckeditor5` instead.
  • Loading branch information
mlewand committed Oct 31, 2019
2 parents da17895 + 15d5b55 commit 586d272
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 90 deletions.
4 changes: 1 addition & 3 deletions packages/ckeditor5-dev-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ You can also use the bin script for testing a package:
* `browsers` - Browsers which will be used to run the tests. Also available as an alias: `-b`.
* `reporter` - Mocha reporter – either `mocha` (default) or `dots` (less verbose one).
* `disallow-console-use` - Whether to throw an error when one of the console methods (e.g. `console.log()`) is executed.
* `only-root` - Whether to run tests only for root repository. Equivalent of `--files /`.
* `include-root` - Whether to append root repository to tests matched by `--files`.

#### Examples

Expand Down Expand Up @@ -99,7 +97,7 @@ $ npm t -- --files='!(engine|ui)'
| `engine/view/so/**/me/glob.js` | `node_modules/ckeditor5-engine/tests/view/so/**/me/*glob.js` | |
| `!(engine)` | `node_modules/ckeditor5-!(engine)*/tests/**/*.js` | all tests except of given package(s) – works with multiple names `!(engine|ui|utils)` |
| `*` | `node_modules/ckeditor5-*/tests/**/*.js` | all installed package's tests |
| `/` | `tests/**/*.js` | current package's tests only |
| `ckeditor5` | `tests/**/*.js` | tests from the main repository |

## Changelog

Expand Down
9 changes: 1 addition & 8 deletions packages/ckeditor5-dev-tests/bin/test-manual.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ const cwd = process.cwd();
const options = tests.parseArguments( process.argv.slice( 2 ) );

if ( options.files.length === 0 ) {
// Checks whether the test command was called from the main repository.
// If so then take all packages files to tests.
if ( require( path.join( cwd, 'package.json' ) ).name === 'ckeditor5' ) {
options.files = [ '*', '/' ];
} else {
// In other case take files from the current package.
options.files = [ '/' ];
}
options.files = [ '*', 'ckeditor5' ];
}

// "Lark" is the default theme for tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,5 @@ module.exports = function parseArguments( args ) {
delete options[ alias ];
}

// Due to issues with `/` in Git bash (on Windows environments), we needed to introduce more CLI parameters.
// See: https://github.com/ckeditor/ckeditor5-dev/issues/558#issuecomment-534008612
// `--include-root` appends `/` to the `--files` list.
// E.g.: `yarn run manual -f core --include-root` => `yarn run manual -f core,/`
if ( options[ 'include-root' ] && !options.files.includes( '/' ) ) {
options.files.push( '/' );

delete options[ 'include-root' ];
}

// `--only-root` means that we want to compile manual tests from the main repository only.
// E.g.: `yarn run manual --only-root` => `yarn run manual -f /`
if ( options[ 'only-root' ] ) {
options.files = [ '/' ];

delete options[ 'only-root' ];
}

return options;
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Converts values of --files argument to proper globs.
* There are 5 supported types of values now:
*
* 0. current package's tests (when run in context of a package – e.g. on CI) - '/'
* 0. the main repository - 'ckeditor5'
* 1. all packages' files – '*'
* 2. given package files – 'engine'
* 3. everything except the given package – '!engine'
Expand Down Expand Up @@ -60,7 +60,7 @@ function transformSingleGlobPattern( globPattern, options ) {
globSuffix.push( '*.js' );

// 0.
if ( globPattern === '/' ) {
if ( globPattern === 'ckeditor5' ) {
returnChunks = cwdChunks.concat( globSuffix );
} else if ( chunks.length === 0 ) {
// 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,60 +74,4 @@ describe( 'parseArguments()', () => {

expect( options.debug ).to.deep.equal( [] );
} );

describe( 'workaround for "/" in Git Bash (Windows)', () => {
it( 'adds the main repository when --include-root was used', () => {
const options = parseArguments( [
'--include-root'
] );

expect( options.files ).to.deep.equal( [ '/' ] );
} );

it( 'removes "include-root" from "options" object', () => {
const options = parseArguments( [
'--include-root'
] );

expect( options[ 'include-root' ] ).to.be.undefined;
} );

it( 'does not duplicate the main repository when --include-root was used', () => {
const options = parseArguments( [
'--files',
'/',
'--include-root'
] );

expect( options.files ).to.deep.equal( [ '/' ] );
} );

it( 'merges --include-root and values specified in --files', () => {
const options = parseArguments( [
'--files',
'core,engine',
'--include-root'
] );

expect( options.files ).to.deep.equal( [ 'core', 'engine', '/' ] );
} );

it( 'ignores values specified in --files when --only-root was used', () => {
const options = parseArguments( [
'--files',
'core,engine',
'--only-root'
] );

expect( options.files ).to.deep.equal( [ '/' ] );
} );

it( 'removes "only-root" from "options" object', () => {
const options = parseArguments( [
'--only-root'
] );

expect( options[ 'only-root' ] ).to.be.undefined;
} );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ describe( 'dev-tests/utils', () => {
sandbox.restore();
} );

describe( 'converts "/" to current package\'s tests', () => {
describe( 'converts "ckeditor5" to the root package tests', () => {
it( 'for automated tests', () => {
expect( transformFileOptionToTestGlob( '/' ) ).to.deep.equal( [ '/workspace/tests/**/*.js' ] );
expect( transformFileOptionToTestGlob( 'ckeditor5' ) ).to.deep.equal( [ '/workspace/tests/**/*.js' ] );
} );

it( 'for manual tests', () => {
expect( transformFileOptionToTestGlob( '/', true ) ).to.deep.equal( [ '/workspace/tests/**/manual/**/*.js' ] );
expect( transformFileOptionToTestGlob( 'ckeditor5', true ) ).to.deep.equal( [ '/workspace/tests/**/manual/**/*.js' ] );
} );
} );

Expand Down

0 comments on commit 586d272

Please sign in to comment.