vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

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

Open nhbusch opened this issue 2 years ago • 2 comments

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

nhbusch avatar Jan 22 '24 15:01 nhbusch

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

gcampbell-msft avatar Jan 26 '24 14:01 gcampbell-msft

@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?

hippo91 avatar May 09 '24 14:05 hippo91

@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!

Yingzi1234 avatar May 17 '24 02:05 Yingzi1234