Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions test/blackbox-tests/test-cases/pkg/depexts/system-deps.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
If we have a 'pure' system dependency (no OCaml compilation unit)
and no 'libraries' field, we don't fail nor do we print a hint

$ . ../helpers.sh
$ mkrepo
$ add_mock_repo_if_needed

$ cat > dune-project << EOF
> (lang dune 3.20)
> (package
> (name foo)
> (depends conf-foobar))
> EOF

$ mkdir src

$ cat > src/dune << EOF
> (executable
> (name foo)
> (public_name foo))
> EOF

$ cat > src/foo.ml << EOF
> let _exit_code = Sys.command "foobar some_arg" in
> ()
> EOF

$ mkpkg conf-foobar << EOF
> build: [
> ["foobar" "--version"]
> ]
> depexts: [
> ["foobar-cram"]
> ]
> flags: conf
> EOF

Dune is aware of the dependency
$ dune show depexts
foobar-cram

And we add it to the lock solution
$ dune pkg lock
Solution for dune.lock

Dependencies common to all supported platforms:
- conf-foobar.0.0.1

Yet we don't try to build it at all
$ dune build

And we don't print the hint
$ dune exec src/foo.exe
sh: line 1: foobar: command not found

If however, the 'libraries' field is present and there is an unknown 'hi'
lib required, dune will try building depexts to find said 'hi' module,
even if it is unrelated to our depext.

$ rm src/dune
$ cat > src/dune << EOF
> (executable
> (name foo)
> (public_name foo)
> (libraries hi))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work with the empty (libraries) field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty libraries field produces the same behaviour as no field at all

> EOF

Now we see it!
$ dune build
File "dune.lock/conf-foobar.0.0.1.pkg", line 4, characters 30-36:
4 | (all_platforms ((action (run foobar --version)))))
^^^^^^
Error: Program foobar not found in the tree or in PATH
(context: default)
Hint: You may want to verify the following depexts are installed:
- foobar-cram
[1]
Loading