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

Made ckeditor5-dev-tests a general use application #594

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 3 additions & 1 deletion packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ function createEntryFile( globPatterns, production ) {
let hasFiles = false;

for ( const resolvedPattern of globPatterns[ singlePattern ] ) {
const files = glob.sync( resolvedPattern );
const files = glob.sync( resolvedPattern, {
absolute: resolvedPattern.startsWith( './' )
} );

if ( files.length ) {
hasFiles = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = function getKarmaConfig( options ) {
files: Object.keys( options.globPatterns ).map( key => options.globPatterns[ key ] ),
sourceMap: options.sourceMap,
coverage: options.coverage,
coveragePaths: options.coveragePaths,
themePath: options.themePath,
debug: options.debug
} ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function getWebpackConfigForAutomatedTests( options ) {
rules: [
{
// test: **/ckeditor5-*/theme/icons/*.svg
test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
test: /\.svg$/,
use: [ 'raw-loader' ]
},
{
Expand Down Expand Up @@ -80,11 +80,14 @@ module.exports = function getWebpackConfigForAutomatedTests( options ) {
}

if ( options.coverage ) {
// Additional coverage paths coming from command line.
const coveragePaths = ( options.coveragePaths || [] ).map( relativePath => path.resolve( relativePath ) );

config.module.rules.unshift(
{
test: /\.js$/,
loader: 'istanbul-instrumenter-loader',
include: getPathsToIncludeForCoverage( options.files ),
include: getPathsToIncludeForCoverage( options.files ).concat( coveragePaths ),
exclude: [
new RegExp( `${ escapedPathSep }(lib)${ escapedPathSep }` )
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module.exports = function parseArguments( args ) {
'repositories',
'language',
'theme-path',
'additional-languages'
'additional-languages',
'coverage-paths'
],

boolean: [
Expand Down Expand Up @@ -58,6 +59,7 @@ module.exports = function parseArguments( args ) {
language: 'en',
watch: false,
coverage: false,
'coverage-paths': '',
verbose: false,
'source-map': false,
server: false,
Expand All @@ -83,13 +85,15 @@ module.exports = function parseArguments( args ) {
'identity-file',
'theme-path',
'karma-config-overrides',
'additional-languages'
'additional-languages',
'coverage-paths'
] );
splitOptionsToArray( options, [
'browsers',
'files',
'repositories',
'additionalLanguages'
'additionalLanguages',
'coveragePaths'
] );
parseDebugOption( options );
parseRepositoriesOption( options );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

/**
* Converts values of --files argument to proper globs.
* There are 5 supported types of values now:
* These are the supported types of values:
*
* 0. the main repository - 'ckeditor5'
* 1. all packages' files – '*'
* 2. given package files – 'engine'
* 3. everything except the given package – '!engine'
* 4. path – 'engine/view' -> 'ckeditor5-engine/tests/view/**\/*.js'
* 5. simplified glob – 'engine/view/**\/*.js' -> 'ckeditor5-engine/tests/view/**\/*.js'
* 6. a glob starting with './', which stays as is - './tests/**\/*.js'
*
* @param {String} globPattern A path or pattern to determine the tests to execute.
* @param {Boolean} [isManualTest=false] Whether the tests are manual or automated.
Expand Down Expand Up @@ -55,6 +56,11 @@ module.exports = function transformFileOptionToTestGlob( globPattern, isManualTe
* @returns {String}
*/
function transformSingleGlobPattern( globPattern, options ) {
// 6. Support for direct glob to test files.
if ( globPattern.startsWith( './' ) ) {
return globPattern;
}

const isManualTest = options.isManualTest || false;
const useCKEditorPrefix = options.useCKEditorPrefix || false;
const prefix = useCKEditorPrefix ? 'ckeditor' : 'ckeditor5';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,18 @@ describe( 'dev-tests/utils', () => {
] );
} );
} );

describe( 'keep ./ paths intact', () => {
it( 'for automated tests', () => {
expect( transformFileOptionToTestGlob( './tests/**/*.js' ) ).to.deep.equal( [
'./tests/**/*.js'
] );
} );

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