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

Fixed automated tests entry point on Windows. #1062

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 13 additions & 13 deletions packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { logger } from '@ckeditor/ckeditor5-dev-utils';
import getKarmaConfig from '../utils/automated-tests/getkarmaconfig.js';
Expand All @@ -15,21 +14,22 @@ import { mkdirp } from 'mkdirp';
import karmaLogger from 'karma/lib/logger.js';
import karma from 'karma';
import transformFileOptionToTestGlob from '../utils/transformfileoptiontotestglob.js';
import upath from 'upath';

const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );
const __dirname = upath.dirname( __filename );

// Glob patterns that should be ignored. It means if a specified test file is located under path
// that matches to these patterns, the file will be skipped.
const IGNORE_GLOBS = [
// Ignore files which are saved in `manual/` directory. There are manual tests.
path.join( '**', 'tests', '**', 'manual', '**', '*.{js,ts}' ),
upath.join( '**', 'tests', '**', 'manual', '**', '*.{js,ts}' ),
// Ignore `_utils` directory as well because there are saved utils for tests.
path.join( '**', 'tests', '**', '_utils', '**', '*.{js,ts}' )
upath.join( '**', 'tests', '**', '_utils', '**', '*.{js,ts}' )
];

// An absolute path to the entry file that will be passed to Karma.
const ENTRY_FILE_PATH = path.posix.join( process.cwd(), 'build', '.automated-tests', 'entry-point.js' );
const ENTRY_FILE_PATH = upath.join( process.cwd(), 'build', '.automated-tests', 'entry-point.js' );

export default function runAutomatedTests( options ) {
return Promise.resolve().then( () => {
Expand Down Expand Up @@ -68,7 +68,7 @@ function transformFilesToTestGlob( files ) {
}

function createEntryFile( globPatterns, production ) {
mkdirp.sync( path.dirname( ENTRY_FILE_PATH ) );
mkdirp.sync( upath.dirname( ENTRY_FILE_PATH ) );
karmaLogger.setupFromConfig( { logLevel: 'INFO' } );

const log = karmaLogger.create( 'config' );
Expand All @@ -78,7 +78,7 @@ function createEntryFile( globPatterns, production ) {
let hasFiles = false;

for ( const resolvedPattern of globPatterns[ singlePattern ] ) {
const files = globSync( resolvedPattern ).map( file => file.replace( /\\/g, '/' ) );
const files = globSync( resolvedPattern );

if ( files.length ) {
hasFiles = true;
Expand All @@ -99,21 +99,21 @@ function createEntryFile( globPatterns, production ) {
}

// Set global license key in the `before` hook.
allFiles.unshift( path.join( __dirname, '..', 'utils', 'automated-tests', 'licensekeybefore.js' ).replace( /\\/g, '/' ) );
allFiles.unshift( upath.join( __dirname, '..', 'utils', 'automated-tests', 'licensekeybefore.js' ) );

// Inject the leak detector root hooks. Need to be split into two parts due to #598.
allFiles.splice( 0, 0, path.join( __dirname, '..', 'utils', 'automated-tests', 'leaksdetectorbefore.js' ).replace( /\\/g, '/' ) );
allFiles.push( path.join( __dirname, '..', 'utils', 'automated-tests', 'leaksdetectorafter.js' ).replace( /\\/g, '/' ) );
allFiles.splice( 0, 0, upath.join( __dirname, '..', 'utils', 'automated-tests', 'leaksdetectorbefore.js' ) );
allFiles.push( upath.join( __dirname, '..', 'utils', 'automated-tests', 'leaksdetectorafter.js' ) );

const entryFileContent = allFiles
.map( file => 'import "' + file + '";' );

// Inject the custom chai assertions. See ckeditor/ckeditor5#9668.
const assertionsDir = path.join( __dirname, '..', 'utils', 'automated-tests', 'assertions' ).replace( /\\/g, '/' );
const assertionsDir = upath.join( __dirname, '..', 'utils', 'automated-tests', 'assertions' );
const customAssertions = fs.readdirSync( assertionsDir ).map( assertionFileName => {
return [
assertionFileName,
path.parse( assertionFileName ).name.replace( /-([a-z])/g, value => value[ 1 ].toUpperCase() )
upath.parse( assertionFileName ).name.replace( /-([a-z])/g, value => value[ 1 ].toUpperCase() )
];
} );

Expand Down Expand Up @@ -209,7 +209,7 @@ function runKarma( options ) {
} );

if ( options.coverage ) {
const coveragePath = path.join( process.cwd(), 'coverage' );
const coveragePath = upath.join( process.cwd(), 'coverage' );

server.on( 'run_complete', () => {
// Use timeout to not write to the console in the middle of Karma's status.
Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-dev-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"sinon-chai": "^3.5.0",
"socket.io": "^4.0.0",
"typescript": "5.0.4",
"upath": "^2.0.1",
"webpack": "^5.94.0"
},
"devDependencies": {
Expand Down