Ckeditor5: Unable to run tests in development Environment on Windows.

Created on 22 Nov 2017  ·  16Comments  ·  Source: ckeditor/ckeditor5

🐞 Is this a bug report or feature request? (choose one)

  • Bug report

💻 Version of CKEditor

CKEditor 5

📋 Steps to reproduce

  1. Follow the instructions here
  2. Execute npm run test -- --files=core

✅ Expected result

Tests run

❎ Actual result

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1

2017-11-22T12_27_22_823Z-debug.log

I am running in a standard Windows 10 Command Shell with Admin privileges.

bug

Most helpful comment

Ok, I found the problem.

When we we call npm t, npm will execute this command:

node --max_old_space_size=4096 ./node_modules/.bin/ckeditor5-dev-tests

There are differences between running npm scripts on Windows and Unix systems.

Unix

I've checked what contains file in the specified path:

cat ./node_modules/.bin/ckeditor5-dev-tests | head -n 15

#!/usr/bin/env node

/**
 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const chalk = require( 'chalk' );
const tests = require( '../lib/index' );

const cwd = process.cwd();
const options = tests.parseArguments( process.argv.slice( 2 ) );

It looks like a content from file which should be executed. So it looks good. Just to be sure, I've checked whether the ckeditor5-dev-tests is a file or a symlink to real file:

ls -la ./node_modules/.bin/ | grep ckeditor5-dev-tests

lrwxr-xr-x    1 pomek  staff     44 Nov 13 14:08 ckeditor5-dev-tests -> ../@ckeditor/ckeditor5-dev-tests/bin/test.js
# More "ckeditor5-dev-tests" scripts...

Conclusion – on Unix system, npm run [command] calls a symlink which is a valid script.

Windows

Let's start the same way as Unix (checking content of the executed file):

cat ./node_modules/.bin/ckeditor5-dev-tests | head -n 15

#!/bin/sh

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../@ckeditor/ckeditor5-dev-tests/bin/test.js" "$@"
  ret=$?
else
  node  "$basedir/../@ckeditor/ckeditor5-dev-tests/bin/test.js" "$@"
  ret=$?
fi

Oops. There is a bash script. It cannot be executed by node directly because node won't understand what we want to do. Error:

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list

confirms that.

At this moment, the easiest solution to execute the test – call bin script directly from command line:

node_modules/.bin/ckeditor5-dev-tests --files=core

or execute the real file which is called by the bash script:

node --max_old_space_size=4096 node_modules/@ckeditor/ckeditor5-dev-tests/bin/test.js --files=core

It should work.

But… Thanks for your ticket, I found another issue in our Webpack config (https://github.com/ckeditor/ckeditor5-dev/issues/323). A temporary solution also is available here so please follow the link. I'm working on fixing those problems.

All 16 comments

(I'm sure I'm making a rookie error. I've previously set up a build successfully on Ubuntu, but my main dev rig is a Windows machine - any help welcome; this is definitely in the "I'm sure it's me not you" category)

Thanks for the report.

I will try to reproduce the issue on a virtual machine. I will let you know if I will find out more details.

I've checked it on the real machine with Windows 10 and I can confirm this issue.

Ok, I found the problem.

When we we call npm t, npm will execute this command:

node --max_old_space_size=4096 ./node_modules/.bin/ckeditor5-dev-tests

There are differences between running npm scripts on Windows and Unix systems.

Unix

I've checked what contains file in the specified path:

cat ./node_modules/.bin/ckeditor5-dev-tests | head -n 15

#!/usr/bin/env node

/**
 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const chalk = require( 'chalk' );
const tests = require( '../lib/index' );

const cwd = process.cwd();
const options = tests.parseArguments( process.argv.slice( 2 ) );

It looks like a content from file which should be executed. So it looks good. Just to be sure, I've checked whether the ckeditor5-dev-tests is a file or a symlink to real file:

ls -la ./node_modules/.bin/ | grep ckeditor5-dev-tests

lrwxr-xr-x    1 pomek  staff     44 Nov 13 14:08 ckeditor5-dev-tests -> ../@ckeditor/ckeditor5-dev-tests/bin/test.js
# More "ckeditor5-dev-tests" scripts...

Conclusion – on Unix system, npm run [command] calls a symlink which is a valid script.

Windows

Let's start the same way as Unix (checking content of the executed file):

cat ./node_modules/.bin/ckeditor5-dev-tests | head -n 15

#!/bin/sh

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../@ckeditor/ckeditor5-dev-tests/bin/test.js" "$@"
  ret=$?
else
  node  "$basedir/../@ckeditor/ckeditor5-dev-tests/bin/test.js" "$@"
  ret=$?
fi

Oops. There is a bash script. It cannot be executed by node directly because node won't understand what we want to do. Error:

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list

confirms that.

At this moment, the easiest solution to execute the test – call bin script directly from command line:

node_modules/.bin/ckeditor5-dev-tests --files=core

or execute the real file which is called by the bash script:

node --max_old_space_size=4096 node_modules/@ckeditor/ckeditor5-dev-tests/bin/test.js --files=core

It should work.

But… Thanks for your ticket, I found another issue in our Webpack config (https://github.com/ckeditor/ckeditor5-dev/issues/323). A temporary solution also is available here so please follow the link. I'm working on fixing those problems.

@mwadams, @Mgsy, I've just pushed branch t/686 which contains changes related to Windows environments.

Automated tests should work fine, manual tests are waiting for ~fix~ merge https://github.com/ckeditor/ckeditor5-dev/pull/326.

@Mgsy confirms that tests start and work.

However, some of the tests can fail because Webpack cannot load SVG. We fixed it (https://github.com/ckeditor/ckeditor5-dev/issues/323) but we didn't publish the changes on NPM yet.

https://github.com/ckeditor/ckeditor5-dev/pull/326 has been merged. When the latest changes will be published, I'll make a PR which allows testing on Windows from the main branch.

The latest version of @ckeditor/ckeditor5-dev-tests has been released. If you want, you can see what has changed in the changelog.

Excellent. Looks promising.

Can this ticket be closed now?

Until an assortment of PRs have landed, you still can't pull master and build in Windows, so it feels like it should track those to completion.

As @mwadams mentioned, we need to merge https://github.com/ckeditor/ckeditor5/pull/689.

It now gets as far as running the tests, but I get an error when running after it has launched the karma page in the browser.

Is this a) related or b) unrelated, and if unrelated should I open a new item or is this something obviously wrong with my local setup? It looks like a permissions problem judging by the log.

2017-12-12T11_36_32_343Z-debug.log

@mwadams thanks for the info, I'll investigate this.

I helped @szymonkups figured out what happened.

My Windows 10 environment:

IEUser@MSEDGEWIN10 MINGW64 ~/Desktop/CKSource/ckeditor5-dev (master)
$ node -v
v8.9.1

IEUser@MSEDGEWIN10 MINGW64 ~/Desktop/CKSource/ckeditor5-dev (master)
$ npm -v
4.6.1

After first calling npm t -- --files=core, I've got a lot of errors which look like:

ERROR in ./packages/ckeditor5-ui/src/tooltip/tooltipview.js
Module not found: Error: Can't resolve 'postcss-loader' in 'C:\Users\IEUser\Desktop\CKSource\ckeditor5'

I called lerna bootstrap from the main (ckeditor/ckeditor5) repo once again. I received another error:

ERROR in ./node_modules/postcss-loader/lib?{"plugins":[null,null,null,null,null,{"version":"5.2.18","plugins":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"postcssPlugin":"cssnano","postcssVersion":"5.2.18"}]}!./packages/ckeditor5-ui/theme/components/inputtext/inputtext.css
Module build failed: SyntaxError: Invalid regular expression: /ckeditor5-[^\]+/: Unterminated character class

Which leads to a new ticket – https://github.com/ckeditor/ckeditor5-dev/issues/343.

@mwadams Could you confirm that this is the same thing that occurs on your machine? From logs you provided it seems that tests are not started at all but from your previous comment I assume that tests are starting. Could you pleas clarify? Thanks.

Was this page helpful?
0 / 5 - 0 ratings