Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests duplicated in Test Explorer #91

Open
oeed opened this issue Sep 7, 2020 · 8 comments
Open

Tests duplicated in Test Explorer #91

oeed opened this issue Sep 7, 2020 · 8 comments

Comments

@oeed
Copy link

oeed commented Sep 7, 2020

I'm still fairly new to Rust and Cargo workspace setups, so this is probably a setup issue on my end but I'm not too sure.

Essentially, the tests for all my projects are showing twice:
Screen Shot 2020-09-07 at 17 21 24

In the above example issue-worker is a binary and elasticsearch-wrapper a library. I've setup a workspace with this folder structure. I'll be adding additional libraries in the future and want them all grouped together, hence the lib folder.

Cargo.toml [workspace]
issue-worker
  | Cargo.toml [package]
  | src
  | issue-worker.code-workspace
lib
  | elasticsearch-wrapper
      | Cargo.toml [package]
      | src
...
+ other non-Rust folders & files

I have a multi-root VSCode workspace with the 'issue-worker' and 'lib' folders. The reason for this is this workspace is sitting in a mono-repo that also has other non-Rust projects; I only want to see the relevant Rust folders.

// issue-worker.code-workspace
{
  "folders": [{
      "path": "."
    },
    {
      "path": "../lib"
    }
  ]
}
@calebcartwright
Copy link
Member

Can you share the contents of your workspace Cargo.toml file?

@oeed
Copy link
Author

oeed commented Sep 7, 2020

Sure

workspace:

[workspace]

members = [
  "issue-worker",
  "lib/elasticsearch-wrapper"
]

issue-worker:

[package]
name = "issue-worker"
version = "0.1.0"
authors = ["..."]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
elasticsearch-wrapper = { path = "../lib/elasticsearch-wrapper" }

elasticsearch-wrapper:

[package]
name = "elasticsearch-wrapper"
version = "0.1.0"
authors = ["..."]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
elasticsearch = "~7"
serde = "~1"
serde_json = "~1"

@calebcartwright
Copy link
Member

Thanks! Everything looks pretty standard there with the explicit cargo workspace, so that plus the the duplicated rust root node in Explorer is highly indicative of the VS Code multiroot workspace doing some double loading somewhere.

Could you try opening a standalone instance of Code on the cargo workspace root directory?

@oeed
Copy link
Author

oeed commented Sep 9, 2020

Yep it appears to not duplicate with just the workspace directory open:

Directory:
Screen Shot 2020-09-09 at 13 43 56

Multi-root Workspace:
Screen Shot 2020-09-09 at 13 44 03

@raphaelricardo10
Copy link

I am studying this project to solve this problem. Someone can help me have a overview?

It think the problem is not that hard to solve.

@calebcartwright
Copy link
Member

That'd be great @raphaelricardo10 thanks!

I don't know off hand what the issue is, but my guess is that the activation is being hit for every workspace:

const workspaceFolder = (vscode.workspace.workspaceFolders || [])[0];

The project is obviously very, very light on contributing documentation but it does have the relevant VS Code configurations and npm scripts wired up (debug, testing, etc.) that you should be able to use the VS Code UI directly for such inner dev loop activities

@mlesin
Copy link

mlesin commented May 31, 2023

Is there any progress on this?

@raphaelricardo10
Copy link

raphaelricardo10 commented Jun 1, 2023

Not yet. But there is a workaround: not using multiple VSCode workspaces, but a single workspace with cargo.toml file referring to different rust projects. In my case, I have a root project that consumes different rust libraries, and I added them as git submodules to edit them directly from the consumer.

For example:

[workspace]

members = [
    "submodules/project-1",
    "submodules/project-2",
    "submodules/project-n",
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants