re-arrange tests

This commit is contained in:
Jeremie Dimino 2017-03-15 11:08:54 +00:00
parent dac70f4d72
commit d8fd2f084c
4 changed files with 70 additions and 45 deletions

View File

@ -1,48 +1,10 @@
(rule
((targets (stdout stderr))
(action (with-stdout-to stdout
(with-stderr-to stderr
(progn
(system "echo toto")
(system "echo titi >&2")))))))
(rule
((targets (both))
(action (with-outputs-to both
(progn
(system "echo toto")
(system "echo titi >&2"))))))
(rule
((targets (stdout.expected))
(action (with-stdout-to ${@} (echo "toto\n")))))
(rule
((targets (stderr.expected))
(action (with-stdout-to ${@} (echo "titi\n")))))
(rule
((targets (both.expected))
(action (with-stdout-to ${@} (echo "toto\ntiti\n")))))
(executables
((names (run))
(libraries (unix))))
(alias
((name runtest)
(deps (stdout stdout.expected))
(action (run diff -u stdout.expected stdout))))
(alias
((name runtest)
(deps (stderr stderr.expected))
(action (run diff -u stderr.expected stderr))))
(alias
((name runtest)
(deps (both both.expected))
(action (run diff -u both.expected both))))
(alias
((name runtest)
(action (ignore-stdout (echo "\
==========================
If you see this, something is wrong
")))))
(deps ((files_recursively_in workspaces/redirections)))
(action
(chdir workspaces/redirections
(run ${exe:run.exe} ${bin:jbuilder} runtest --root .)))))

1
test/jbuild-ignore Normal file
View File

@ -0,0 +1 @@
workspaces

14
test/run.ml Normal file
View File

@ -0,0 +1,14 @@
let () =
let args = Array.sub Sys.argv 1 (Array.length Sys.argv - 1) in
let log = Unix.openfile "log" [O_WRONLY; O_CREAT; O_TRUNC] 0o666 in
let pid = Unix.create_process args.(0) args Unix.stdin log log in
Unix.close log;
match snd (Unix.waitpid [] pid) with
| WEXITED 0 -> ()
| st ->
Printf.eprintf "Command failed, log saved in %s/log\n%!"
(Sys.getcwd ());
exit (match st with
| WEXITED n -> n
| WSIGNALED n -> 128 + n
| WSTOPPED _ -> assert false)

View File

@ -0,0 +1,48 @@
(rule
((targets (stdout stderr))
(action (with-stdout-to stdout
(with-stderr-to stderr
(progn
(system "echo toto")
(system "echo titi >&2")))))))
(rule
((targets (both))
(action (with-outputs-to both
(progn
(system "echo toto")
(system "echo titi >&2"))))))
(rule
((targets (stdout.expected))
(action (with-stdout-to ${@} (echo "toto\n")))))
(rule
((targets (stderr.expected))
(action (with-stdout-to ${@} (echo "titi\n")))))
(rule
((targets (both.expected))
(action (with-stdout-to ${@} (echo "toto\ntiti\n")))))
(alias
((name runtest)
(deps (stdout stdout.expected))
(action (run diff -u stdout.expected stdout))))
(alias
((name runtest)
(deps (stderr stderr.expected))
(action (run diff -u stderr.expected stderr))))
(alias
((name runtest)
(deps (both both.expected))
(action (run diff -u both.expected both))))
(alias
((name runtest)
(action (ignore-stdout (echo "\
==========================
If you see this, something is wrong
")))))