Skip to content

Commit

Permalink
Merge pull request #6331 from kit-ty-kate/fix-admin-check-installability
Browse files Browse the repository at this point in the history
Fix opam admin check in the presence of the with-dev-setup variable
  • Loading branch information
kit-ty-kate authored Dec 12, 2024
2 parents 659e4ad + 1eb7858 commit c6f86e9
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 5 deletions.
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ users)

## Admin
* ◈ Add `opam admin compare-versions` to compare package versions for sanity checks [#6197 @mbarbin]
* [BUG] Fix `opam admin check` in the presence of the `with-dev-setup` variable [#6331 @kit-ty-kate - fix #6329]

## Opam installer

Expand Down Expand Up @@ -146,6 +147,8 @@ users)
## Reftests
### Tests
* Add switch removal test: failure on removal linked switch [#6276 @btjorge]
* Extend the tests on opam admin to include packages using builtin global variables [#6331 @kit-ty-kate]
* Extend the tests on opam admin check by including all the arguments [#6331 @kit-ty-kate @rjbou]

### Engine

Expand Down
10 changes: 6 additions & 4 deletions src/client/opamAdminCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
open OpamTypes
open OpamPackage.Set.Op

let env ~with_test ~with_doc ~dev nv v =
let env ~with_test ~with_doc ~with_dev_setup ~dev nv v =
match OpamVariable.Full.scope v,
OpamVariable.(to_string (Full.variable v))
with
Expand All @@ -27,10 +27,12 @@ let env ~with_test ~with_doc ~dev nv v =
Some (B dev)
| OpamVariable.Full.Global, "with-doc" ->
Some (B with_doc)
| OpamVariable.Full.Global, "with-dev-setup" ->
Some (B with_dev_setup)
| _ -> None

let get_universe ~with_test ~with_doc ~dev opams =
let env = env ~with_test ~with_doc ~dev in
let get_universe ~with_test ~with_doc ~with_dev_setup ~dev opams =
let env = env ~with_test ~with_doc ~with_dev_setup ~dev in
let packages = OpamPackage.keys opams in
{
u_packages = packages;
Expand Down Expand Up @@ -419,7 +421,7 @@ let check ~quiet ~installability ~cycles ~obsolete ~ignore_test repo_root =
in
let univ =
get_universe
~with_test:(not ignore_test) ~with_doc:(not ignore_test) ~dev:false
~with_test:(not ignore_test) ~with_doc:(not ignore_test) ~with_dev_setup:false ~dev:false
opams
in

Expand Down
96 changes: 95 additions & 1 deletion tests/reftests/admin.test
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ depends: "lorem" { < "1" }
### <packages/non/non.1/opam>
opam-version: "2.0"
depends: "lorem"
### <packages/vars/vars.1/opam>
opam-version: "2.0"
depends: [
"lorem" {with-test}
"ipsum" {with-doc}
"dolor" {with-dev-setup}
"sit" {dev}
]
### <add-content.sh>
for op in `ls packages/*/*/opam`; do
grep -q synopsis $op || echo 'synopsis: "A word"' >> $op
Expand Down Expand Up @@ -309,17 +317,98 @@ ocaml-variants -- A word
risus --
sed -- A word
sit -- A word
vars -- A word
### :::::::::::::
### :III: check :
### :::::::::::::
### <packages/suspendisse/suspendisse.1/opam>
opam-version: "2.0"
depends: [
"lorem" { = "1.0" & with-test } # for obsolete -i test
"not-found" { with-test } # for installability -i test
]
### <packages/lectus/lectus.1/opam>
opam-version: "2.0"
depends: [
"tortor" # for cycle test
"dignissim" {with-doc} # for cycle -i test
]
### <packages/tortor/tortor.1/opam>
opam-version: "2.0"
depends: "lectus"
### <packages/dignissim/dignissim.1/opam>
opam-version: "2.0"
depends: "lectus"
### # by default, the check does installability & cycle check
### opam admin check
Checking installability of every package. This may take a few minutes...
[ERROR] These packages are not installable (3):
ocaml-system.1.2 risus.1 suspendisse.1
[ERROR] Dependency cycles detected:
* lectus = 1 -> dignissim = 1
* lectus = 1 -> tortor = 1
Summary: out of 25 packages (22 distinct names)
- 3 uninstallable roots
- 3 packages part of dependency cycles

# Return code 1 #
### opam admin check -i
Checking installability of every package. This may take a few minutes...
[ERROR] These packages are not installable (2):
ocaml-system.1.2 risus.1
Summary: out of 20 packages (17 distinct names)
[ERROR] Dependency cycles detected:
* lectus = 1 -> tortor = 1
Summary: out of 25 packages (22 distinct names)
- 2 uninstallable roots
- 2 packages part of dependency cycles

# Return code 1 #
### opam admin check --installability
Checking installability of every package. This may take a few minutes...
[ERROR] These packages are not installable (3):
ocaml-system.1.2 risus.1 suspendisse.1
Summary: out of 25 packages (22 distinct names)
- 3 uninstallable roots

# Return code 1 #
### opam admin check --installability -i
Checking installability of every package. This may take a few minutes...
[ERROR] These packages are not installable (2):
ocaml-system.1.2 risus.1
Summary: out of 25 packages (22 distinct names)
- 2 uninstallable roots

# Return code 1 #
### opam admin check --obsolete
[ERROR] Obsolete packages detected:
- lorem 2.0
Summary: out of 25 packages (22 distinct names)
- 1 obsolete packages

# Return code 1 #
### opam admin check --obsolete -i
[ERROR] Obsolete packages detected:
- lorem 1.0, 2.0
Summary: out of 25 packages (22 distinct names)
- 2 obsolete packages

# Return code 1 #
### opam admin check --cycles
[ERROR] Dependency cycles detected:
* lectus = 1 -> dignissim = 1
* lectus = 1 -> tortor = 1
Summary: out of 25 packages (22 distinct names)
- 3 packages part of dependency cycles

# Return code 1 #
### opam admin check --cycles -i
[ERROR] Dependency cycles detected:
* lectus = 1 -> tortor = 1
Summary: out of 25 packages (22 distinct names)
- 2 packages part of dependency cycles

# Return code 1 #
### rm -r packages/suspendisse packages/lectus packages/tortor packages/dignissim
### : index :
### opam admin index
Generating urls.txt...
Expand All @@ -331,6 +420,9 @@ packages/
packages/base-comp/
packages/base-comp/base-comp.base/
packages/base-comp/base-comp.base/opam
packages/vars/
packages/vars/vars.1/
packages/vars/vars.1/opam
packages/risus/
packages/risus/risus.1/
packages/risus/risus.1/opam
Expand Down Expand Up @@ -434,6 +526,7 @@ opam-version: "2.0"
depends: "lorem"
### opam admin add-constraint lorem<1.2
[WARNING] In package adipiscing.1, updated constraint lorem {< "1.2" & > "2"} cannot be satisfied, not updating (use `--force' to update anyway)
[WARNING] In package vars.1, updated constraint lorem {< "1.2" & with-test & > "1.2"} cannot be satisfied, not updating (use `--force' to update anyway)
### opam show --just-file ./packages/non/non.1/opam --field depends
"lorem" {< "1.2"}
### opam show --just-file ./packages/sed/sed.1/opam --field depends
Expand All @@ -460,6 +553,7 @@ depends: "lorem"
### opam admin add-constraint lorem=1.2
[WARNING] In package adipiscing.1, updated constraint lorem {= "1.2" & > "2"} cannot be satisfied, not updating (use `--force' to update anyway)
[WARNING] In package sed.1, updated constraint lorem {= "1.2" & < "1"} cannot be satisfied, not updating (use `--force' to update anyway)
[WARNING] In package vars.1, updated constraint lorem {= "1.2" & < "1.2" & with-test & > "1.2"} cannot be satisfied, not updating (use `--force' to update anyway)
### opam show --just-file ./packages/non/non.1/opam --field depends
"lorem" {= "1.2"}
### opam show --just-file ./packages/sed/sed.1/opam --field depends
Expand Down

0 comments on commit c6f86e9

Please sign in to comment.