This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,78 @@
When a package fails to build, dune will print opam depexts warning.
$ . ../helpers.sh
$ mkrepo
$ add_mock_repo_if_needed
Make a library that would fail when building it:
$ mkdir foo
$ cat > foo/dune-project <<EOF
> EOF
$ tar cf foo.tar foo
$ rm -rf foo
Make a project that uses the foo library:
$ cat > dune-project <<EOF
> (lang dune 3.13)
> (package
> (name bar)
> (depends foo))
> EOF
$ cat > dune <<EOF
> (executable
> (public_name bar)
> (libraries foo))
> EOF
Make dune.lock files with known program "dune".
$ make_lockdir
$ cat > dune.lock/foo.pkg <<EOF
> (version 0.0.1)
> (build
> (run dune build))
> (depexts unzip gnupg)
> (source
> (fetch
> (url file://$PWD/foo.tar)
> (checksum md5=$(md5sum foo.tar | cut -f1 -d' '))))
> EOF
Build the project, when it fails building 'foo' package, it shows the depexts
error message.
$ dune build
File "dune.lock/foo.pkg", line 3, characters 6-10:
3 | (run dune build))
^^^^
Error: Logs for package foo
File "dune-project", line 1, characters 0-0:
Error: Invalid first line, expected: (lang <lang> <version>)
Hint: You may want to verify the following depexts are installed:
- gnupg
- unzip
[1]
Make dune.lock files with unknown program and unknown package.
$ make_lockdir
$ cat > dune.lock/foo.pkg <<EOF
> (version 0.0.1)
> (build
> (run unknown-program))
> (depexts unknown-package)
> (source
> (fetch
> (url file://$PWD/foo.tar)
> (checksum md5=$(md5sum foo.tar | cut -f1 -d' '))))
> EOF
Running the same build. It is supposed to show the depexts message at the end,
when the program is not found.
$ dune build
File "dune.lock/foo.pkg", line 3, characters 6-21:
3 | (run unknown-program))
^^^^^^^^^^^^^^^
Error: Program unknown-program not found in the tree or in PATH
(context: default)
Hint: You may want to verify the following depexts are installed:
- unknown-package
[1]

View file

@ -0,0 +1,24 @@
Show that the depexts that a project has can be printed.
$ . ../helpers.sh
$ mkrepo
Make a project:
$ cat > dune-project <<EOF
> (lang dune 3.13)
> EOF
Create a lockdir with a package that features some depexts.
$ make_lockdir
$ cat > dune.lock/foo.pkg <<EOF
> (version 0.0.1)
> (depexts unzip gnupg)
> EOF
Printing the depexts should show all the depexts that the project has:
$ dune show depexts
gnupg
unzip

View file

@ -0,0 +1,27 @@
Solving would add opam 'depext' field to lock directory packages
$ . ../helpers.sh
$ mkrepo
$ add_mock_repo_if_needed
Make a package for the library with depexts:
$ mkpkg foo <<EOF
> depexts: [["unzip" "gnupg"]]
> EOF
Make a project that uses the foo library:
$ cat > dune-project <<EOF
> (lang dune 3.13)
> (package
> (name bar)
> (depends foo))
> EOF
locking would add the opam 'depext' field to foo.pkg
$ dune pkg lock
Solution for dune.lock:
- foo.0.0.1
$ cat dune.lock/foo.pkg
(version 0.0.1)
(depexts unzip gnupg)

View file

@ -0,0 +1,25 @@
Solving with an unknown variable on depexts:
$ . ../helpers.sh
$ mkrepo
$ add_mock_repo_if_needed
The "foobar" variable is not defined:
$ mkpkg foo <<EOF
> depexts: [[ "unzip" ] {foobar}]
> EOF
Make a project that uses the foo library:
$ cat > dune-project <<EOF
> (lang dune 3.13)
> (package
> (name bar)
> (depends foo))
> EOF
Locking should succeed and not include the "unzip" package
$ dune pkg lock 2>&1 | head -n 1
Solution for dune.lock:
$ [ -e dune.lock/foo.pkg ] && cat dune.lock/foo.pkg
(version 0.0.1)