diff --git a/desktop/internal/toolchain/multicall_link_other_test.go b/desktop/internal/toolchain/multicall_link_other_test.go new file mode 100644 index 000000000..56aa1a79f --- /dev/null +++ b/desktop/internal/toolchain/multicall_link_other_test.go @@ -0,0 +1,56 @@ +//go:build !windows + +package toolchain + +import ( + "context" + "encoding/json" + "os" + "path/filepath" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" +) + +// A version manager can install every tool as a link to one multi-call +// executable that picks the tool by the name it was started under (rustup's +// cargo and rust-analyzer). The probe and the launch must start the layout +// name; the link target answers for itself, so its output never matches the +// tool's version pattern and the installation would never be found. +func TestALayoutLinkedToAMultiCallExecutableIsStartedByItsLayoutName(t *testing.T) { + root, home, vmHome := t.TempDir(), t.TempDir(), t.TempDir() + bin := filepath.Join(vmHome, "jre", "bin") + multiplexer := filepath.Join(bin, "multiplexer") + writeExecutable(t, multiplexer) + if err := os.Symlink("multiplexer", filepath.Join(bin, "vm")); err != nil { + t.Fatal(err) + } + canonicalHome := canonical(t, vmHome) + vm := filepath.Join(canonicalHome, "jre", "bin", "vm") + options := fixtureOptions(home, vmHome, map[string]string{ + vm: "vm 7.1\n", + filepath.Join(canonicalHome, "jre", "bin", "multiplexer"): "multiplexer 1.0\n", + }) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) + defer cancel() + snapshot, err := Load(ctx, core.NewClient(), root, ".", []json.RawMessage{readManifest(t, "runtime.plugin.json")}, options) + if err != nil { + t.Fatal(err) + } + if len(snapshot.Tools) != 1 { + t.Fatalf("tools = %+v", snapshot.Tools) + } + effective := snapshot.Tools[0].Effective + if effective == nil { + for _, trace := range snapshot.Tools[0].Trace { + if trace.Reason != nil { + t.Logf("trace reason = %s", trace.Reason.Code) + } + } + t.Fatal("the linked installation was not selected") + } + if filepath.Clean(effective.Executable) != vm || effective.Version != "7.1" { + t.Fatalf("selection = %s %s, want %s 7.1", effective.Executable, effective.Version, vm) + } +} diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index 34887fd2f..3c1495aa5 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -297,7 +297,10 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # contract, resolveSource.recommendationsURL, and plugins.marketplace.recommendForWorkspace (#2228). # Core #132, merged into main: reviewed-tip force deletion and first-primary-click selection. # Core #133, merged into main: commandInstallers 1 pinned archive downloads (API-23). -PINNED_CORE_REVISION="72036de379e4a71bb995c81a8f574859937bc616" +# Lithe-core-rust #135 (branch fix/toolchain-keep-invoked-name at 8291f3c, on top of main 72036de): +# an external installation whose layout file links to another file name (rustup's cargo and +# rust-analyzer proxies) resolves to the layout path, so probes and launches start cargo, not rustup. +PINNED_CORE_REVISION="8291f3c26f0aa8bc5db8a948608bdf7e8f9c5ad6" PROFILE="debug" CHECKOUT_ONLY="no" while [[ $# -gt 0 ]]; do