vscode-rust-test-adapter icon indicating copy to clipboard operation
vscode-rust-test-adapter copied to clipboard

Support VS Code workspace with no root-level Cargo.toml file

Open iocast opened this issue 6 years ago • 7 comments
trafficstars

Tests are not displayed when working with more then one folder inside a VS workspace.

my workspace (test.code-workspace) looks like this

{
	"folders": [
		{
			"path": "a"
		},
		{
			"path": "b"
		}
	],
	"settings": {}
}

iocast avatar Aug 12 '19 14:08 iocast

Hi there @iocast! Do you have a Cargo.toml file in the root directory that you have open in VS Code? That's a minimum requirement for the Test Explorer to work as we're entirely reliant on cargo for test discovery.

If you setup a cargo workspace with a root-level Cargo.toml file then everything should work as well.

calebcartwright avatar Aug 12 '19 15:08 calebcartwright

ahh ok i see. I normally work with VS code workspaces. Each workspace (*.code-workspace) includes different folders from different places. A folder in my case could be a rust workspace and/or lib, a js project, etc. Hence I do not have a Cargo.toml in my root folder.

iocast avatar Aug 13 '19 05:08 iocast

I think for now the easiest short term solution would be to add Cargo.toml file in your root directory, and set it up as a cargo workspace. You should be able to add a workspace member for the various projects in your VS Code workspace that are Rust projects.

I'll keep this open for now for us to do some future exploration to determine the viability of supporting a VS Code workspace that does not have a root level Cargo.toml 👍

calebcartwright avatar Aug 13 '19 16:08 calebcartwright

Hi @calebcartwright, this is important for me too, I tried symlinking a Cargo.toml file in the root folder to the one in the sub-directory, but that didn't work either. Any ideas for workarounds? I noticed this "rustTestExplorer.rootCargoManifestFilePath" configuration parameter but I tried playing around with it and also couldn't get it to work. The only way it worked, was if I opened my rust sub-directory instead of my workspace.

gabiganam avatar Dec 29 '22 10:12 gabiganam

Hi @calebcartwright, this is important for me too, I tried symlinking a Cargo.toml file in the root folder to the one in the sub-directory, but that didn't work either. Any ideas for workarounds? I noticed this "rustTestExplorer.rootCargoManifestFilePath" configuration parameter but I tried playing around with it and also couldn't get it to work. The only way it worked, was if I opened my rust sub-directory instead of my workspace.

More info in #183 but tl;dr the option doesn't fully work yet. There was a PR opened to fix it but that stalled out. If anyone has bandwidth and interest in picking that back up I'd be happy to review

calebcartwright avatar Jan 02 '23 06:01 calebcartwright

Hi @calebcartwright, this is important for me too, I tried symlinking a Cargo.toml file in the root folder to the one in the sub-directory, but that didn't work either. Any ideas for workarounds? I noticed this "rustTestExplorer.rootCargoManifestFilePath" configuration parameter but I tried playing around with it and also couldn't get it to work. The only way it worked, was if I opened my rust sub-directory instead of my workspace.

More info in #183 but tl;dr the option doesn't fully work yet. There was a PR opened to fix it but that stalled out. If anyone has bandwidth and interest in picking that back up I'd be happy to review

I read the conversation in that PR, and unfortunately I don't have the bandwidth or TS expertise to implement it properly (although I have the interest 😄). I wonder if it's not better to have it working "quick and ugly" as the PR seems to be, than the current situation where the extension is useless to anyone working in a multi-folder environment.

gabiganam avatar Jan 18 '23 06:01 gabiganam

I wonder if it's not better to have it working "quick and ugly" as the PR seems to be, than the current situation where the extension is useless to anyone working in a multi-folder environment.

So I don't view this as a case of prioritizing perfection over pace. There's still a few things that'd have to be addressed for the current PR to be able to be merged, e.g. documentation as I'd mentioned back in https://github.com/swellaby/vscode-rust-test-adapter/pull/186#issuecomment-1052313922.

If someone was willing to grab the commits from that PR and address some of these items (documentation, remove the lockfile changes, maybe add a test or two, etc.) then I could help get that landed and released. However, at the moment this is still sufficiently blocked

calebcartwright avatar Jan 20 '23 01:01 calebcartwright