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

Error spawn tests on windows 10 Pro #309

Closed
dimaslanjaka opened this issue May 14, 2023 · 3 comments
Closed

Error spawn tests on windows 10 Pro #309

dimaslanjaka opened this issue May 14, 2023 · 3 comments

Comments

@dimaslanjaka
Copy link
Contributor

dimaslanjaka commented May 14, 2023

error like below screenshot

5 failing

  1) spawn
       default:
     Error: C:\cygwin64\bin\type: line 2: type: D:\Repositories\hexo\packages\hexo-util\test\spawn_test.txt: not found

      at ChildProcess.<anonymous> (lib\spawn.ts:43:19)
      at ChildProcess.emit (domain.js:475:12)
      at ChildProcess.cp.emit (node_modules\cross-spawn\dist\lib\enoent.js:35:29)
      at maybeClose (internal/child_process.js:1088:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)

  2) spawn
       default - string:
     Error: C:\cygwin64\bin\type: line 2: type: D:\Repositories\hexo\packages\hexo-util\test\spawn_test.txt: not found

      at ChildProcess.<anonymous> (lib\spawn.ts:43:19)
      at ChildProcess.emit (domain.js:475:12)
      at ChildProcess.cp.emit (node_modules\cross-spawn\dist\lib\enoent.js:35:29)
      at maybeClose (internal/child_process.js:1088:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)

  3) spawn
       error:

      AssertionError: expected promise to be rejected with an error including 'spawn type ENOENT' 
but got 'C:\cygwin64\bin\type: line 2: type: n…'
      + expected - actual

      -C:\cygwin64\bin\type: line 2: type: nothing: not found
      +spawn type ENOENT



  4) spawn
       custom encoding:
     Error: 433a5c63796777696e36345c62696e5c747970653a206c696e6520323a20747970653a20443a5c5265706f7369746f726965735c6865786f5c7061636b616765735c6865786f2d7574696c5c746573745c737061776e5f746573742e7478743a206e6f7420666f756e640a
      at ChildProcess.<anonymous> (lib\spawn.ts:43:19)
      at ChildProcess.emit (domain.js:475:12)
      at ChildProcess.cp.emit (node_modules\cross-spawn\dist\lib\enoent.js:35:29)
      at maybeClose (internal/child_process.js:1088:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)

  5) spawn
       encoding = null:
     Error: C:\cygwin64\bin\type: line 2: type: D:\Repositories\hexo\packages\hexo-util\test\spawn_test.txt: not found

      at ChildProcess.<anonymous> (lib\spawn.ts:43:19)
      at ChildProcess.emit (domain.js:475:12)
      at ChildProcess.cp.emit (node_modules\cross-spawn\dist\lib\enoent.js:35:29)
      at maybeClose (internal/child_process.js:1088:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)



npm ERR! Lifecycle script `test` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: hexo-util@3.0.1
npm ERR!   at location: D:\Repositories\hexo\packages\hexo-util

image

but succesfull in CI https://github.com/dimaslanjaka/hexo-util/actions
image

@stevenjoezhang
Copy link
Member

In the Windows Command shell, type is a built-in command which displays the contents of a text file. In your shell, it is overridden by C:\cygwin64\bin\type which is incorrect.

@uiolee
Copy link
Member

uiolee commented Oct 18, 2023

I am using git-bash on windows 10, everything works well

@dimaslanjaka
Copy link
Contributor Author

dimaslanjaka commented Oct 19, 2023

fixed by creating custom bash script and run it under cygwin bash.

  • save below script with custom filename (let says bin/runtest)
#!/usr/bin/env bash

# put these on top of file

(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix

# absolute path working directory
basecwd=${PWD}
# base script directory
basedir=`dirname "$0"`
# absolute path script directory
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
# get script path
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

case `uname` in
  *CYGWIN*)
    basedir=`cygpath -w "$basedir"`
    # make cygwin bin as priority
    export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH"
    ;;
esac

# parse and export .env file (dotenv)
if [ -f ".env" ]; then
  # Export the vars in .env into your shell:
  export $(egrep -v '^#' .env | xargs)
fi

npm run test
  • open windows cmd terminal
  • type bash (it will open bash in windows cmd terminal)
  • run the script bash bin/runtest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants