Skip to content

Commit

Permalink
Readded support for multiple excluded packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslaw-zan committed Sep 6, 2022
1 parent b65a56a commit 69bd1ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const path = require( 'path' );
const SINGLE_PACKAGE_REGEXP = /^[a-z][a-z-]+[a-z]$/;
// Matches pattern of a specific filename test path, e.g. "ckeditor5/article", "basic-styles/bold*".
const NAMED_TEST_REGEXP = /^[a-z1-9-]+\/[*a-z-]+$/;
// Matches pattern of a single excluded package name, e.g. "!engine", "!special-characters".
const EXCLUSION_REGEXP = /^![a-z-]+[a-z]$/;
// Matches pattern of a single package name and subdirectory, e.g. "engine/view/", "alignment/alignment/".
// Matches pattern of excluded package names, e.g. "!engine", "!special-characters", "!(ui|core)".
const EXCLUSION_REGEXP = /^!(?:\([a-z-|]+\)|[a-z-]+)$/;
// Matches pattern of a single package name and a subdirectory, e.g. "engine/view/", "alignment/alignment/".
const DIRECTORY_REGEXP = /^[a-z]+\/[/a-z-]+\/$/;

/**
Expand Down Expand Up @@ -70,7 +70,7 @@ function transformSingleGlobPattern( globPattern, options ) {
const prefix = options.useCKEditorPrefix ? 'ckeditor' : 'ckeditor5';
const packagesDirectory = options.externalPackages ? [ 'external', '*', 'packages' ] : [ 'packages' ];

const chunks = globPattern.match( /[a-z1-9*-]+/g );
const chunks = globPattern.match( /[a-z1-9|*-]+/g );
const returnChunks = [];

// Every path starts with workspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe( 'dev-tests/utils', () => {
} );

describe( 'converts "!foo" to pattern matching all tests except from a package', () => {
it( 'for automated tests', () => {
it( 'for automated tests (single exclusion)', () => {
expect( transformFileOptionToTestGlob( '!engine' ) ).to.deep.equal( [
'/workspace/packages/ckeditor5-!(engine)*/tests/**/*.js',
'/workspace/packages/ckeditor-!(engine)*/tests/**/*.js',
Expand All @@ -85,14 +85,32 @@ describe( 'dev-tests/utils', () => {
] );
} );

it( 'for manual tests', () => {
it( 'for automated tests (multiple exclusions)', () => {
expect( transformFileOptionToTestGlob( '!(engine|core|basic-styles)' ) ).to.deep.equal( [
'/workspace/packages/ckeditor5-!(engine|core|basic-styles)*/tests/**/*.js',
'/workspace/packages/ckeditor-!(engine|core|basic-styles)*/tests/**/*.js',
'/workspace/external/*/packages/ckeditor5-!(engine|core|basic-styles)*/tests/**/*.js',
'/workspace/external/*/packages/ckeditor-!(engine|core|basic-styles)*/tests/**/*.js'
] );
} );

it( 'for manual tests (single exclusion)', () => {
expect( transformFileOptionToTestGlob( '!engine', true ) ).to.deep.equal( [
'/workspace/packages/ckeditor5-!(engine)*/tests/**/manual/**/*.js',
'/workspace/packages/ckeditor-!(engine)*/tests/**/manual/**/*.js',
'/workspace/external/*/packages/ckeditor5-!(engine)*/tests/**/manual/**/*.js',
'/workspace/external/*/packages/ckeditor-!(engine)*/tests/**/manual/**/*.js'
] );
} );

it( 'for manual tests (multiple exclusions)', () => {
expect( transformFileOptionToTestGlob( '!(engine|core|basic-styles)', true ) ).to.deep.equal( [
'/workspace/packages/ckeditor5-!(engine|core|basic-styles)*/tests/**/manual/**/*.js',
'/workspace/packages/ckeditor-!(engine|core|basic-styles)*/tests/**/manual/**/*.js',
'/workspace/external/*/packages/ckeditor5-!(engine|core|basic-styles)*/tests/**/manual/**/*.js',
'/workspace/external/*/packages/ckeditor-!(engine|core|basic-styles)*/tests/**/manual/**/*.js'
] );
} );
} );

describe( 'converts "foo/bar/" to pattern matching all tests from a package and a subdirectory', () => {
Expand Down

0 comments on commit 69bd1ed

Please sign in to comment.