gtest-adapter icon indicating copy to clipboard operation
gtest-adapter copied to clipboard

Does not expand ${workspaceFolder} in environment variables associated with launch targets.

Open joe-jordan opened this issue 5 years ago • 2 comments

(Platform: Ubuntu 18.04)

If you have an environment variable associated with a launch target, which contains a vs code variable:

{
  "name": "C++ Launch",
  "type": "cppdbg",
  "request": "launch",
  "program": "${workspaceFolder}/a.out",
  "args": ["arg1", "arg2"],
  "environment": [{ "name": "LD_LIBRARY_PATH", "value": "${workspaceFolder}/libs" }],
  "cwd": "${workspaceFolder}/bin"
}

then this extension will not expand the variable when refreshing the list of tests. In my project, this means a dynamic library that is part of my project fails to load, and the program crashes out unable to load its libraries, thus not listing the test and no tree view is created.

My debugging shows that the above example would see LD_LIBRARY_PATH defined literally as ${workspaceFolder}/libs, and not as an expanded path, but the "program" key will be expanded correctly.

When running the target from vscode, it does expand the variable and the program works.

(I also second #44 , which means that "cwd" is not set when listing tests, this is also important to my setup. But a PR for that already exists and can simply be merged.)

joe-jordan avatar Dec 30 '19 14:12 joe-jordan

Adding to this, Microsoft's cmake-tools (https://github.com/microsoft/vscode-cmake-tools) defines a few convenience variables for target path which is not followed (the tests panel remains empty).

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "(Windows) Launch",
			"type": "cppvsdbg",
			"request": "launch",
			"program": "${command:cmake.launchTargetDirectory}/tests.exe",
			"args": [],
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": true
		},
		{
			"name": "(Windows) Launch 2",
			"type": "cppvsdbg",
			"request": "launch",
			"program": "D:/Projects/<full-path>/build/Debug/tests.exe",
			"args": [],
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": true
		}
	]
}

Launch 2 works, but not the 1st one.

(platform : Windows 10)

kitattyor avatar Aug 28 '20 09:08 kitattyor

see Issue #56

shimpossible avatar Sep 19 '21 14:09 shimpossible