microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.47k stars 454 forks source link

ctest preset outputLogFile property handled differently between ctest and Visual Studio Code #3546

Open nhbusch opened 9 months ago

nhbusch commented 9 months ago

Brief Issue Summary

The outputLogFile preset property seems to be interpreted differently when executing tests from the command line via ctest compared to executing from Visual Studio Code. In the latter case, it seems to be interpreted relative to CMAKE_BINARY_DIR while ctest handles it relative to the location of CMakePresets.json. If, say, CMAKE_BINARY_DIR is out/build and outputLogFile is path/to/test_output.log, then running ctest from the command line will write test output to path/to/test_output.log while Visual Studio Code will output to out/build/path/to/test_output.log.

CMake Tools Diagnostics

"cmtVersion": "1.16.32",
  "configurations": [
    {
      "folder": "my_project",
      "cmakeVersion": "3.28.1",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": true,
      "compilers": {
        "C": "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe",
        "CXX": "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 8,
    "executablesCount": 5,
    "librariesCount": 3,
    "targets": [
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

No response

Additional Information

No response

gcampbell-msft commented 9 months ago

Thanks for letting us know! I've marked it as a bug and placed it on our backlog. 👍

hippo91 commented 6 months ago

@nhbusch i cannot reproduce this bug.

In one of my project is set the following presets:

  "version": 6,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 21,
    "patch": 1
  },
  "configurePresets": [
    {
      "name": "debug",
      "displayName": "GCC 5.4.0 avr",
      "description": "Using compilers: C = /usr/bin/avr-gcc, CXX = /usr/bin/avr-g++",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "cacheVariables": {
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
        "CMAKE_C_COMPILER": "/usr/bin/avr-gcc",
        "CMAKE_CXX_COMPILER": "/usr/bin/avr-g++",
        "CMAKE_BUILD_TYPE": "Debug"
      }
    }
  ],
  "testPresets": [
    {
      "name": "myTestPreset",
      "configurePreset": "debug",
      "description": "A custom test preset",
      "hidden": false,
      "output": {
        "outputLogFile": "/tmp/my_dir/myTestPreset.log"
      }
    }
  ]
}

When running the ctest from the command palette (CMake: Run Tests) the log file is created right in /tmp/my_dir/myTestPreset.log. Even when launched from the Test Explorer the log file seems to be created at the right place.

Am I missing something?

Yingzi1234 commented 6 months ago

@nhbusch Thank you for your GitHub issue! We tried to reproduce your problem based on the information you provided, but we were unable to do so, so in order to better address your issue, could you provide us with the exact steps to reproduce the problem as well as a recording of the reproduction of the problem? Thank you in advance!