diff --git a/test/blackbox-tests/test-cases/public_name-exe.t/dune b/test/blackbox-tests/test-cases/public_name-exe.t/dune new file mode 100644 index 000000000000..15d32bd8916e --- /dev/null +++ b/test/blackbox-tests/test-cases/public_name-exe.t/dune @@ -0,0 +1,3 @@ +(executable + (name example) + (public_name shaihulud)) diff --git a/test/blackbox-tests/test-cases/public_name-exe.t/dune-project b/test/blackbox-tests/test-cases/public_name-exe.t/dune-project new file mode 100644 index 000000000000..07daf46607bf --- /dev/null +++ b/test/blackbox-tests/test-cases/public_name-exe.t/dune-project @@ -0,0 +1,8 @@ +(lang dune 2.8) +(generate_opam_files true) +(package + (name mypackage) + (synopsis "My first Dune package!") + (description "\| This is my first attempt at creating + "\| a project with Dune. +)) diff --git a/test/blackbox-tests/test-cases/public_name-exe.t/example.ml b/test/blackbox-tests/test-cases/public_name-exe.t/example.ml new file mode 100644 index 000000000000..7bf6048f46da --- /dev/null +++ b/test/blackbox-tests/test-cases/public_name-exe.t/example.ml @@ -0,0 +1 @@ +let () = print_endline "Hello, World!" diff --git a/test/blackbox-tests/test-cases/public_name-exe.t/mypackage.opam b/test/blackbox-tests/test-cases/public_name-exe.t/mypackage.opam new file mode 100644 index 000000000000..d94e2ca65ee1 --- /dev/null +++ b/test/blackbox-tests/test-cases/public_name-exe.t/mypackage.opam @@ -0,0 +1,25 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: "My first Dune package!" +description: """ +This is my first attempt at creating +a project with Dune. +""" +depends: [ + "dune" {>= "2.8"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] diff --git a/test/blackbox-tests/test-cases/public_name-exe.t/run.t b/test/blackbox-tests/test-cases/public_name-exe.t/run.t new file mode 100644 index 000000000000..79608a59bb6f --- /dev/null +++ b/test/blackbox-tests/test-cases/public_name-exe.t/run.t @@ -0,0 +1,88 @@ +Test case for https://github.com/ocaml/dune/issues/3322 +"dune exec needs to add .exe on Windows" + + $ os_type=$(ocamlc -config-var os_type) + +Test that on Windows `dune exec -- public_name` and +`dune exec -- public_name.exe` have the same effect. + +With extension +============== + + $ dune clean + $ dune build @install + $ if [ $os_type = Win32 ]; then dune exec -- shaihulud.exe; else echo "Hello, World!"; fi + Hello, World! + +Without extension, prebuild +================= + + $ dune clean + $ dune build @install + $ dune exec -- shaihulud + Hello, World! + + +Test that `dune exec -- public_name` (omitting the .exe) works from a +clean state. + +Without extension, clean state +============================== + + $ dune clean + $ dune exec -- shaihulud + Hello, World! + + +Test that the public name resolves well to the actual executable file +when a dependency changes. On platforms where there are no symlinks, +updating the public_name executable matters. + +With extension, prebuild +============== + + $ dune clean + $ dune build @install + + $ if [ $os_type = Win32 ]; then dune exec -- shaihulud.exe; else echo "Hello, World!"; fi + Hello, World! + $ dune exec -- ./example.exe + Hello, World! + $ sed -i'' 's/World/Arrakis/' example.ml + $ if [ $os_type = Win32 ]; then dune exec -- shaihulud.exe; else echo "Hello, Arrakis!"; fi + Hello, Arrakis! + $ dune exec -- ./example.exe + Hello, Arrakis! + +Without extension, prebuild +================= + + $ sed -i'' 's/Arrakis/World/' example.ml + $ dune clean + $ dune build @install + + $ dune exec -- shaihulud + Hello, World! + $ dune exec -- ./example.exe + Hello, World! + $ sed -i'' 's/World/Arrakis/' example.ml + $ dune exec -- shaihulud + Hello, Arrakis! + $ dune exec -- ./example.exe + Hello, Arrakis! + +Without extention, clean state +============================== + + $ sed -i'' 's/Arrakis/World/' example.ml + $ dune clean + + $ dune exec -- shaihulud + Hello, World! + $ dune exec -- ./example.exe + Hello, World! + $ sed -i'' 's/World/Arrakis/' example.ml + $ dune exec -- shaihulud + Hello, Arrakis! + $ dune exec -- ./example.exe + Hello, Arrakis!