From 5f6cdae18f415b9af3b3d24234ab2943efb30993 Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 14 May 2020 14:42:40 +0300 Subject: [PATCH] Mixed "bin" and "test" artifacts workaround. --- editors/code/src/cargo.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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');