Skip to content

Commit

Permalink
Add basic tests of lockfile generation
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
  • Loading branch information
gridbugs committed May 16, 2023
1 parent 14b2f89 commit 32f4971
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
@@ -0,0 +1 @@
opam-version: "2.0"
@@ -0,0 +1 @@
opam-version: "2.0"
@@ -0,0 +1 @@
opam-version: "2.0"
@@ -0,0 +1 @@
opam-version: "2.0"
@@ -0,0 +1 @@
opam-version: "2.0"
@@ -0,0 +1,5 @@
opam-version: "2.0"
depends: [
"baz" {>= "0.1"}
"bar" {>= "0.2"}
]
85 changes: 85 additions & 0 deletions test/blackbox-tests/test-cases/pkg/lockfile-generation.t/run.t
@@ -0,0 +1,85 @@
Simple example of generating a lock file with Dune

Generate a `dune-project` file.
$ cat >dune-project <<EOF
> (lang dune 3.8)
> (package
> (name lockfile_generation_test)
> (depends
> foo
> (bar (>= "0.3"))
> ))
> EOF
Run the solver and generate a lock directory.
$ dune pkg lock --opam-env=pure --opam-repository=mock-opam-repository
Selected the following packages:
bar.0.4.0
baz.0.1.0
foo.0.0.1
lockfile_generation_test.LOCAL
Print the name and contents of each file in the lock directory separated by
"---", sorting by filename for consistency.
$ find dune.lock -type f | sort | xargs -I{} sh -c "printf '{}:\n\n'; cat {}; printf '\n\n---\n\n'"
dune.lock/bar:
(version 0.4.0)
(dev false)
---
dune.lock/baz:
(version 0.1.0)
(dev false)
---
dune.lock/foo:
(version 0.0.1)
(deps baz bar)
(dev false)
---
dune.lock/lock.dune:
(lang package 0.1)
---
dune.lock/lockfile_generation_test:
(version LOCAL)
(deps foo bar)
(dev true)
---
Regenerate the `dune-project` file introducing an unsatisfiable constraint.
$ cat >dune-project <<EOF
> (lang dune 3.8)
> (package
> (name lockfile_generation_test)
> (depends
> foo
> (bar (>= "0.6"))
> ))
> EOF
Run the solver again. This time it will fail.
$ dune pkg lock --opam-env=pure --opam-repository=mock-opam-repository
Error: Can't find all required versions.
Selected: baz.0.1.0 foo.0.0.1 lockfile_generation_test.LOCAL
- bar -> (problem)
foo 0.0.1 requires >= 0.2
lockfile_generation_test LOCAL requires >= 0.6
Rejected candidates:
bar.0.5.0: Incompatible with restriction: >= 0.6
bar.0.4.0: Incompatible with restriction: >= 0.6
bar.0.0.1: Incompatible with restriction: >= 0.2
[1]

0 comments on commit 32f4971

Please sign in to comment.