recca0120/vscode-phpunit

UnhandledPromiseRejectionWarning: Error: spawn UNKNOWN

Closed this issue · 25 comments

setting.json

{
    "phpunit.phpunit": "${workspaceFolder}/phpunit.phar",
    "phpunit.args": [
        "--configuration ${workspaceFolder}/phpunit.xml"
    ],
}

版本資訊

PHP: 7.2.9
PHPUnit 版本: 8.1.5
PHPUnit 位置: workspace 根目錄 (phpunit.phar)
phpunit.xml 位置: workspace 根目錄

image

完整訊息

(node:12924) UnhandledPromiseRejectionWarning: Error: spawn UNKNOWN
    at ChildProcess.spawn (internal/child_process.js:357:11)
    at Object.spawn (child_process.js:540:9)
    at Promise (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:123901)
    at new Promise (<anonymous>)
    at e.Process.run (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:123813)
    at e.TestRunner.<anonymous> (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:122800)
    at Generator.next (<anonymous>)
    at o (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:121482)
(node:12924) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 30)

命令列執行正常,透過插件不行。

謝謝開發如此美觀好用的插件,可惜目前遇到此問題
尚未使用。如果能解決,那真的很感謝。

Phar 試試指定 php 路徑

謝謝回應。我再試試。

我的 command line 可以直接下 php 及 phpunit 照理說都不填應該也可以。
但不管有沒有填,或絕對路徑,還是不行。

[Trace - 7:52:08 PM] Sending request 'TestRunStartedEvent - (1)'.
Params: {
    "tests": [
        "Shieldon\\IpTraitTest::testSetIp"
    ]
}


[Trace - 7:52:08 PM] Received response 'TestRunStartedEvent - (1)' in 2ms. Request failed: Request TestRunStartedEvent failed with message: Cannot read property 'id' of undefined (-32603).

phpunit language server 回的訊息。

好想用這個插件呀 ><

最後這個訊息看起來應該是正常的啊
你先用composer require phpunit/phpunit
試著執行看看

奇怪的是,我試另一款插件是可以跑的

打勾的 "Run Test" 是該插件的功能
image

該插件的名字:

image

image

蠻奇怪的。

ps. 各種路徑設定包括 PHP 的設定都試過了,ouput 有時有訊息,但看起來是錯誤,但按很多次以後就都是空的沒反應。重啟 VSCode 後再執行會有 output,如下:

[Trace - 9:46:43 AM] Received request 'TestRunStartedEvent - (4)'.
Params: {
    "tests": [
        "Shieldon\\IpTraitTest::testSetIp"
    ],
    "events": [
        {
            "type": "test",
            "test": "Shieldon\\IpTraitTest::testSetIp",
            "state": "running"
        }
    ]
}


[Trace - 9:46:43 AM] Sending response 'TestRunStartedEvent - (4)'. Processing request took 1ms
No result returned.


[Trace - 9:46:43 AM] Received response 'TestRunStartedEvent - (2)' in 6ms.
No result returned.


(node:9072) UnhandledPromiseRejectionWarning: Error: spawn UNKNOWN
    at ChildProcess.spawn (internal/child_process.js:357:11)
    at Object.spawn (child_process.js:540:9)
    at Promise (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:123901)
    at new Promise (<anonymous>)
    at e.Process.run (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:123813)
    at e.TestRunner.<anonymous> (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:122800)
    at Generator.next (<anonymous>)
    at o (c:\Users\terry\.vscode\extensions\recca0120.vscode-phpunit-2.0.50\server\out\server.js:6:121482)
(node:9072) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:9072) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

有可能是 windows 路徑的問題 ...
這要再檢查看看了

https://github.com/terrylinooo/shieldon
那你把資料夾的路徑還有vscode的設定檔提供給我
我看能不能重現問題

好的,我有時間再多試試,有成果再來分享。

對了!方便的話,先幫我裝 1.x版的看能不能正常執行
1.x 版我是在 windows 上開發的

裝了1.x 一樣錯誤訊息。不過如果設定值留空白。

[Error - 4:25:39 PM] Request workspace/executeCommand failed.
  Message: Request workspace/executeCommand failed with message: ENOENT: no such file or directory, open 'c:\Users\terry\AppData\Local\Temp\phpunit-lsp-1558427138919.xml'
  Code: -32603 

xml 檔案不是讀 workspace 底下的。

I don't understand the previous conversation but it might be related to my issue where I'm trying to have this in my settings:

"phpunit.phpunit": "plugins/versionpress/vendor/bin/phpunit"

// or this:
"phpunit.phpunit": "${workspaceFolder}/plugins/versionpress/vendor/bin/phpunit"

but it's probably not supported – the extension always seems to try an absolute path, I'm getting errors like this:

Error: spawn /${workspaceFolder}/plugins/versionpress/vendor/bin/phpunit ENOENT

or

Error: spawn /plugins/versionpress/vendor/bin/phpunit ENOENT

@terrylinooo

settings 增加 "phpunit.logpanel": true
輸出會多增加一個 PHPUnit Test Explorer
執行完程式後把訊息提供給我一下

[2019-05-26 12:13:28.462] [INFO] Running tests ["Shieldon\\Component\\RobotTest::testSetStrict"]
[2019-05-26 12:13:42.527] [INFO] Running tests ["Shieldon\\Component\\IpTest::testInRange"]
[2019-05-26 12:14:02.427] [INFO] Running tests ["Shieldon\\Component\\IpTest::testDecimalIpv6"]
[2019-05-26 12:14:06.319] [INFO] Running tests ["Shieldon\\Component\\IpTest"]

類似這樣的訊息。

@terrylinooo 再試看看,應該至少要看到這個訊息

螢幕快照 2019-05-30 上午1 25 48

更新了新版。情況和之前的一樣。
辛苦囉。這麼晚了還沒睡。

@terrylinooo 看樣子要加個 facebook 好友私聊一下了

很歡迎加喔。不過我會發政治文喔。哈哈。還是加賴比較好 @@

@terrylinooo 換了一個方案再幫我試看看
螢幕快照 2019-06-22 上午10 50 28

好喔。感謝。晚點試試。

更新之後還是不行。連左邊列表都抓不到了

看樣子要加你了 來個 line id

看樣子要加你了 來個 line id

staroo

I also see this same error happen.

try version 3.0