Skip to content

Commit 5f6cdae

Browse files
committed
Mixed "bin" and "test" artifacts workaround.
1 parent af7c50f commit 5f6cdae

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

editors/code/src/cargo.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ export class Cargo {
4848

4949
async executableFromArgs(args: readonly string[]): Promise<string> {
5050
const cargoArgs = [...args, "--message-format=json"];
51-
if( cargoArgs[0] == "run" ) {
51+
if (cargoArgs[0] === "run") {
5252
// a runnable from the quick pick.
5353
cargoArgs[0] = "build";
5454
}
5555

56-
const artifacts = await this.artifactsFromArgs(cargoArgs);
56+
let artifacts = await this.artifactsFromArgs(cargoArgs);
57+
if (cargoArgs[0] === "test") {
58+
// for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
59+
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
60+
artifacts = artifacts.filter(a => a.isTest);
61+
}
5762

5863
if (artifacts.length === 0) {
5964
throw new Error('No compilation artifacts');

0 commit comments

Comments
 (0)