Skip to content

Commit

Permalink
test(pkg): cycles in opam repo (ocaml#8823)
Browse files Browse the repository at this point in the history
The solver does not check for cyles. This might lead to an invalid build
plan so something to keep in mind.

We also add a test for a situation where there is a cycle in the repo,
but an alternative valid solution is still available.

In both tests the solver ignores the cycle.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
  • Loading branch information
Alizter authored Oct 18, 2023
1 parent 41b8c89 commit ab8774f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/blackbox-tests/test-cases/pkg/opam-package-cycle-with-or.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
We test an repository with a package cycle that has an alternative solution which avoids a
cycle. We have the following packages:

> a --> b --> c

Now c depends either on a or on a fourth package d. Therefore there is a valid solution
available that avoids a cycle.

$ . ./helpers.sh
$ mkrepo

$ mkpkg a <<EOF
> depends: [ "b" ]
> EOF
$ mkpkg b <<EOF
> depends: [ "c" ]
> EOF
$ mkpkg c <<EOF
> depends: [ "a" | "d" ]
> EOF
$ mkpkg d

Solver finds the invalid solution as it doesn't check cycles.

$ solve c
Solution for dune.lock:
a.0.0.1
b.0.0.1
c.0.0.1

35 changes: 35 additions & 0 deletions test/blackbox-tests/test-cases/pkg/opam-package-cycle.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Testing how the solver handles cycles in an opam repository.

$ . ./helpers.sh
$ mkrepo

$ mkpkg a <<'EOF'
> depends: [ "b" ]
> EOF
$ mkpkg b <<'EOF'
> depends: [ "c" ]
> EOF
$ mkpkg c <<'EOF'
> depends: [ "a" ]
> EOF

Solver doesn't complain about cycles.

$ solve a
Solution for dune.lock:
a.0.0.1
b.0.0.1
c.0.0.1

$ solve b
Solution for dune.lock:
a.0.0.1
b.0.0.1
c.0.0.1

$ solve c
Solution for dune.lock:
a.0.0.1
b.0.0.1
c.0.0.1

0 comments on commit ab8774f

Please sign in to comment.