diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/cargo.ts | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index c3e2e5c05..a55b2f860 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts | |||
@@ -25,7 +25,7 @@ export function artifactSpec(args: readonly string[]): ArtifactSpec { | |||
25 | switch (cargoArgs[0]) { | 25 | switch (cargoArgs[0]) { |
26 | case "run": cargoArgs[0] = "build"; break; | 26 | case "run": cargoArgs[0] = "build"; break; |
27 | case "test": { | 27 | case "test": { |
28 | if (cargoArgs.indexOf("--no-run") === -1) { | 28 | if (!cargoArgs.includes("--no-run")) { |
29 | cargoArgs.push("--no-run"); | 29 | cargoArgs.push("--no-run"); |
30 | } | 30 | } |
31 | break; | 31 | break; |
@@ -36,9 +36,7 @@ export function artifactSpec(args: readonly string[]): ArtifactSpec { | |||
36 | if (cargoArgs[0] === "test") { | 36 | if (cargoArgs[0] === "test") { |
37 | // for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests | 37 | // for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests |
38 | // produce 2 artifacts: {"kind": "bin"} and {"kind": "test"} | 38 | // produce 2 artifacts: {"kind": "bin"} and {"kind": "test"} |
39 | result.filter = (artifacts) => { | 39 | result.filter = (artifacts) => artifacts.filter(it => it.isTest); |
40 | return artifacts.filter(a => a.isTest); | ||
41 | }; | ||
42 | } | 40 | } |
43 | 41 | ||
44 | return result; | 42 | return result; |
@@ -48,7 +46,7 @@ export class Cargo { | |||
48 | constructor(readonly rootFolder: string, readonly output: OutputChannel) { } | 46 | constructor(readonly rootFolder: string, readonly output: OutputChannel) { } |
49 | 47 | ||
50 | private async getArtifacts(spec: ArtifactSpec): Promise<CompilationArtifact[]> { | 48 | private async getArtifacts(spec: ArtifactSpec): Promise<CompilationArtifact[]> { |
51 | let artifacts: CompilationArtifact[] = []; | 49 | const artifacts: CompilationArtifact[] = []; |
52 | 50 | ||
53 | try { | 51 | try { |
54 | await this.runCargo(spec.cargoArgs, | 52 | await this.runCargo(spec.cargoArgs, |
@@ -75,11 +73,7 @@ export class Cargo { | |||
75 | throw new Error(`Cargo invocation has failed: ${err}`); | 73 | throw new Error(`Cargo invocation has failed: ${err}`); |
76 | } | 74 | } |
77 | 75 | ||
78 | if (spec.filter) { | 76 | return spec.filter?.(artifacts) ?? artifacts; |
79 | artifacts = spec.filter(artifacts); | ||
80 | } | ||
81 | |||
82 | return artifacts; | ||
83 | } | 77 | } |
84 | 78 | ||
85 | async executableFromArgs(args: readonly string[]): Promise<string> { | 79 | async executableFromArgs(args: readonly string[]): Promise<string> { |