Mixed "bin" and "test" artifacts workaround.

This commit is contained in:
vsrs 2020-05-14 14:42:40 +03:00
parent af7c50f8a2
commit 5f6cdae18f

View file

@ -48,12 +48,17 @@ export class Cargo {
async executableFromArgs(args: readonly string[]): Promise<string> {
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');