Code Monkey home page Code Monkey logo

Comments (23)

tyler36 avatar tyler36 commented on July 18, 2024 1

@renandelmonico created new issue since my seems to be related to config file #5

from vscode-phpunit.

tyler36 avatar tyler36 commented on July 18, 2024 1

now for some reason the extension is trying to call phpunit with the -c flag, trying to load a configuration from the wrong path. Solution: create an option to specify to not use the -c flag or provide the configuration path

This is the same issue as #5

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

If you add a double non-quoted backslash ( \ ) in filepath the command works?

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

If you add a double non-quoted backslash ( \ ) in filepath the command works?

Nope, it does not work. I tried all escapes I could think of, I don't know why it is escaping the wrong slash at all 😅

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

If you add a double non-quoted backslash ( \ ) in filepath the command works?

Nope, it does not work. I tried all escapes I could think of, I don't know why it is escaping the wrong slash at all sweat_smile

Another test: if you change "" to "/" in "project\tests\Feature\Main\AuthTest.php" and run, it works? I think it's escaping because the docker environment is linux-based and the backslash is the escape caracter in linux. How windows uses backslack by default I think the linux container considers the backslash as escape caracter.

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

It still does not work as intended. I will show more screenshots, showing all the configuration options as requested, the wrong outputs and the correct expected behaviour, all from WSL, invoking the docker command.

Configs

config-1
config-2
config-3

Wrong output from plugin

wrong-output-in-windows

Wrong output from WSL because the paths are incorrect

first-test-inside-wsl-correct-call-wrong-path

Working in WSL after fixing paths

working-in-wsl-with-correct-path

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

In Linux, vscode doesn't recognize some env variables, like docker. According with your screenshots I think you should specify the full path of docker binary file. Can you test that configuration in "Docker Image" property? I don't know the filepath for docker bin in windows, but in Linux is /usr/bin/docker. If works, I'll update the README.md. In my vscode, the config is like this:

image

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

In Linux, vscode doesn't recognize some env variables, like docker. According with your screenshots I think you should specify the full path of docker binary file. Can you test that configuration in "Docker Image" property? I don't know the filepath for docker bin in windows, but in Linux is /usr/bin/docker. If works, I'll update the README.md. In my vscode, the config is like this:

image

Docker in Windows 10 is using Docker Desktop and so the docker binary is availble directly. I tried it using both methods calling directly from Powershell. It works, but spawn refuses to output the correct paths 🤷‍♂️
trying-to-run-wsl-command
from-powershell

from vscode-phpunit.

tyler36 avatar tyler36 commented on July 18, 2024

I'm having a similar problem that might be related.

I get an output error:

spawn docker exec -it d110561 bash -c "var/www/html/vendor/bin/phpunit -c /home/user13/code/laravel/test123/phpunit.xml" ENOENT

I can run the following from the terminal without an issue:

docker exec -it d110561 bash -c /var/www/html/vendor/bin/phpunit
docker exec -it d110561 bash -c /var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml

For me, the issue seems to be the injection of the config file path:

  • -c /home/user13/code/laravel/test123/phpunit.xml is my WSL project path
  • -c /var/www/html/phpunit.xml

Vscode config:

    "phpunit.relativeFilePath": true,
    "phpunit.phpunit": "/var/www/html/vendor/bin/phpunit",
    "phpunit.docker": true,
    "phpunit.dockerImage": "docker exec -it d110561",

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

I am not familiar with VSCode extension development so I couldn't debug it, but reading the code the issue must be how the paths are being called in line 183.

image

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

What is the base image in your projects? I had a similar problem in one of my projects because de base image entrypoint is different from the php official image. What i did? I added --entrypoint="" in phpunit.dockerImage config.

PS: I don't know what the problem it yet

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

I am using Laradock, https://laradock.io/

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

I'm having a similar problem that might be related.

I get an output error:

spawn docker exec -it d110561 bash -c "var/www/html/vendor/bin/phpunit -c /home/user13/code/laravel/test123/phpunit.xml" ENOENT

I can run the following from the terminal without an issue:

docker exec -it d110561 bash -c /var/www/html/vendor/bin/phpunit
docker exec -it d110561 bash -c /var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml

For me, the issue seems to be the injection of the config file path:

  • -c /home/user13/code/laravel/test123/phpunit.xml is my WSL project path
  • -c /var/www/html/phpunit.xml

Vscode config:

    "phpunit.relativeFilePath": true,
    "phpunit.phpunit": "/var/www/html/vendor/bin/phpunit",
    "phpunit.docker": true,
    "phpunit.dockerImage": "docker exec -it d110561",

Are you tried to run the command in your terminal (with double quotes)? According with you comment above I think you tried to run the command without double quotes.

docker exec -it d110561 bash -c "var/www/html/vendor/bin/phpunit -c /home/user13/code/laravel/test123/phpunit.xml"

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

In Linux, vscode doesn't recognize some env variables, like docker. According with your screenshots I think you should specify the full path of docker binary file. Can you test that configuration in "Docker Image" property? I don't know the filepath for docker bin in windows, but in Linux is /usr/bin/docker. If works, I'll update the README.md. In my vscode, the config is like this:
image

Docker in Windows 10 is using Docker Desktop and so the docker binary is availble directly. I tried it using both methods calling directly from Powershell. It works, but spawn refuses to output the correct paths man_shrugging trying-to-run-wsl-command from-powershell

Yes, in linux the docker binary is available directly too, but in vscode environment the bash doesn't have some binary available directly so I specified the docker path manualy in my config. If you didn't try to put in your config the docker path, my sugestion is try 😆

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

In Linux, vscode doesn't recognize some env variables, like docker. According with your screenshots I think you should specify the full path of docker binary file. Can you test that configuration in "Docker Image" property? I don't know the filepath for docker bin in windows, but in Linux is /usr/bin/docker. If works, I'll update the README.md. In my vscode, the config is like this:
image

Docker in Windows 10 is using Docker Desktop and so the docker binary is availble directly. I tried it using both methods calling directly from Powershell. It works, but spawn refuses to output the correct paths man_shrugging trying-to-run-wsl-command from-powershell

Yes, in linux the docker binary is available directly too, but in vscode environment the bash doesn't have some binary available directly so I specified the docker path manualy in my config. If you didn't try to put in your config the docker path, my sugestion is try 😆

now that you mention it, Docker Desktop seems to be the one making the docker command available in Windows. I can't seem to find how to call it directly. I will do some research

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

In Linux, vscode doesn't recognize some env variables, like docker. According with your screenshots I think you should specify the full path of docker binary file. Can you test that configuration in "Docker Image" property? I don't know the filepath for docker bin in windows, but in Linux is /usr/bin/docker. If works, I'll update the README.md. In my vscode, the config is like this:
image

Docker in Windows 10 is using Docker Desktop and so the docker binary is availble directly. I tried it using both methods calling directly from Powershell. It works, but spawn refuses to output the correct paths man_shrugging trying-to-run-wsl-command from-powershell

Yes, in linux the docker binary is available directly too, but in vscode environment the bash doesn't have some binary available directly so I specified the docker path manualy in my config. If you didn't try to put in your config the docker path, my sugestion is try laughing

now that you mention it, Docker Desktop seems to be the one making the docker command available in Windows. I can't seem to find how to call it directly. I will do some research

Nice! Keep me informed about this, please! 😄 If have a trouble on extension I'll try to fix it when possible.

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

As a curiosity, the absolute path to call docker from Docker Desktop on Windows is 'C:\Program Files\Docker\Docker\resources\bin\docker.exe' 😉

Anyway, I tried to simplify the variables. I now changed WSL setup to use relative Linux paths instead of the Windows mount points, and I am so close to make it work, but it is missing a couple things:

  • The setup involves calling code . from inside WSL, to it uses the remote extension and I need to install the extension again inside WSL. It is a workaround but seems to be working fine
  • now for some reason the extension is trying to call phpunit with the -c flag, trying to load a configuration from the wrong path. Solution: create an option to specify to not use the -c flag or provide the configuration path
  • unfortunately using the relative path option does not use the project folder. Solution: create an option to specify the project folder, so the test files can be relative correctly.

In this case, mdl is a Laravel project. PHPUnit on Laravel is called from the \vendor folder, but the tests are in the project itself. So you can see why the paths can't be always infered, but should be provided by the developer. The way Laradock works is providing the workspace image, that contains the PHP executable and is aware of the relative paths.

Again, I provide the new screenshots from this approach. I think with a couple of options and strings adjustments, we can finally make it work inside WSL 🙌

Settings panel

settings-1
settings-2

Extension output

output from extension trying to call with config

Adjusting the command in WSL from Windows Terminal. It works there

correct way to call phpunit

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

As a curiosity, the absolute path to call docker from Docker Desktop on Windows is 'C:\Program Files\Docker\Docker\resources\bin\docker.exe' wink

Anyway, I tried to simplify the variables. I now changed WSL setup to use relative Linux paths instead of the Windows mount points, and I am so close to make it work, but it is missing a couple things:

  • The setup involves calling code . from inside WSL, to it uses the remote extension and I need to install the extension again inside WSL. It is a workaround but seems to be working fine
  • now for some reason the extension is trying to call phpunit with the -c flag, trying to load a configuration from the wrong path. Solution: create an option to specify to not use the -c flag or provide the configuration path
  • unfortunately using the relative path option does not use the project folder. Solution: create an option to specify the project folder, so the test files can be relative correctly.

In this case, mdl is a Laravel project. PHPUnit on Laravel is called from the \vendor folder, but the tests are in the project itself. So you can see why the paths can't be always infered, but should be provided by the developer. The way Laradock works is providing the workspace image, that contains the PHP executable and is aware of the relative paths.

Again, I provide the new screenshots from this approach. I think with a couple of options and strings adjustments, we can finally make it work inside WSL raised_hands

Settings panel

settings-1 settings-2

Extension output

output from extension trying to call with config

Adjusting the command in WSL from Windows Terminal. It works there

correct way to call phpunit

Interesting... First of all we need check if the docker env is available in your vscode. Please, could you check if the command above works?

C:\Program Files\Docker\Docker\resources\bin\docker.exe exec -it laradock-workspace-1 blablabla

The second point is the issue #5, I think. And the last one create the config to specify the project folder. Are you agree?

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

Interesting... First of all we need check if the docker env is available in your vscode. Please, could you check if the command above works?

C:\Program Files\Docker\Docker\resources\bin\docker.exe exec -it laradock-workspace-1 blablabla

Changing the command. Output:
image

The second point is the issue #5, I think. And the last one create the config to specify the project folder. Are you agree?

Yes, I agree

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

Interesting... First of all we need check if the docker env is available in your vscode. Please, could you check if the command above works?

C:\Program Files\Docker\Docker\resources\bin\docker.exe exec -it laradock-workspace-1 blablabla

Changing the command. Output: image

The second point is the issue #5, I think. And the last one create the config to specify the project folder. Are you agree?

Yes, I agree

I'll need for help from someone who run vscode with WSL because this problem looks like a specific windows bug 😢

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

I will do more tests. Now that VScode updated as well, I will try again. I noticed I wasn't trying inside the WSL container, I was using the docker directly trying to access stuff in the Windows side. I will setup it in another way and report my findings. I use both Windows and Linux on my work, so I can test the different behaviours.

Thank you for looking on the matter so far. I will get the updated version and give another shot 🙌

from vscode-phpunit.

weidmaster avatar weidmaster commented on July 18, 2024

@renandelmonico I tried new tests. Now I am using docker inside a proper WSL container, inside VSCode. The path errors were due to execute VScode from Windows instead of WSL container. Now, the outputs of the commands are exactly the same, and it still does not work. Any ideas? 🤔


image

from vscode-phpunit.

renandelmonico avatar renandelmonico commented on July 18, 2024

Sorry for the late response. The main project has been updated. I think we should try it because there are more features. :D

from vscode-phpunit.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.