Skip to content

Commit

Permalink
test: eif, add collision tests for exes and melange.emit (#10211)
Browse files Browse the repository at this point in the history
* eif: add collision tests for exes and melange.emit
  • Loading branch information
jchavarri committed Mar 5, 2024
1 parent edd1192 commit e60e4e8
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Using same executable name in two contexts, where the executables are defined
in the same dune file

$ cat > dune-project << EOF
> (lang dune 3.13)
> EOF
$ cat > dune-workspace << EOF
> (lang dune 3.13)
>
> (context default)
>
> (context
> (default
> (name alt-context)))
> EOF
$ cat > dune << EOF
> (executable
> (name foo)
> (enabled_if (= %{context_name} "default")))
> (executable
> (name foo)
> (enabled_if (= %{context_name} "alt-context")))
> EOF
$ cat > foo.ml <<EOF
> let () = print_endline "foo"
> EOF
$ dune build
File "dune", line 4, characters 0-72:
4 | (executable
5 | (name foo)
6 | (enabled_if (= %{context_name} "alt-context")))
Error: Executable "foo" appears for the second time in this directory
[1]
35 changes: 35 additions & 0 deletions test/blackbox-tests/test-cases/enabled_if/eif-exe-name-collision.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Using same executable name in two contexts

$ mkdir -p a b
$ cat > dune-project << EOF
> (lang dune 3.13)
> EOF
$ cat > dune-workspace << EOF
> (lang dune 3.13)
>
> (context default)
>
> (context
> (default
> (name alt-context)))
> EOF
$ cat > a/dune << EOF
> (executable
> (name foo)
> (enabled_if (= %{context_name} "default")))
> EOF
$ cat > a/foo.ml <<EOF
> let () = print_endline "foo"
> EOF
$ cat > b/dune << EOF
> (executable
> (name foo)
> (enabled_if (= %{context_name} "alt-context")))
> EOF
$ cat > b/foo.ml <<EOF
> let () = print_endline "foo"
> EOF
$ dune build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Using same melange.emit target in two contexts, where the stanzas are defined
in the same dune file

$ cat > dune-project << EOF
> (lang dune 3.13)
> (using melange 0.1)
> EOF
$ cat > dune-workspace << EOF
> (lang dune 3.13)
>
> (context default)
>
> (context
> (default
> (name alt-context)))
> EOF
$ cat > dune << EOF
> (melange.emit
> (target foo)
> (enabled_if (= %{context_name} "default")))
> (melange.emit
> (target foo)
> (enabled_if (= %{context_name} "alt-context")))
> EOF
$ cat > foo.ml <<EOF
> let () = print_endline "foo"
> EOF
$ dune build
File "dune", line 4, characters 0-76:
4 | (melange.emit
5 | (target foo)
6 | (enabled_if (= %{context_name} "alt-context")))
Error: Target "foo" appears for the second time in this directory
[1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Using same melange.emit target in two contexts

$ mkdir -p a b
$ cat > dune-project << EOF
> (lang dune 3.13)
> (using melange 0.1)
> EOF
$ cat > dune-workspace << EOF
> (lang dune 3.13)
>
> (context default)
>
> (context
> (default
> (name alt-context)))
> EOF
$ cat > a/dune << EOF
> (melange.emit
> (target foo)
> (enabled_if (= %{context_name} "default")))
> EOF
$ cat > a/foo.ml <<EOF
> let () = print_endline "foo"
> EOF
$ cat > b/dune << EOF
> (melange.emit
> (target foo)
> (enabled_if (= %{context_name} "alt-context")))
> EOF
$ cat > b/foo.ml <<EOF
> let () = print_endline "foo"
> EOF
$ dune build

0 comments on commit e60e4e8

Please sign in to comment.