New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: wait until the plugin update are finished #1037
fix: wait until the plugin update are finished #1037
Conversation
Thanks for the PR! Is there any way we can write a test for this fix to verify we don't introduce this bug at a later time? |
I'm currently writing tests in bats, and I found that bats wait for all commands to finish in a different way. I haven't found a way to work around this problem, do you know of any good information? If you write such a test code and debug output along with the date and time, you will see that the waiting areas are different. Added test code in plugin_update_command.bats (echo is a debug print for bats) @test "asdf plugin-update for all plugins" {
install_mock_plugin_repo "dummy2"
run asdf plugin add "dummy2" "${BASE_DIR}/repo-dummy2"
run asdf plugin-update --all
echo "# end $(date -u) in $(basename "${BASH_SOURCE[0]}:$LINENO")" >&3
{
[[ "$output" = *"Updating dummy to master"* ]]
[[ "$output" = *"Updating dummy2 to master"* ]]
} || (
echo "output = ${output}"
false
)
} Add debug output to the code before modification in plugin_update_command.bats:
Output:
Add debug output to the modified code:
Output:
|
Thanks for the detailed examples @yacchi! Would it not be possible to do something like this to check if the updates are finished?
I'm pretty sure this would not be a fool proof way of checking - the job could always finish after the command exited but before than line of test code ran. But it might be better than nothing if it works. |
77a7ada
to
6ce7724
Compare
@Stratus3D I found out that the processes that couldn't wait and remained had a Parent PID of 1 The
It is true that this method cannot detect the problem if all the jobs are terminated before the end of the process list. |
Thanks for the test! |
Summary
In
asdf plugin update --all
,wait
is not working and the command exits before the update of each plugin are finished.Executing
while
after a pipe will run it in a subshell, so you can't usewait
on the caller to wait for each command to finish.In such a case, Process Substitution is often used, but it seems to be prohibited in this project.
However, for the usage here, I think Here string is fine.