Skip to content

Commit

Permalink
Test dune exec -- wrt file path, public_name with or without .exe
Browse files Browse the repository at this point in the history
Test case for #3322 "dune exec needs to add .exe on Windows".

Signed-off-by: Antonin Décimo <[email protected]>
  • Loading branch information
MisterDA committed Mar 19, 2021
1 parent 0a454e3 commit 398e194
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/public_name-exe.t/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executable
(name example)
(public_name shaihulud))
8 changes: 8 additions & 0 deletions test/blackbox-tests/test-cases/public_name-exe.t/dune-project
Original file line number Diff line number Diff line change
@@ -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.
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline "Hello, World!"
25 changes: 25 additions & 0 deletions test/blackbox-tests/test-cases/public_name-exe.t/mypackage.opam
Original file line number Diff line number Diff line change
@@ -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}
]
]
88 changes: 88 additions & 0 deletions test/blackbox-tests/test-cases/public_name-exe.t/run.t
Original file line number Diff line number Diff line change
@@ -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!

0 comments on commit 398e194

Please sign in to comment.