Skip to content

Commit

Permalink
Don't match on version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Jul 3, 2024
1 parent e326367 commit e33ff73
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/bin/julialauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ fn get_julia_path_from_channel(
let potential_matches: Vec<_> = config_data
.installed_channels
.keys()
.filter(|&item| item.starts_with(channel))
.filter(|&item| {
item.starts_with(channel) && !item.starts_with("0") && !item.starts_with("1")
})
.cloned()
.collect();
let actual_channel = if potential_matches.len() == 1 {
Expand Down
35 changes: 28 additions & 7 deletions tests/channel_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ fn channel_selection() {
.stderr("ERROR: Invalid Juliaup channel `1.8.6`. Please run `juliaup list` to get a list of valid channels and versions.\n");

// Now testing short channel matching
// At this point, installed channels are: 1.6.7, 1.7.3, 1.8.5

// Test that incomplete number matching does not autocomplete:
// https://github.com/JuliaLang/juliaup/pull/838#issuecomment-2206640506)
Command::cargo_bin("julia")
.unwrap()
.arg("+1.8")
Expand All @@ -137,13 +140,34 @@ fn channel_selection() {
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_CHANNEL", "1.7.3")
.assert()
.failure();

// Test that completion works only when it should for words
Command::cargo_bin("juliaup")
.unwrap()
.arg("add")
.arg("release")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("1.8.5");
.stdout("");

Command::cargo_bin("julia")
.unwrap()
.arg("+r")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_CHANNEL", "1.7.4")
.assert()
.success();

Command::cargo_bin("juliaup")
.unwrap()
.arg("add")
.arg("1.8.4")
.arg("rc")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
Expand All @@ -152,15 +176,12 @@ fn channel_selection() {

Command::cargo_bin("julia")
.unwrap()
.arg("+1.8")
.arg("+r")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_CHANNEL", "1.7.4")
.assert()
.failure()
.stderr(
"`1.8` is not installed. Please run `juliaup add 1.8` to install channel or version.\n",
);
.failure();
}

0 comments on commit e33ff73

Please sign in to comment.