Skip to content

[Tests] Add unit test for nvm_download #2406

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

Merged
merged 2 commits into from
Jan 13, 2021

Conversation

nmarghetti
Copy link
Contributor

@nmarghetti nmarghetti commented Jan 11, 2021

Playing a bit more with git, I changed a bit the code compared to the other same PR, which is more compact but changing a bit the previous code though.
It still have the exact same test that pass and which I think cover rather well all the cases I could think of.

@ljharb
Copy link
Member

ljharb commented Jan 11, 2021

I'm confused; why is this a separate PR? A PR, once opened, is a permanent ref on a repo, so opening 2 PRs for the same change is highly undesirable (iow, between this and #2401, now both of them must stay open and be kept in sync manually if i want to avoid one of them dangling forever).

Should I ignore #2401, and review this one instead?

@nmarghetti nmarghetti force-pushed the install_other_repo_bis branch from 7f5a9cd to 6e479a5 Compare January 11, 2021 23:45
@nmarghetti
Copy link
Contributor Author

nmarghetti commented Jan 11, 2021

Sorry for that, I did not realize it would cause this problem. But indeed, in the end only one of the 2 PRs should be discarded.
I just did not like so much about all the copy/paste of the code, so I tried to factorize it a bit. It made me realized my unit test had a tiny bug also.
About reviewing, I would say that you can have a look on both and tell me which approach you would prefer. Then we can remove the other PR.

@ljharb
Copy link
Member

ljharb commented Jan 11, 2021

PRs can't ever be removed; what I'd do is force push the same commit to both PRs before landing it.

@nmarghetti
Copy link
Contributor Author

nmarghetti commented Jan 11, 2021

If one PR is closed without being integrated, is it causing any issue ?

@ljharb
Copy link
Member

ljharb commented Jan 11, 2021

Yes. A closed and unmerged PR is a git ref that lasts for eternity, just dangling.

@nmarghetti
Copy link
Contributor Author

nmarghetti commented Jan 12, 2021

Ah yep true... I can still use one of the PR to add another change to reduce the size of my other PR for Windows. Both PRs would be integrated at some point and not dangling then :D

@nmarghetti
Copy link
Contributor Author

Do you have any preferred approach on this current change ? This PR with more compact code, or the other one ?

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Overall this LGTM.

install.sh Outdated
Comment on lines 102 to 106
# Check if version is a tag
if [ "$(command git ls-remote "$(nvm_source "git")" "refs/tags/$NVM_VERSION" | wc -l)" != "0" ]; then
:
# Check if version is a ref
elif [ "$(command git ls-remote "$(nvm_source "git")" "$NVM_VERSION" | wc -l)" != "0" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

why not command git ls-remote "$(nvm_source "git")" "${NVM_INSTALL_VERSION}" | grep? that would tell you if it was refs/tags/ or `refs/heads/.

Copy link
Contributor Author

@nmarghetti nmarghetti Jan 12, 2021

Choose a reason for hiding this comment

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

I dont like grep so much here, as you can the in my other PR failing, just adding nvm_grep makes the CI failing...
Also, on what would I grep ? grep "$NVM_VERSION" ? I am not sure about the difference with using wc -l then ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry yes, did not get your comment well in fact. Yes in fact I could put them both together as there is no difference. It was just based on my other PR where I was doing a difference between a tag and a ref.

Copy link
Member

Choose a reason for hiding this comment

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

It seems important for us to know the difference, but it seems like a single ls-remote call would provide it if we used grep or similar to filter the results.

@nmarghetti
Copy link
Contributor Author

I still have to check deeper what is feasible or not. With my other PR #2401 which passed, everything looked good. I integrated it in the other PR for Windows #2391 which allow me to have the CI testing with the SHA. But with this current PR it seems that there is some problem. I dont get it.
I guess I can put them all as draft again and check deeper...

install.sh Outdated
elif [ "$(command git ls-remote "$(nvm_source "git")" "$NVM_VERSION" | wc -l)" != "0" ]; then
:
# Check if version is an existing changeset
elif ! nvm_download -o /dev/null "$(nvm_source "script-nvm-exec")"; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check here based on downloading nvm-exec with a given changeset seems to fail while on my other PR for Windows it seems to have worked, otherwise the CI would not pass. I need to check deeper.

@ljharb
Copy link
Member

ljharb commented Jan 12, 2021

Sure, sounds good.

@ljharb ljharb marked this pull request as draft January 12, 2021 00:45
@nmarghetti nmarghetti force-pushed the install_other_repo_bis branch 2 times, most recently from e6a1b55 to a7722f8 Compare January 13, 2021 01:27
@nmarghetti nmarghetti changed the title Allow installation from other repository also for git method [Tests] Add unit test for nvm_download Jan 13, 2021
@nmarghetti nmarghetti marked this pull request as ready for review January 13, 2021 01:42
@nmarghetti nmarghetti requested a review from ljharb January 13, 2021 01:43
@nmarghetti nmarghetti force-pushed the install_other_repo_bis branch from a7722f8 to d6872ae Compare January 13, 2021 09:30
@ljharb ljharb force-pushed the install_other_repo_bis branch from d6872ae to 589c237 Compare January 13, 2021 20:37
@ljharb ljharb merged commit 589c237 into nvm-sh:master Jan 13, 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