vscode-phpunit
vscode-phpunit copied to clipboard
docker: invalid reference format
I'm trying to run a select test in a Docker container. My settings.json
looks like:
{
"phpunit.command": "docker run --rm -t -v ${workspaceFolder}:${workspaceFolder} -u 258006334:258000513 -e XDEBUG_MODE=develop,coverage,debug,trace -e XDEBUG_CONFIG='client_host=10.120.1.1 start_with_request=yes' -e XDEBUG_SESSION=1 -w ${workspaceFolder}/src -e COMPOSER_HOME=${workspaceFolder}/src myimage:9.9.9",
"phpunit.php": "php",
"phpunit.phpunit": "vendor/bin/phpunit",
"phpunit.args": ["--coverage-text", "--coverage-html", "coverage", "--debug"],
"phpunit.paths": {
// ${workspaceFolder} (current directory) is mounted to /app
//"${workspaceFolder}": '/app',
// ${workspaceFolder} is mapped to /app
}
}
If I initiate a debugging launch with the following from .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
The following appears in the "OUTPUT" pane, when "playing" the desired test:
docker run --rm -t -v /home/me/workspace:/home/me/workspacei -u 258006334:258000513 -e XDEBUG_MODE=develop,coverage,debug,trace -e XDEBUG_CONFIG='client_host=10.120.1.1 start_with_request=yes' -e XDEBUG_SESSION=1 -w /home/me/workspace/src -e COMPOSER_HOME=/home/me/workspace/src myimage:9.9.9 php vendor/bin/phpunit /home/me/workspace/src/tests/application/MyTest.php '--filter=^.*::(testOfSpecialInterest)( with data set .*)?$' '--coverage-text' '--coverage-html=coverage' '--debug' '--teamcity' '--colors=never'
❌ docker: invalid reference format.
See 'docker run --help'.
The curious thing is that I can copy-paste that command directly into any terminal, even VScode's integrated terminal, and it works!
Is there some strange quoting that is occurring but not appearing in the above command?
Installation Details:
PHPUnit Test Explorer: Version = v3.0.34
$ docker --version
Docker version 23.0.3, build 3e7cbfd
$ code --version
1.77.3
********
x64
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Maybe related?
- https://github.com/microsoft/vscode/issues/98471
- https://github.com/microsoft/vscode-python/issues/13264
As a possible workaround, could you make the extension honor phpunit.envVars
, like so?
{
"phpunit.command": "docker run --rm -t -v ${workspaceFolder}:${workspaceFolder} -u 258006334:258000513 -e XDEBUG_MODE -e XDEBUG_CONFIG -e XDEBUG_SESSION -w ${workspaceFolder}/src -e COMPOSER_HOME=${workspaceFolder}/src myimage:9.9.9 bash -c",
"phpunit.php": "php",
"phpunit.phpunit": "vendor/bin/phpunit",
"phpunit.args": ["--coverage-text", "--coverage-html", "coverage", "--debug"],
"phpunit.envVars": {
"XDEBUG_MODE": "develop,coverage,debug",
"XDEBUG_CONFIG": "client_host=10.120.1.1 start_with_request=yes",
"XDEBUG_SESSION": "1"
},
"phpunit.paths": {}
}
This almost works. It does not throw an error. :smile: See:
docker run --rm -t -v /home/me/workspace -u 258006334:258000513 -e XDEBUG_MODE -e XDEBUG_CONFIG -e XDEBUG_SESSION -w /home/me/workspace/src -e COMPOSER_HOME=/home/me/workspace/src myimage:9.9.9 bash -c php vendor/bin/phpunit /home/me/workspace/src/tests/application/MyTest.php '--filter=^.*::(testOfSpecificInterest( with data set .*)?$' '--coverage-text' '--coverage-html=coverage' '--debug' '--teamcity' '--colors=never'
🚀 PHPUnit 9.6.6 by Sebastian Bergmann and contributors.
MyTest
✅ testIndex 65 ms
🟨 Test 'MyTest::testOfSpecificInterest' ended
Time: 00:00.068, Memory: 22.00 MB
OK (1 test, 4 assertions)
However, it is ignoring the environment variables' values, not injecting them, so it does not stop when it hit my breakpoints. Again, I can run the same command from a terminal, where those env vars are defined like above, and it breaks appropriately.
I've had luck doing it with ini definitions instead of environment vars
"phpunit.command": "docker-compose exec -T webapp /bin/sh -c",
"phpunit.phpunit": "./vendor/bin/phpunit",
"phpunit.args": [
"-c", "./phpunit.xml",
],
"phpunit.php": "/usr/local/bin/php -d 'zend_extension=xdebug.so' -d 'xdebug.mode=debug,coverage' -d 'xdebug.client_host=host.docker.internal' -d 'xdebug.client_port=10427' -d 'xdebug.discover_client_host=1' -d 'xdebug.remote_handler=dbgp' -d 'xdebug.start_with_request=yes'",