Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb committed Oct 6, 2019
1 parent 42944d6 commit c619037
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,14 @@
test-cases/windows-diff
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name with-exit-codes)
(deps (package dune) (source_tree test-cases/with-exit-codes))
(action
(chdir
test-cases/with-exit-codes
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name with-stdin-from)
(deps (package dune) (source_tree test-cases/with-stdin-from))
Expand Down Expand Up @@ -2015,6 +2023,7 @@
(alias vlib-default-impl)
(alias vlib-wrong-default-impl)
(alias windows-diff)
(alias with-exit-codes)
(alias with-stdin-from)
(alias workspace-paths)
(alias workspaces)
Expand Down Expand Up @@ -2209,6 +2218,7 @@
(alias vlib-default-impl)
(alias vlib-wrong-default-impl)
(alias windows-diff)
(alias with-exit-codes)
(alias with-stdin-from)
(alias workspace-paths)
(alias workspaces)
Expand Down
48 changes: 48 additions & 0 deletions test/blackbox-tests/test-cases/with-exit-codes/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$ cat > dune-project <<EOF
> (lang dune 2.0)
> EOF

$ cat > dune <<EOF
> (alias
> (name a)
> (action (with-exit-codes 0 (run false))))
> EOF

$ dune build --display=short --root . @a
false alias a (exit 1)
(cd _build/default && /usr/bin/false)
[1]

$ cat >> dune <<EOF
> (alias
> (name b)
> (action (with-exit-codes (not 0) (run false))))
> EOF

$ dune build --display=short --root . @b
false alias b

$ cat >> dune <<EOF
> (executable
> (name exit)
> (modules exit))
> (rule (with-stdout-to exit.ml (echo "let () = exit (int_of_string Sys.argv.(1))")))
> (alias
> (name c)
> (action (with-exit-codes (or 1 2 3) (run ./exit.exe 2))))
> (alias
> (name d)
> (action (with-exit-codes (or 4 5 6) (run ./exit.exe 7))))
> EOF

$ dune build --display=short --root . @c
ocamldep .exit.eobjs/exit.ml.d
ocamlc .exit.eobjs/byte/dune__exe__Exit.{cmi,cmo,cmt}
ocamlopt .exit.eobjs/native/dune__exe__Exit.{cmx,o}
ocamlopt exit.exe
exit alias c

$ dune build --display=short --root . @d
exit alias d (exit 7)
(cd _build/default && ./exit.exe 7)
[1]

0 comments on commit c619037

Please sign in to comment.