DavidSchuldenfrei/gtest-adapter

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

Opened this issue · 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.)

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)

see Issue #56