diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index ba286c0abf..4ff24ea7df 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts @@ -48,12 +48,17 @@ export class Cargo { async executableFromArgs(args: readonly string[]): Promise { const cargoArgs = [...args, "--message-format=json"]; - if( cargoArgs[0] == "run" ) { + if (cargoArgs[0] === "run") { // a runnable from the quick pick. cargoArgs[0] = "build"; } - const artifacts = await this.artifactsFromArgs(cargoArgs); + let artifacts = await this.artifactsFromArgs(cargoArgs); + if (cargoArgs[0] === "test") { + // for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests + // produce 2 artifacts: {"kind": "bin"} and {"kind": "test"} + artifacts = artifacts.filter(a => a.isTest); + } if (artifacts.length === 0) { throw new Error('No compilation artifacts');