forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#17705 - huntc:resolve-ra, r=Veykril
feat: Use oldest rustup rust-analyzer when toolchain override is present Selects a rust-toolchain declared RA based on its date. The earliest (oldest) RA wins and becomes the one that the workspace uses as a whole. In terms of precedence: nightly > stable-with-version > stable With stable-with-version, we invoke the RA with a `--version` arg and attempt to extract a date. Given the same date as a nightly, the nightly RA will win. Fixes rust-lang#17663
- Loading branch information
Showing
2 changed files
with
191 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/tools/rust-analyzer/editors/code/tests/unit/bootstrap.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import * as assert from "assert"; | ||
import { _private } from "../../src/bootstrap"; | ||
import type { Context } from "."; | ||
|
||
export async function getTests(ctx: Context) { | ||
await ctx.suite("Bootstrap/Select toolchain RA", (suite) => { | ||
suite.addTest("Order of nightly RA", async () => { | ||
assert.deepStrictEqual( | ||
_private.orderFromPath( | ||
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer", | ||
function (path: string) { | ||
assert.deepStrictEqual( | ||
path, | ||
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer", | ||
); | ||
return "rust-analyzer 1.67.0-nightly (b7bc90fe 2022-11-21)"; | ||
}, | ||
), | ||
"0-2022-11-21/0", | ||
); | ||
}); | ||
|
||
suite.addTest("Order of versioned RA", async () => { | ||
assert.deepStrictEqual( | ||
_private.orderFromPath( | ||
"/Users/myuser/.rustup/toolchains/1.72.1-aarch64-apple-darwin/bin/rust-analyzer", | ||
function (path: string) { | ||
assert.deepStrictEqual( | ||
path, | ||
"/Users/myuser/.rustup/toolchains/1.72.1-aarch64-apple-darwin/bin/rust-analyzer", | ||
); | ||
return "rust-analyzer 1.72.1 (d5c2e9c3 2023-09-13)"; | ||
}, | ||
), | ||
"0-2023-09-13/1", | ||
); | ||
}); | ||
|
||
suite.addTest("Order of versioned RA when unable to obtain version date", async () => { | ||
assert.deepStrictEqual( | ||
_private.orderFromPath( | ||
"/Users/myuser/.rustup/toolchains/1.72.1-aarch64-apple-darwin/bin/rust-analyzer", | ||
function () { | ||
return "rust-analyzer 1.72.1"; | ||
}, | ||
), | ||
"2", | ||
); | ||
}); | ||
|
||
suite.addTest("Order of stable RA", async () => { | ||
assert.deepStrictEqual( | ||
_private.orderFromPath( | ||
"/Users/myuser/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer", | ||
function (path: string) { | ||
assert.deepStrictEqual( | ||
path, | ||
"/Users/myuser/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer", | ||
); | ||
return "rust-analyzer 1.79.0 (129f3b99 2024-06-10)"; | ||
}, | ||
), | ||
"0-2024-06-10/1", | ||
); | ||
}); | ||
|
||
suite.addTest("Order with invalid path to RA", async () => { | ||
assert.deepStrictEqual( | ||
_private.orderFromPath("some-weird-path", function () { | ||
return undefined; | ||
}), | ||
"2", | ||
); | ||
}); | ||
|
||
suite.addTest("Earliest RA between nightly and stable", async () => { | ||
assert.deepStrictEqual( | ||
_private.earliestToolchainPath( | ||
"/Users/myuser/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer", | ||
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer", | ||
function (path: string) { | ||
if ( | ||
path === | ||
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer" | ||
) { | ||
return "rust-analyzer 1.67.0-nightly (b7bc90fe 2022-11-21)"; | ||
} else { | ||
return "rust-analyzer 1.79.0 (129f3b99 2024-06-10)"; | ||
} | ||
}, | ||
), | ||
"/Users/myuser/.rustup/toolchains/nightly-2022-11-22-aarch64-apple-darwin/bin/rust-analyzer", | ||
); | ||
}); | ||
}); | ||
} |