Skip to content

Commit

Permalink
reftest: more exhaustive test for pin command
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Oct 7, 2024
1 parent 8e3b634 commit ab8c465
Show file tree
Hide file tree
Showing 4 changed files with 958 additions and 9 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ users)
## Reftests
### Tests
* Move pin test to pin-legacy [#6135 @rjbou]
* More exhaustive test for pin command: test different behaviour and cli options [#6135 @rjbou]

### Engine

Expand Down
21 changes: 21 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,27 @@
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:pin-legacy.test} %{read-lines:testing-env}))))

(rule
(alias reftest-pin)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(action
(diff pin.test pin.out)))

(alias
(name reftest)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(deps (alias reftest-pin)))

(rule
(targets pin.out)
(deps root-N0REP0)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(package opam)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:pin.test} %{read-lines:testing-env}))))

(rule
(alias reftest-rebuild)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
Expand Down
34 changes: 25 additions & 9 deletions tests/reftests/pin-legacy.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
N0REP0
### OPAMYES=1
### : --current option :
### :::::::::::::::::::::::
### :1: --current option
### :::::::::::::::::::::::
### opam switch create pinning --empty
### opam pin --current foo
[ERROR] foo is not installed, invalid flag `--current'
Expand Down Expand Up @@ -42,7 +44,9 @@ Now run 'opam upgrade' to apply any package updates.
foo 1
### opam pin --current foo
foo is now pinned locally (version 1)
### : check no repin in case of double 'install .' :
### :::::::::::::::::::::::
### :2: check no repin in case of double 'install .'
### :::::::::::::::::::::::
### <pin:nip/nip.opam>
opam-version: "2.0"
### opam install ./nip
Expand Down Expand Up @@ -74,7 +78,9 @@ The following actions will be performed:
-> retrieved nip.dev (file://${BASEDIR}/nip)
-> installed nip.dev
Done.
### : depext update :
### :::::::::::::::::::::::
### :3: depext update
### :::::::::::::::::::::::
### OPAMNODEPEXTS=0 OPAMCONFIRMLEVEL=unsafe-yes
### opam var --global os-family=dummy-success
Added '[os-family "dummy-success" "Set through 'opam var'"]' to field global-variables in global configuration
Expand Down Expand Up @@ -175,13 +181,19 @@ echo "another-inexistant" "inexistant"
-> installed qux.dev
-> installed bar.dev
Done.
### : Test opam pin remove <pkg>.<version>
### :::::::::::::::::::::::
### :4: 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)
### opam pin remove --no-action nip.wrong-version
[ERROR] nip is pinned but not to version wrong-version. Skipping.
# Return code 2 #
### : Test opam pin remove --all
### opam pin remove --no-action bar.dev
[NOTE] bar is not pinned.
### :::::::::::::::::::::::
### :5: Test opam pin remove --all
### :::::::::::::::::::::::
### OPAMNODEPEXTS=1
### opam pin add --no-action bar.dev ./bar
[bar.dev] synchronised (file://${BASEDIR}/bar)
Expand Down Expand Up @@ -234,7 +246,9 @@ The following actions will be performed:
-> removed qux.dev
Done.
### opam pin
### : Error retrieving git pin :
### :::::::::::::::::::::::
### :6: Error retrieving git pin :
### :::::::::::::::::::::::
### mkdir pin-empty
### git -C pin-empty init -q --initial-branch=master
### git -C pin-empty config core.autocrlf false
Expand Down Expand Up @@ -263,8 +277,10 @@ Could not retrieve some package sources, they will not be pinned nor installed:

Continue anyway? [y/n] y
### opam pin
### : Parse error with future opam version field on pin
### :: just the opam version that is a future
### :::::::::::::::::::::::
### :7: Parse error with future opam version field on pin
### :::::::::::::::::::::::
### :7:a: just the opam version that is a future
### <pin:pin-at-two-one/pin-at-two-one.opam>
opam-version: "2.1"
### opam install ./pin-at-two-one
Expand Down Expand Up @@ -337,7 +353,7 @@ opam-version: "50.0"
error 2: File format error: unsupported or missing file format version; should be 2.0 or older
[ERROR] No package named pin-at-future found.
# Return code 5 #
### :: opam version is a future and there is a parse error
### :7:b: opam version is a future and there is a parse error
### <junk.sh>
echo GARBAGE>>"$1"
### sh junk.sh pin-at-two-one/pin-at-two-one.opam
Expand Down
Loading

0 comments on commit ab8c465

Please sign in to comment.