asdf icon indicating copy to clipboard operation
asdf copied to clipboard

bug: asdf plugin test nodejs . 'node --version' unexpectedly only operates on commited code

Open airtonix opened this issue 2 years ago β€’ 3 comments

Describe the Bug

Documentation says I can test the local plugin:

You also have the option to pass a relative path to plugin-test.

For example, if the test script is ran in the repo directory: asdf plugin test nodejs . 'node --version'.

https://asdf-vm.com/plugins/create.html#testing-plugins

But when I run this I don't see behaviour that is reflected in my uncommited changes.

Steps to Reproduce

  1. clone any plugin locally
  2. make some changes, (the download message is a good start)
  3. do not commit changes
  4. run asdf plugin test THEPLUGINNAME . 'somethingsomethingsomething darkside'
  5. witness the absence of your glory 🎺☁️πŸŒ₯οΈπŸŒ€οΈπŸ’€

Expected Behaviour

I expect to see how awesome I am

🎺☁️πŸŒ₯οΈπŸŒ€οΈπŸ‘ΌπŸ»

Actual Behaviour

I'm dissapointed.

Environment

> asdf info
OS:
Linux brass 6.1.11-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Feb  9 19:20:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.9 (x86_64-redhat-linux-gnu)

ASDF VERSION:
v0.11.2-8eb11b8

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/zenobius/.asdf

ASDF INSTALLED PLUGINS:
act                          https://github.com/grimoh/asdf-act.git master 8c5f499
awscli                       https://github.com/MetricMike/asdf-awscli.git main c645552
aws-copilot                  https://github.com/NeoHsu/asdf-copilot main 1341900
fzf                          https://github.com/kompiro/asdf-fzf.git master d19eb67
github-cli                   https://github.com/bartlomiejdanek/asdf-github-cli.git master 9e0a9d7
golang                       https://github.com/kennyp/asdf-golang.git master f006a12
java                         https://github.com/halcyon/asdf-java.git master 6598845
neovim                       https://github.com/richin13/asdf-neovim.git master 15e9a80
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c9e5df4
pnpm                         https://github.com/jonathanmorley/asdf-pnpm.git master 95752a9
python                       https://github.com/danhper/asdf-python.git master 8505457
shellcheck                   https://github.com/luizm/asdf-shellcheck.git master 0f79f0b
shfmt                        https://github.com/luizm/asdf-shfmt.git master a42c5ff
yarn                         https://github.com/twuni/asdf-yarn.git main 376c540


### asdf plugins affected (if relevant)

any plugin.

airtonix avatar Feb 24 '23 23:02 airtonix

The plugin-test command installs the plugin in the same way a user would - by running same code that the asdf plugin-add <plugin name> <url> command invokes (see https://github.com/asdf-vm/asdf/blob/master/lib/commands/command-plugin-test.bash#L77).

I'm not sure we want to change this. I understand having to commit each change may be a bit of a hassle. But it also ensures we are testing it in a way users will actually be using it.

If you want more real-time feedback on the plugin code you are writing I'd suggest using tools like shellcheck and shfmt which can be integrated into your editor for fast feedback.

In my opinion I don't think we should change the way the asdf plugin-test command works.

Stratus3D avatar Mar 06 '23 13:03 Stratus3D

I really think this should be changed because not only is this unexpected, but it makes it much more difficult to test incremental changes.

The point of Git having a working tree is so you can do things without committing code. Every testing framework or library I have used works on all code, including code that is unstaged and untracked. This unexpected default makes the feedback loop far slower, and isn't a good experience for plugin authors. Furthermore, the docs mention a GitHub action, which would already cover the case when a user runs asdf plugin-add ....

Shellcheck and shfmt don't help in this case. We have some improvements to make around asdf plugin DX, and I think this should be a part of that. I can't imagine needing to run git add -A && git commit --amend --no-edit every time I want to simply test my code.

hyperupcall avatar Jul 28 '23 22:07 hyperupcall