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

Reftest: add more exhaustive pin command test #6135

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

rjbou
Copy link
Collaborator

@rjbou rjbou commented Jul 31, 2024

This is separated in 2 commits for readability/review:

  • first that adds a test for all pin subcommands and options;
  • second that update previous test (that were only special cases and new subcommands) to make them independent, each one is run in a fresh switch.

I don't know if I added a test for each case (exhaustiveness).

Backported for 2.3 in #6229

Queued on #6219 Unqueued it

@rjbou rjbou added this to the 2.3.0~alpha milestone Jul 31, 2024
@rjbou rjbou requested review from kit-ty-kate and dra27 July 31, 2024 17:53
tests/reftests/pin.test Show resolved Hide resolved
### : Test opam pin remove <pkg>.<version>
### opam pin remove --no-action bar.dev
Ok, bar is no longer pinned to file://${BASEDIR}/bar (version dev)
### :XI:c: Test opam pin remove <pkg>.<version>
Copy link
Collaborator Author

@rjbou rjbou Jul 31, 2024

Choose a reason for hiding this comment

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

Should this test & remove --all one be in its proper section above ?

Copy link
Member

Choose a reason for hiding this comment

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

i think it's fine here

### opam pin add --no-action bar.dev ./bar
### opam pin remove --no-action nip2.dev
[NOTE] nip2 is not pinned.
### :XI:d: Test opam pin remove --all
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept this test here, "as is": be the most similar to previous one with several kind of pins, etc. I don't know if it is intended or not?

Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure to understand what you mean here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it intended to have different kind of pins to remove ? or it was the case because the current switch had already several kind of pins?

Comment on lines 629 to 744
### opam pin add ./nip-empty2
Package nip-empty2 does not exist, create as a NEW package? [y/n] y
nip-empty2 is now pinned to file://${BASEDIR}/nip-empty2 (version dev)

The following actions will be performed:
=== install 1 package
- install nip-empty2 dev (pinned)

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved nip-empty2.dev (file://${BASEDIR}/nip-empty2)
-> installed nip-empty2.dev
Done.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it a bug?

Copy link
Member

Choose a reason for hiding this comment

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

the fact that linting is not done if the name of the package is not specified? yeah probably although it doesn't seem critical

Comment on lines +792 to +908
### opam install ./nip-fo
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/nip-fo (`--working-dir' not specified or specified with no argument).
[nip-fo.dev2] synchronised (git+file://${BASEDIR}/nip-fo#master)
The following actions will be performed:
=== recompile 1 package
- recompile nip-fo dev2 (pinned)

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed nip-fo.dev2
-> installed nip-fo.dev2
Done.
### opam show nip-fo --field=version
dev2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it a bug?

Copy link
Member

Choose a reason for hiding this comment

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

yes it is a known bug, i've seen it several times but i can't find the issue that i used to redirect people to when they got that issue

Copy link
Member

Choose a reason for hiding this comment

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

tests/reftests/pin.test Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
Copy link
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

LGTM aside from those two things and the first commit message

tests/reftests/pin.test Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
master_changes.md Outdated Show resolved Hide resolved
tests/reftests/pin.test Outdated Show resolved Hide resolved
@rjbou rjbou added the PR: QUEUED Pending pull request, waiting for other work to be merged or closed label Oct 1, 2024
@rjbou rjbou modified the milestones: 2.4.0~alpha1, 2.3.0~alpha2 Oct 1, 2024
@rjbou rjbou requested a review from kit-ty-kate October 1, 2024 10:11
@kit-ty-kate kit-ty-kate modified the milestones: 2.3.0~alpha2, 2.4.0~alpha1 Oct 1, 2024
@rjbou rjbou marked this pull request as ready for review October 2, 2024 12:49
@rjbou rjbou removed the PR: QUEUED Pending pull request, waiting for other work to be merged or closed label Oct 2, 2024
Done.
### opam pin edit nip-path
[WARNING] The opam file didn't pass validation:
warning 59: url doesn't contain a checksum
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be fixed with #6218

master_changes.md Outdated Show resolved Hide resolved
### opam switch create removal --empty
### opam pin ./nip --no-action
nip is now pinned to file://${BASEDIR}/nip (version ved)
### opam pin remove --no-action nip.dev
Copy link
Member

Choose a reason for hiding this comment

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

This command is duplicated with the nip.wrong-version test below

Suggested change
### opam pin remove --no-action nip.dev

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In fact, it is

### opam pin remove --no-action nip.ved

The logic

  • test with a good version of pinned packages
  • test with a wrong version of pinned packages
  • test with a not pinned package

Copy link
Member

Choose a reason for hiding this comment

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

it's not. It was:

  • remove good version of pkg1
  • remove wrong version of pkg2

Thus we should simplify into:

  • remove wrong version of pkg1
  • remove good version of pkg1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the original test i agree it was : remove good version then remove wrong version. I've updated the test to add also removal of unpinned one.

"The logic" i was talking about is on the wanted final test (my modif), not the original.

Copy link
Member

Choose a reason for hiding this comment

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

i don't think the extra test makes sense and i don't think we should add new tests here. The commit changing this part is here just to add separation not adding extra tests. It's already complicated to review changes in the reftests as it is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the final form (not yet pushed, i'm still debugging cygwin), i've separated the addition of unpinned package test in first commit like that the second commit only contains the switch change.

### opam pin remove --no-action nip.wrong-version
[ERROR] nip is pinned but not to version wrong-version. Skipping.
# Return code 2 #
### opam pin remove --no-action nip2.dev
Copy link
Member

Choose a reason for hiding this comment

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

The version of nip is ved not dev. The test is different from originally intended

Suggested change
### opam pin remove --no-action nip2.dev
### opam pin remove --no-action nip.ved

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cf above

Comment on lines 1079 to 1110
### opam pin ./nip --no-action
[NOTE] Package nip is already pinned to file://${BASEDIR}/nip (version ved).
nip is now pinned to file://${BASEDIR}/nip (version ved)
Copy link
Member

Choose a reason for hiding this comment

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

this is not needed since the pinned package hasn't been removed

Suggested change
### opam pin ./nip --no-action
[NOTE] Package nip is already pinned to file://${BASEDIR}/nip (version ved).
nip is now pinned to file://${BASEDIR}/nip (version ved)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cf above

Copy link
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

I'm personally not a huge fan of editing the testsuite. I would've preferred to have a new file or to rename the old one if you prefer, but changing it is hard to review and can potentially break test-cases (the opam pin remove <pkg>.<version> section was a good example). In my opinion our testsuite should be append-only whenever possible in the future.

In any case i won't block this. It looks fine as far as i could review.
Thanks!

@rjbou
Copy link
Collaborator Author

rjbou commented Oct 7, 2024

Updated with the news test in their own file,like that the legacy remains untouched. I just updated the comments and added a test case for remove <pkg.version>. The content of the new file is the same than previous versions of this PR.

Comment on lines +638 to +639
### # shell on Cygwin ads a trialing `\r` in the middle of the string
### sh -c 'opam pin add $(opam pin scan ./lot_of_pkgs --normalise | grep path | sed "s/\\r//g") ' | unordered
Copy link
Member

Choose a reason for hiding this comment

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

What about:

Suggested change
### # shell on Cygwin ads a trialing `\r` in the middle of the string
### sh -c 'opam pin add $(opam pin scan ./lot_of_pkgs --normalise | grep path | sed "s/\\r//g") ' | unordered
### sh -c 'opam pin scan ./lot_of_pkgs --normalise | xargs opam pin add'

Copy link
Collaborator Author

@rjbou rjbou Oct 7, 2024

Choose a reason for hiding this comment

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

it doesn't work neither. If there is at least 2 packages, the \r issue is present

Copy link
Member

Choose a reason for hiding this comment

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

interesting

@kit-ty-kate
Copy link
Member

Thanks a lot!

@kit-ty-kate kit-ty-kate merged commit c048c05 into ocaml:master Oct 7, 2024
29 checks passed
@rjbou rjbou changed the title Reftest: add pin command test Reftest: add more exhaustive pin command test Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants