Closed Xachman closed 1 year ago
This issue is because on my system it needs to be a file. I made a docker-phpunit.sh file:
#!/bin/bash
docker-compose run --rm app /var/www/html/vendor/bin/phpunit $@
and made changes to the settings.json
{
"phpunit.phpunit": "/path/to/file/docker-phpunit.sh",
"phpunit.args": ["--configuration", "/var/www/html/phpunit.xml"],
"phpunit.relativeFilePath": true
}
This works in general but now I get the error every once and a while.
(node:6089) UnhandledPromiseRejectionWarning: Error: Unhandled method TestRetryEvent-0e1f51777fd53e8d4de77095197d3029
at /home/user/.vscode/extensions/recca0120.vscode-phpunit-2.0.76/server/out/server.js:1:9133
at /home/user/.vscode/extensions/recca0120.vscode-phpunit-2.0.76/server/out/server.js:1:9427
at Immediate.<anonymous> (/home/user/.vscode/extensions/recca0120.vscode-phpunit-2.0.76/server/out/server.js:1:9788)
at processImmediate (internal/timers.js:439:21)
(node:6089) 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: 25)
https://github.com/recca0120/vscode-phpunit/issues/33 may be related
It's happening for me too, I get this error after running all the tests succesfully, then trying to run the tests again returns the error above.
Just started using this tool. I'm running against a docker-compose container sitting on a Debian box, which I'm connecting to using the inbuilt vscode SSH bridge (Remote-SSH). I'm experiencing the same issues as described.
I've set up my fields a little differently.
"phpunit.relativeFilePath": true,
"phpunit.php": "/usr/bin/docker exec my_container php",
"phpunit.phpunit": "/var/www/html/vendor/bin/phpunit",
"phpunit.shell": "/bin/bash",
The tests run fine as long as there's no failures, but as soon as there are the module crashes out and can't be recovered without a restart of the SSH connection.
I get the same error message as @Xachman.
(node:5145) UnhandledPromiseRejectionWarning: Error: Unhandled method TestRunStartedEvent-0199eba5e9da448952078e8954b366f9
at /home/me/.vscode-server/extensions/recca0120.vscode-phpunit-2.0.76/server/out/server.js:1:9133
at /home/me/.vscode-server/extensions/recca0120.vscode-phpunit-2.0.76/server/out/server.js:1:9427
at Immediate.<anonymous> (/home/me/.vscode-server/extensions/recca0120.vscode-phpunit-2.0.76/server/out/server.js:1:9788)
at processImmediate (internal/timers.js:439:21)
(node:5145) 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: 12)
Same problem here. I get a UnhandledPromiseRejectionWarning
if a test fails and then I need to restart vscode.
@perebusquets, @enricodias Please don't (ever) just comment "same here" — +1 the issue instead. Only post if you have valuable information to add to the discussion.
Also, you don't need to restart vscode, restarting the extension host (Ctrl+Shift+P, "Developer: Restart Extension Host") is enough.
@antichris It was intentional to show that this issue is still relevant almost a year after the last reply. Having to restart the extension host is pretty much the same hassle as having to restart vscode itself, at least for me.
It was intentional to show that this issue is still relevant almost a year after the last reply
Successful deflection is successful.
Although I'd speculate, had you thought about it that way at that particular moment, you'd probably written it like "hey, this is still happening, it's very annoying/frustrating, is there a fix coming?" (or something along the lines).
Also I was surprised at first how you managed to get "almost a year" from November 13 to May 21 (6 months 8 days), but that, although appears to shed light on your tendency to stick to the facts, is not very pertinent to the discussion.
What matters is that I do agree — having to restart anything every single flipping time a test fails is extremely frustrating and renders this extension practically useless, considering how tests have to be written to fail first, before enough code has been written (or changed) for them to start passing. We need a fix for this.
It appears that problem that happens when a test fails seems to be caused by the file paths reported by phpunit, they differ between the container and the host machine. It works when no tests fail because the extension doesn't need to open any file in that case.
As a workaround, I'm using sed
to replace the paths reported by phpunit with the path used in the host machine:
#!/bin/bash
docker-compose exec -T DOCKER_IMAGE bin/phpunit ${@:2} | sed "s|\./|HOST_PATH|g"
Replace DOCKER_IMAGE
and HOST_PATH
with your own.
@enricodias I can confirm that this will in fact fix the issue. I had to make some adjustments to your script in my case this worked.
#!/bin/bash
docker-compose exec -T DOCKER_IMAGE bin/phpunit $@ | sed "s|/path/in/container|/path/on/host|g"
I can finally use this extension again! I appreciate all the time you put into figuring out this issue!
Thanks @Xachman. Your comments helped me to make this extension finally work 👍
I used your settings.json
{
"phpunit.phpunit": "/path/to/file/docker-phpunit.sh",
"phpunit.args": ["--configuration", "/var/www/html/phpunit.xml"],
"phpunit.relativeFilePath": true
}
Here is my bash script - I used docker exec
where app
is container name
#!/bin/bash
docker exec \
--workdir="/var/www/api/" \
app \
php ./vendor/bin/phpunit "$@" \
| sed "s|/var/www/api|$HOME/Projects/api|g"
For anyone having issues setting this up make sure to restart vscode if extension throws any error while you tweak bash script and re-try running tests. I had weird issue where tests would pass but it would never mark them as passed. At the same time extension worked for failed tests and it showed the error in the code. Only restart helped
I was debugging issues with following settings.json
{
"phpunit.showAfterExecution": "always",
"phpunit.logpanel": true,
"phpunit.trace.server": "verbose",
}
I wanted to post a quick update
Even though I have this extension working with the setup above I decided to use remote containers approach
I already have php docker container running as part of my docker-compose
so I used Open an existing folder in a container
I've added list of extensions that will be automatically installed in any new remote container in my global settings.json
"remote.containers.defaultExtensions": [
....
]
After setting and installing extensions everything works out of the box without any hacks. I also don't have to do similar hacks/updates for other vscode extensions
Since I use some terminal CLI apps I also found how to start host terminal:
Terminal: Create New Integrated Terminal
will open a terminal window within a container.Terminal: Create New Integrated Terminal (Local)
will open a terminal on your host machine.
Thanks for all the help!
try version 3.0
if I add:
Config options and try to run the tests I get back.