Skip to content
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: ensure shims get created when data dir has spaces #996

Merged
merged 2 commits into from Jul 20, 2021

Conversation

mook-as
Copy link
Contributor

@mook-as mook-as commented Jul 14, 2021

Summary

If ASDF_DATA_DIR has a space in the path (by default, this means asdf itself was installed to a path with a space), then the shims will not be created correctly in bash. This PR fixes the issue.

Other Information

I have only checked up to the actual executable (in my case, node) running — I do not yet know if there are other issues related to spaces in the path.

I'm using extra variables for the lists (which contain newlines) because POSIX shell wouldn't support while read … done; while < <(command) (and is caught by the tests).

@mook-as mook-as requested a review from a team as a code owner July 14, 2021 01:07
lib/utils.bash Outdated Show resolved Hide resolved
@Stratus3D
Copy link
Member

Thanks for the PR @mook-as ! Thank you for catching this, it's definitely something we need to get fixed. Do you think you'd be able to write a basic unit tests for these two functions to prevent this bug from being introduced again in the future?

Copy link
Contributor Author

@mook-as mook-as left a comment

Choose a reason for hiding this comment

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

Thanks for the fast review!

I've made changes to make it match existing code better, as well changed the tests to just default to having a space in ASDF_DIR to catch any issues. This does involve changing a lot of the tests to quote things properly; sorry that the PR is so invasive.

I couldn't figure out a nice way to fix shim_exec.bats, though, so I've opted that one out of having spaces for now. This is because it tests having a tool version of path:…, but it's unclear from the documentation what should happen if there's a space in the path, given that it's a file with space-delimited fields.

lib/commands/command-reshim.bash Outdated Show resolved Hide resolved
@jthegedus
Copy link
Contributor

This does involve changing a lot of the tests to quote things properly; sorry that the PR is so invasive.

Is there a way to add specific test cases for the code paths you modified to support the space, leaving the large existing set of tests for without a space in place?

@mook-as
Copy link
Contributor Author

mook-as commented Jul 16, 2021

Okay, I've changed things so that having spaces in the test is opt in (per test setup), and only do it for the reshim tests. Would that be better? I still fixed all the test within the one file, but it's not quite as big (and I can start doing follow up PRs slowly until the whole thing is covered).

@jthegedus
Copy link
Contributor

Okay, I've changed things so that having spaces in the test is opt in (per test setup), and only do it for the reshim tests. Would that be better?

Yes, I think so. We don't need to have every single asdf test cover both cases, just as long as the modified codepaths in

lib/commands/command-reshim.bash 
lib/utils.bash 

are covered with the existing cases and your new cases.

@Stratus3D
Copy link
Member

This does involve changing a lot of the tests to quote things properly; sorry that the PR is so invasive.

Is there a way to add specific test cases for the code paths you modified to support the space, leaving the large existing set of tests for without a space in place?

I had the exact same thought as @jthegedus.

Checking the updated code now.

@jthegedus
Copy link
Contributor

@mook-as are you happy with this to be merged?

@mook-as
Copy link
Contributor Author

mook-as commented Jul 19, 2021

@jthegedus I am; I can't figure out what's wrong with the WSL tests, though.

@jthegedus
Copy link
Contributor

They do not work. We do not expect them to either. It is my fault they are there. I will be removing those test cases shortly. We do want to test in other envs like wsl2 eventually.

@jthegedus jthegedus merged commit 39c9999 into asdf-vm:master Jul 20, 2021
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.

None yet

3 participants