recca0120 / vscode-phpunit

The VS Code Test Explorer extension for PHPUnit
MIT License
129 stars 44 forks source link

${workspaceFolder} appears to not be correctly mapping. #206

Open mrenyard opened 1 week ago

mrenyard commented 1 week ago

When using ${workspaceFolder} in settings.json it looks to be equating to "/ ./" even when set within settings.json, meaning that the below setting prepend "/ ./" to the paths for phpunit and our arguments, produce the following command:

php /./tools/phpunit.phar --configuration=/./tools/phpunit.xml --colors=never --teamcity

While "./" makes sense, as presumably we are running from within the ${workspaceFolder} the proceeding "/ " would look to be superfluous.

{
  "phpunit.php": "php",
  "phpunit.phpunit" : "${workspaceFolder}/tools/phpunit.phar",
  "phpunit.args": [

    "-c",
    "${workspaceFolder}/tools/phpunit.xml"
  ],
  "editor.tabSize": 2,
  "phpunit.paths": {

    "${workspaceFolder}": "/home/mrenyard/Projects/RAMP"
  },
}

I really appreciate all that you are doing with the extension as it is by the far the most important and useful tool in my development lifecycle.

ili101 commented 1 week ago

Looks like we came to the same conclusion (: https://github.com/recca0120/vscode-phpunit/issues/205#issuecomment-2486574157

mrenyard commented 1 week ago

@recca0120 FYI This is still an issues with the latest update v3.4.9 Many thanks for the work. M.

recca0120 commented 6 days ago

@mrenyard where do you run the command ? docker or local ? paths replace only for docker, ssh and ${workspaceFolder} in vscode, usually point to vscode project tool

mrenyard commented 6 days ago

@recca0120 It's run locally under WSL (ubuntu linux). I have a 'tools' folder which contains: phpunit.phar and phpunit.xml, etc.

FYI. I' am also not getting all the test showing in the 'left; panel' under Testing. Occasionally it picks up on an open fileTest.php in the main editor. I have had to set all my paths to full qualified paths in both vscode/setting.json and under tools/phpunit.xml as below for the time being to get anything working.

.vscode/settings.json

{
  "phpunit.php": "php",
  "phpunit.phpunit" : "/home/mrenyard/Projects/RAMP/tools/phpunit.phar",
  "phpunit.args": [
    "-c",
    "/home/mrenyard/Projects/RAMP/tools/phpunit.xml"
  ],
  "phpunit.paths": {
    "${workspaceFolder}" : "/home/mrenyard/Projects/RAMP"
  }
}

tools/phpunit.phar tools/phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
  cacheDirectory=".phpunit.cache"
  executionOrder="depends,defects"
  requireCoverageMetadata="false"
  beStrictAboutCoverageMetadata="true"
  beStrictAboutOutputDuringTests="true"
  displayDetailsOnPhpunitDeprecations="true"
  displayDetailsOnTestsThatTriggerDeprecations="true"
  displayDetailsOnTestsThatTriggerErrors="true"
  displayDetailsOnTestsThatTriggerNotices="true"
  displayDetailsOnTestsThatTriggerWarnings="true"
  failOnPhpunitDeprecation="true"
  failOnRisky="true"
  failOnWarning="true"
  >
  <testsuites>
    <testsuite name="default">
      <directory suffix="Test.php">/home/mrenyard/Projects/RAMP/tests</directory>
    </testsuite>
  </testsuites>
  <source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
    <include>
      <directory suffix=".class.php">/home/mrenyard/Projects/RAMP/code</directory>
    </include>
  </source>
  <coverage>
    <report>
      <html
        outputDirectory="/home/mrenyard/Code/Documentation/coverage/"
        lowUpperBound="50"
        highLowerBound="90"
        customCssFile="/home/mrenyard/Projects/RAMP/tools/custom.css" />
    </report>
  </coverage>
</phpunit>

It's really seams kind of odd that it look to run from "/ ./" (forward-slash|space|dot|forward-slash) whenever I use a relative path with or without ${workspaceFolder} .

recca0120 commented 6 days ago

@mrenyard Is vscode under WSL too ? I need more information to reproduce this issue

mrenyard commented 6 days ago

No windows 10

recca0120 commented 6 days ago

PHP under WSL, but VSCode under windows 10 ?

ili101 commented 6 days ago

If it helps in the example from my issue https://github.com/recca0120/vscode-phpunit/issues/205#issuecomment-2486574157 I run in devcontainer (local Windows 11 to remote Debian 12 docker).

JonathanGawrych commented 6 days ago

We are experiencing the same issue. We are on macOS Sonoma (M3 chips). Currently we are working around it by hardcoding the full path. Since we are using docker compose, we have to hardcode the path to docker-compose.yml too:

"phpunit.command": "docker compose -f /Volumes/code/work/GoREACT/docker-compose.yml exec v2 /bin/sh -c",
"phpunit.paths": {
    "/Volumes/code/work/GoREACT/goreact-api-v2": "/www/goreactv2/"
},
recca0120 commented 3 days ago

3.4.10 fix this bug and you can set custom variables by yourself

{
     "php": "${bin}/php",
     "phpunit.paths": {
         "${bin}": "/usr/local/bin"
     }
}