phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

pathMappings configuration in launch.json not working

Open set0x opened this issue 11 months ago • 4 comments

Hi, the pathMappings configuration in launch.json not working in visual code.

When the test finished as failure it doesn't show output error and open the file with remote path.

Here is a video to show error:

  • https://youtu.be/QUo7tBs4l0s

This is my launch.json configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "xdebug",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "exclude": ["**/vendor/**/*.php"],
      "pathMappings": {
        "/var/www/html": "${workspaceRoot}"
      }
    }
  ]
}

and this is my settings

{
  "php.codeLens.enabled": false,
  "php.problems.scope": "all",
  "phpunit.command": "./vendor/bin/sail art test ${phpunitargs}"
}

If the test was successful, the extension works perfectly.

set0x avatar Mar 27 '24 12:03 set0x

Hi,

Thank you for creating the issue.

pathMapping is currently not used in the context of tests, only when debugging. But it's something we can take a look at.

May I ask you more about your setup? What is your local OS? I assume you are using docker containers, but you are not using Remote extension. So you want to develop locally but run/debug/test inside the container.

Thank you for any additional info

Miloslav avatar Mar 28 '24 14:03 Miloslav

Hi, here is my setup:

  • OS: Windows 11
  • ENV: WSL2
  • DISTRIBUTION: Ubuntu 20.04

My setup is Visual Studio Code in "WSL: Ubuntu" mode, and I would like to be able to use my "local" (WSL) configuration for development and to run both tests and debug mode on my Docker container (currently using Laravel's "sail" in multiple projects). This allows me to avoid duplicating my Visual Studio Code configurations for each remote container.

I hope I have explained myself well, I don't speak English very well.

Thanks

set0x avatar Mar 28 '24 15:03 set0x

Thank you so much for additional information.

Now, we do not match the launch profile with the testing. What we will do is find a way how to pair the profile and therefore use the pathMapping. That should do it.

I'll keep you posted.

Miloslav avatar Apr 02 '24 12:04 Miloslav

I came across this issue when checking if I can get path mapping for PHPunit tests.

I use the following setting which works well when tests pass:

    "phpunit.command": "ddev exec phpunit --teamcity",

When tests fail, it tries to open the file using the path from inside the container.

  • /var/www/html/tests/TestCase/Controller/ArticlesControllerTest.php (path in container)
  • ${workspaceFolder}/tests/TestCase/Controller/ArticlesControllerTest.php (actual path)

While reusing the value from launch.json is great, I think a seperate setting might be easier for new developer and debugging.

tyler36 avatar Jun 28 '24 02:06 tyler36