This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
|||
Test that available optional dependencies of a package are added to the
|
||||
"depends" field of that package's lockfile.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ mkrepo
|
||||
|
||||
$ mkpkg a
|
||||
$ mkpkg b
|
||||
|
||||
Make a package which has a regular dependency and an optional dependency.
|
||||
$ mkpkg foo <<EOF
|
||||
> depends: [ "a" ]
|
||||
> depopts: [ "b" ]
|
||||
> EOF
|
||||
|
||||
The optional dependency on "b" is not included in foo's dependencies because
|
||||
"b" is not part of the package solution:
|
||||
$ solve foo
|
||||
Solution for dune.lock:
|
||||
- a.0.0.1
|
||||
- foo.0.0.1
|
||||
$ cat dune.lock/foo.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
(depends a)
|
||||
|
||||
Another package which has a regular dependency on "b":
|
||||
$ mkpkg bar <<EOF
|
||||
> depends: [ "b" ]
|
||||
> EOF
|
||||
|
||||
Solve again, this time depending on both "foo" and "bar". Now "b" is among
|
||||
the dependencies of "foo", since "b" is part of the package solution:
|
||||
$ solve foo bar
|
||||
Solution for dune.lock:
|
||||
- a.0.0.1
|
||||
- b.0.0.1
|
||||
- bar.0.0.1
|
||||
- foo.0.0.1
|
||||
$ cat dune.lock/foo.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
(depends a b)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
This tests that depopts are considered optional by the solver.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ mkrepo
|
||||
$ mkpkg foo
|
||||
$ mkpkg bar
|
||||
|
||||
We create a package that depends on foo and has an optional dependency on bar
|
||||
but also a conflict with bar. This should ensure that bar is never selected by
|
||||
the solver.
|
||||
|
||||
$ solve_project << EOF
|
||||
> (lang dune 3.11)
|
||||
> (package
|
||||
> (name x)
|
||||
> (depends foo)
|
||||
> (depopts bar)
|
||||
> (conflicts bar))
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- foo.0.0.1
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
We test depopts with conflicting constraints to see which one the solver will
|
||||
prefer if any:
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ mkpkg foo 1
|
||||
$ mkpkg foo 2
|
||||
|
||||
$ mkpkg bar <<'EOF'
|
||||
> depopts: [ "foo" {= "1"} ]
|
||||
> EOF
|
||||
|
||||
$ mkpkg baz <<'EOF'
|
||||
> depopts: [ "foo" {= "2"} ]
|
||||
> EOF
|
||||
|
||||
We don't currently support depopts so they are both omitted.
|
||||
|
||||
$ solve bar baz
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
- baz.0.0.1
|
||||
|
||||
It's possible to find a solution by satisfying one (but not both) depopts.
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
We test how the solver chooses a solution for depopts with constraints.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ mkrepo
|
||||
|
||||
We create a package "foo" that is the dependency of two packages "optional" and
|
||||
"bar".
|
||||
|
||||
$ mkpkg foo 1
|
||||
|
||||
The package "optional" has a constraint on a particular version of "foo".
|
||||
|
||||
$ mkpkg optional <<'EOF'
|
||||
> depends: [ "foo" {= "1"} ]
|
||||
> EOF
|
||||
|
||||
The package "bar" depends on "foo" and depends optionally on "optional".
|
||||
|
||||
$ mkpkg bar <<'EOF'
|
||||
> depends: [ "foo" ]
|
||||
> depopts: [ "optional" ]
|
||||
> EOF
|
||||
|
||||
Here the solver could pick "bar" and "foo", and perphaps pick "optional",
|
||||
however this is not required.
|
||||
|
||||
$ solve bar
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
- foo.1
|
||||
|
||||
Since the version of "foo" is constrained by "optional", "optional" should be
|
||||
excluded from the build plan if the latest version of "foo" is picked.
|
||||
|
||||
$ mkpkg foo 2
|
||||
$ solve bar
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
- foo.2
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Selecting depopts
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ mkrepo
|
||||
$ mkpkg foo
|
||||
$ mkpkg bar
|
||||
|
||||
$ solve_project << EOF
|
||||
> (lang dune 3.11)
|
||||
> (package
|
||||
> (name x)
|
||||
> (depends foo)
|
||||
> (depopts bar))
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- foo.0.0.1
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
Reproduce github issue #11058
|
||||
|
||||
Handling of more than one depopt:
|
||||
|
||||
$ . ../helpers.sh
|
||||
|
||||
$ mkpkg a
|
||||
$ mkpkg b
|
||||
$ mkpkg c
|
||||
$ mkpkg d
|
||||
$ mkpkg e
|
||||
$ mkpkg f
|
||||
|
||||
$ runtest() {
|
||||
> mkpkg bar <<'EOF'
|
||||
> depopts: [ "a" "b" "c" ]
|
||||
> EOF
|
||||
> solve bar
|
||||
> }
|
||||
|
||||
$ runtest <<'EOF'
|
||||
> depopts: [ "a" "b" "c" ]
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
|
||||
$ runtest <<'EOF'
|
||||
> depopts: [ "a" "b" "c" "d" ]
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
|
||||
$ runtest <<'EOF'
|
||||
> depopts: [ ("a" | "b") "c" "d" ]
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
|
||||
$ runtest <<'EOF'
|
||||
> depopts: [ (("e" | "a") | ("d" | "f")) "b" "c" ]
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
Reproduce the bug in #11698
|
||||
|
||||
$ . ../helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
$ add_mock_repo_if_needed
|
||||
|
||||
$ mkpkg fmt
|
||||
$ mkpkg semver
|
||||
|
||||
$ mkdir _dep
|
||||
$ cat >_dep/dune-project <<EOF
|
||||
> (lang dune 3.18)
|
||||
> (package
|
||||
> (name dep)
|
||||
> (depopts fmt semver))
|
||||
> EOF
|
||||
|
||||
$ solve_project <<EOF
|
||||
> (lang dune 3.18)
|
||||
> (pin
|
||||
> (url "file://$PWD/_dep")
|
||||
> (package
|
||||
> (name dep)
|
||||
> (version 1.0.0)))
|
||||
> (package
|
||||
> (name x)
|
||||
> (depends dep))
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
- dep.1.0.0
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
We test how opam files with depopts fields are translated into dune.lock files:
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ mkrepo
|
||||
|
||||
Make a package with a depopts field
|
||||
$ mkpkg with-depopts <<'EOF'
|
||||
> depopts: [ "foo" ]
|
||||
> EOF
|
||||
$ mkpkg foo
|
||||
|
||||
$ solve with-depopts
|
||||
Solution for dune.lock:
|
||||
- with-depopts.0.0.1
|
||||
|
||||
When depopts are supported and selected, the above lock should change and we
|
||||
should also be able to see a deps field in the lock file:
|
||||
|
||||
$ cat dune.lock/with-depopts.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
We should also be able to validate the lock directory:
|
||||
|
||||
$ dune pkg validate-lockdir
|
||||
|
||||
Depopts should not be selected if they conflict with other constraints:
|
||||
|
||||
$ mkpkg no-foo <<'EOF'
|
||||
> depends: [ "with-depopts" ]
|
||||
> conflicts: [ "foo" ]
|
||||
> EOF
|
||||
|
||||
$ solve no-foo
|
||||
Solution for dune.lock:
|
||||
- no-foo.0.0.1
|
||||
- with-depopts.0.0.1
|
||||
|
||||
$ dune pkg validate-lockdir
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
Demonstrate how depopts can be forced in the workspace
|
||||
|
||||
$ . ../helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
|
||||
$ mkpkg foo
|
||||
$ mkpkg bar
|
||||
$ mkpkg baz
|
||||
|
||||
$ solve_project <<EOF
|
||||
> (lang dune 3.18)
|
||||
> (package
|
||||
> (name x)
|
||||
> (depopts foo bar))
|
||||
> EOF
|
||||
Solution for dune.lock:
|
||||
(no dependencies to lock)
|
||||
|
||||
Select just foo
|
||||
|
||||
$ cat >dune-workspace <<EOF
|
||||
> (lang dune 3.10)
|
||||
> (lock_dir
|
||||
> (depopts foo)
|
||||
> (repositories mock))
|
||||
> (repository
|
||||
> (name mock)
|
||||
> (url "file://$PWD/mock-opam-repository"))
|
||||
> EOF
|
||||
|
||||
$ dune pkg lock
|
||||
Solution for dune.lock:
|
||||
- foo.0.0.1
|
||||
|
||||
Select both foo and bar
|
||||
|
||||
$ cat >dune-workspace <<EOF
|
||||
> (lang dune 3.10)
|
||||
> (lock_dir
|
||||
> (depopts foo bar)
|
||||
> (repositories mock))
|
||||
> (repository
|
||||
> (name mock)
|
||||
> (url "file://$PWD/mock-opam-repository"))
|
||||
> EOF
|
||||
|
||||
$ dune pkg lock
|
||||
Solution for dune.lock:
|
||||
- bar.0.0.1
|
||||
- foo.0.0.1
|
||||
|
||||
Select a package that is not listed as depopt
|
||||
|
||||
$ cat >dune-workspace <<EOF
|
||||
> (lang dune 3.10)
|
||||
> (lock_dir
|
||||
> (depopts baz)
|
||||
> (repositories mock))
|
||||
> (repository
|
||||
> (name mock)
|
||||
> (url "file://$PWD/mock-opam-repository"))
|
||||
> EOF
|
||||
|
||||
$ dune pkg lock
|
||||
Solution for dune.lock:
|
||||
(no dependencies to lock)
|
||||
|
||||
|
||||
Select garbage
|
||||
|
||||
$ cat >dune-workspace <<EOF
|
||||
> (lang dune 3.10)
|
||||
> (lock_dir
|
||||
> (depopts z)
|
||||
> (repositories mock))
|
||||
> (repository
|
||||
> (name mock)
|
||||
> (url "file://$PWD/mock-opam-repository"))
|
||||
> EOF
|
||||
|
||||
$ dune pkg lock
|
||||
Error: Unable to solve dependencies for the following lock directories:
|
||||
Lock directory dune.lock:
|
||||
Couldn't solve the package dependency formula.
|
||||
The following packages couldn't be found: z
|
||||
[1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue