Skip to content

fix: Make plugin test resolve latest version#2246

Closed
maciektr wants to merge 4 commits into
asdf-vm:masterfrom
maciektr:maciektr/fix-2193
Closed

fix: Make plugin test resolve latest version#2246
maciektr wants to merge 4 commits into
asdf-vm:masterfrom
maciektr:maciektr/fix-2193

Conversation

@maciektr
Copy link
Copy Markdown
Contributor

Summary

If --asdf-tool-version=latest is passed to plugin test, it should resolve the version correctly, instead of passing latest directly.
This change mimics the one of the old bash plugin:

# Use the version passed in if it was set. Otherwise grab the latest
# version from the versions list
if [ -z "$tool_version" ] || [[ "$tool_version" == *"latest"* ]]; then
version="$(latest_command "$plugin_name" "$(sed -e 's#latest##;s#^:##' <<<"$tool_version")")"
if [ -z "$version" ]; then
fail_test "could not get latest version"
fi
else
version="$tool_version"
fi

It also adds a test case to ensure correct behaviour of the changed code.

Fixes: #2193

Other Information

@maciektr maciektr requested a review from a team as a code owner February 24, 2026 18:37
Comment thread internal/cli/cli.go
query := strings.TrimPrefix(toolVersion, "latest")
query = strings.TrimPrefix(query, ":")
resolved, err := versions.Latest(plugin, query)
if err != nil || resolved == "" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This || resolved == "" check should not be needed.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes asdf plugin test so that when --asdf-tool-version=latest (or latest:<query>) is provided, it resolves to an actual version (via the plugin’s latest-stable/list-all callbacks) instead of passing the literal string latest through to installation.

Changes:

  • Resolve --asdf-tool-version latest / latest:<query> in plugin test using internal/versions.Latest.
  • Add a Bats test covering the latest resolution behavior.
  • Update the dummy plugin fixture to fail if it is asked to install a literal latest version, ensuring the test meaningfully validates the fix.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
internal/cli/cli.go Adds latest/latest:<query> resolution logic in pluginTestCommand before installing.
test/plugin_test_command.bats Adds a regression test asserting plugin test succeeds when --asdf-tool-version latest is provided.
test/fixtures/dummy_plugin/bin/install Makes the dummy plugin installation fail on literal latest to catch regressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@Stratus3D Stratus3D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fix @maciektr ! I've been meaning to review your PR and just today hit this issue myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: plugin test command --asdf-tool-version latest does not translate this to an actual version

3 participants