Skip to content

Commit

Permalink
Merge pull request ocaml#5004 from AltGr/tests-autoupd
Browse files Browse the repository at this point in the history
Some new tests, and auto-update after package def
  • Loading branch information
kit-ty-kate authored and rjbou committed Apr 27, 2022
1 parent d641689 commit c4a44d7
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 106 deletions.
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ New option/command/subcommand are prefixed with ◈.
* Add & update env tests [#4861 #4841 @rjbou @dra27]
* Port opam-rt tests: orphans, dep-cycles, reinstall, and big-upgrade [#4979 @AltGr]
* Add & update env tests [#4861 #4841 #4974 @rjbou @dra27 @AltGr]
* Add remove test [#5004 @AltGr]
### Engine
* Add `opam-cat` to normalise opam file printing [#4763 @rjbou @dra27] [2.1.0~rc2 #4715]
* Fix meld reftest: open only with failing ones [#4913 @rjbou]
Expand All @@ -141,6 +142,7 @@ New option/command/subcommand are prefixed with ◈.
* Clean outputs from opam error reporting block [#4966 @rjbou]
* Avoid diff when the repo is too old [#4979 @AltGr]
* Escape regexps characters in string replacements primitives [#5009 @kit-ty-kate]
* Automatically update default repo when adding a package file [#5004 @AltGr]


## Github Actions
Expand Down
126 changes: 126 additions & 0 deletions tests/reftests/avoid-version.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
N0REP0
### <pkg:a.2>
opam-version: "2.0"
flags: avoid-version
### opam switch create default --empty
### OPAMFAKE=1
### OPAMYES=1
### opam install a --show
The following actions would be faked:
- install a 2
### <pkg:a.1>
opam-version: "2.0"
### opam install a
The following actions will be faked:
- install a 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.1
Done.
### opam upgrade a
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).

The following packages are not being upgraded because the new versions conflict with other installed packages:
- a.2
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.
### <pkg:a.1.1>
opam-version: "2.0"
### opam upgrade a
The following actions will be faked:
- upgrade a 1 to 1.1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.1.1
Done.
### <pkg:a.3>
opam-version: "2.0"
### opam upgrade a
The following actions will be faked:
- upgrade a 1.1 to 3

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.3
Done.
### opam install a.2
The following actions will be faked:
- downgrade a 3 to 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.2
Done.
### opam upgrade a
The following actions will be faked:
- upgrade a 2 to 3

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.3
Done.
### <pkg:b.1>
opam-version: "2.0"
depends: "a"
### <pkg:b.2>
opam-version: "2.0"
depends: "a" {= "2"}
### opam install b
The following actions will be faked:
- install b 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of b.1
Done.
### opam upgrade
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).

The following packages are not being upgraded because the new versions conflict with other installed packages:
- b.2
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.
### opam upgrade b
The following actions will be faked:
- downgrade a 3 to 2 [required by b]
- upgrade b 1 to 2
===== 1 to upgrade | 1 to downgrade =====

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.2
Faking installation of b.2
Done.
### opam upgrade
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).

The following packages are not being upgraded because the new versions conflict with other installed packages:
- a.3
-- b.2 is installed and requires a = 2
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.
### <pkg:a.4>
opam-version: "2.0"
flags: avoid-version
### <pkg:b.3>
opam-version: "2.0"
flags: avoid-version
### opam upgrade
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).

The following packages are not being upgraded because the new versions conflict with other installed packages:
- a.4
- b.3
However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages.
Nothing to do.
### opam upgrade b.3
The following actions will be faked:
- upgrade b 2 to 3

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of b.3
Done.
### opam install a.2
[NOTE] Package a is already installed (current version is 2).
### opam upgrade
The following actions will be faked:
- upgrade a 2 to 4

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Faking installation of a.4
Done.
10 changes: 0 additions & 10 deletions tests/reftests/cli-versioning.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ flags: compiler
### <pkg:baz.2>
opam-version: "2.0"
flags: compiler
### opam update default

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam option depext=false
Set to 'false' the field depext in global configuration
### opam switch install cli-versioning --empty
Expand Down Expand Up @@ -101,11 +96,6 @@ build-env: [OPAMCLI = "2.1"]
build: ["sh" "-c" "env | grep -qFx 'OPAMCLI=2.1'"]
install: ["sh" "-c" "env | grep -qFx 'OPAMCLI=2.1'"]
remove: ["sh" "-c" "env | grep -qFx 'OPAMCLI=2.1'"]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch set-invariant --formula "[]"
The switch invariant was set to []
### opam install env-2-0
Expand Down
5 changes: 0 additions & 5 deletions tests/reftests/dot-install.test
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ bonjour
saluton
### OPAMYES=1
### opam switch create inst --empty
### opam update default

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### OPAMPRECISETRACKING=1 OPAMDEBUGSECTIONS="TRACK ACTION" OPAMDEBUG=-1
### opam install nodot
The following actions will be performed:
Expand Down
34 changes: 34 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@

(alias
(name reftest-avoid-version)
(action
(diff avoid-version.test avoid-version.out)))

(alias
(name reftest)
(deps (alias reftest-avoid-version)))

(rule
(targets avoid-version.out)
(deps root-N0REP0)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{bin:opam} %{dep:avoid-version.test} %{read-lines:testing-env}))))

(alias
(name reftest-cli-versioning)
(action
Expand Down Expand Up @@ -322,6 +339,23 @@
%{targets}
(run ./run.exe %{bin:opam} %{dep:pat-sub.test} %{read-lines:testing-env}))))

(alias
(name reftest-remove)
(action
(diff remove.test remove.out)))

(alias
(name reftest)
(deps (alias reftest-remove)))

(rule
(targets remove.out)
(deps root-N0REP0)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{bin:opam} %{dep:remove.test} %{read-lines:testing-env}))))

(alias
(name reftest-show)
(action
Expand Down
10 changes: 0 additions & 10 deletions tests/reftests/env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ N0REP0
opam-version: "2.0"
setenv: [ NV_VARS += "%{_:doc}%:%{_:share}%" ]
flags: compiler
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create setenv nv

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Expand All @@ -34,11 +29,6 @@ flags: compiler
### <pkg:nv.1:nv.config>
opam-version: "2.0"
variables { nv_config: "hej!!" }
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create conffile nv

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Expand Down
5 changes: 0 additions & 5 deletions tests/reftests/opamrt-dep-cycle.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ install: [ "mkdir" _:lib ]
depends: "a" {= version}
build: [ "test" "-d" a:lib ]
remove: [ "test" "-d" a:lib ]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create system --empty
### opam install a.1
The following actions will be performed:
Expand Down
32 changes: 11 additions & 21 deletions tests/reftests/opamrt-reinstall.test
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ opam-version: "2.0"
depends: "c"
build: [ "test" "-d" c:lib ]
remove: [ "test" "-d" c:lib ]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create system --empty
### : 1/ Install d
### opam install d
Expand Down Expand Up @@ -157,11 +152,6 @@ depends: "a"
build: [ "test" "-d" a:lib ]
remove: [ "test" "-d" a:lib ]
install: [ "mkdir" _:lib ]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam install d
The following actions will be performed:
- install b 1 [required by c]
Expand Down Expand Up @@ -215,11 +205,6 @@ depends: "b"
build: [ "test" "-d" b:lib ]
remove: [ "test" "-d" b:lib ]
install: [ "mkdir" _:lib ]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam upgrade c
The following actions will be performed:
- upgrade c 1 to 2
Expand Down Expand Up @@ -292,12 +277,17 @@ d
### <pkg:a.2>
opam-version: "2.0"
install: [ "mkdir" _:lib ]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### :TODO: the original test removes b, c, d. Here unpin b ?
### opam upgrade --show
The following actions would be performed:
- remove d 1 [uses c]
- remove c 2 [uses b]
- remove b 1 [conflicts with a]
- upgrade a 1 to 2
===== 1 to upgrade | 3 to remove =====
### opam unpin b --show
[NOTE] b is not pinned.
### opam unpin b --no-action
[NOTE] b is not pinned.
### opam upgrade
The following actions will be performed:
- remove d 1 [uses c]
Expand Down
30 changes: 10 additions & 20 deletions tests/reftests/orphans.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ depends: "foo" {= "1"}
### <pkg:baz.1>
opam-version: "2.0"
### OPAMYES=1
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create sw --empty
### opam install bar
The following actions will be performed:
Expand All @@ -27,11 +22,6 @@ Done.
### <pkg:foo.1>
opam-version: "2.0"
available: false
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam reinstall foo
[ERROR] Sorry, these packages are no longer available from the repositories: foo (= 1)
# Return code 5 #
Expand Down Expand Up @@ -67,11 +57,6 @@ Nothing to do.
### : replay the same sequence but with another version of `foo` present
### <pkg:foo.2>
opam-version: "2.0"
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam upgrade --show
[WARNING] Upgrade is not possible because of conflicts or packages that are no longer available:
- Missing dependency:
Expand All @@ -83,11 +68,16 @@ You may run "opam upgrade --fixup" to let opam fix the current state.
### <pkg:bar.2>
opam-version: "2.0"
depends: "foo" {>= "1"}
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam upgrade --show
The following actions would be performed:
- upgrade foo 1 to 2
- upgrade bar 1 to 2
===== 2 to upgrade =====
### opam upgrade --show --fixup
The following actions would be performed:
- upgrade foo 1 to 2
- upgrade bar 1 to 2
===== 2 to upgrade =====
### opam reinstall baz
baz is not installed. Install it? [Y/n] y
The following actions will be performed:
Expand Down
5 changes: 0 additions & 5 deletions tests/reftests/pat-sub.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ build: [
["grep" "ploplop" "bar"]
["grep" "ploplop" "baz"]
]
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create sw --empty
### OPAMDEBUGSECTIONS="ACTION" opam install pat-sub -y --debug --debug-level=-1
The following actions will be performed:
Expand Down
Loading

0 comments on commit c4a44d7

Please sign in to comment.