summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Kerneis2014-02-18 16:56:05 +0000
committerGabriel Kerneis2014-02-18 16:56:05 +0000
commit669ced036bc511f6c75b91a9abb3dd3f607cf0a1 (patch)
treeb149a7ecf81c34ceca6da611afbe0fc978e7e8e2 /src
parent3dd4e21dc8a0c1782c3cb8d072388612f270facb (diff)
Report failing tests and return 1 in case of error
Diffstat (limited to 'src')
-rw-r--r--src/lem_interp/run_interp.ml7
-rw-r--r--src/test/run_tests.ml15
2 files changed, 18 insertions, 4 deletions
diff --git a/src/lem_interp/run_interp.ml b/src/lem_interp/run_interp.ml
index 1c3c76d6..2440f60f 100644
--- a/src/lem_interp/run_interp.ml
+++ b/src/lem_interp/run_interp.ml
@@ -157,14 +157,14 @@ let perform_action ((reg, mem) as env) = function
let run (name, test) =
let rec loop env = function
- | Value v -> eprintf "%s: returned %s\n" name (val_to_string v)
+ | Value v -> eprintf "%s: returned %s\n" name (val_to_string v); true
| Action (a, s) ->
eprintf "%s: suspended on action %s\n" name (act_to_string a);
(*eprintf "%s: suspended on action %s, with stack %s\n" name (act_to_string a) (stack_to_string s);*)
let return, env' = perform_action env a in
eprintf "%s: action returned %s\n" name (val_to_string return);
loop env' (resume test s return)
- | Error e -> eprintf "%s: error: %s\n" name e in
+ | Error e -> eprintf "%s: error: %s\n" name e; false in
let entry = E_app((Id "main"), [E_lit L_unit]) in
eprintf "%s: starting\n" name;
try
@@ -172,5 +172,6 @@ let run (name, test) =
loop (Reg.empty, Mem.empty) (interp test entry)
with e ->
let trace = Printexc.get_backtrace () in
- eprintf "%s: interpretor error %s\n%s\n" name (Printexc.to_string e) trace
+ eprintf "%s: interpretor error %s\n%s\n" name (Printexc.to_string e) trace;
+ false
;;
diff --git a/src/test/run_tests.ml b/src/test/run_tests.ml
index ddad139a..2507f178 100644
--- a/src/test/run_tests.ml
+++ b/src/test/run_tests.ml
@@ -1,3 +1,5 @@
+open Printf
+
let tests = [
"test1", Test1.defs;
"test2", Test2.defs;
@@ -7,6 +9,17 @@ let tests = [
"power", Power.defs;
] ;;
-let run_all () = List.iter Run_interp.run tests ;;
+let run_one ((name, _) as t) = (name, Run_interp.run t)
+
+let run_all () =
+ let results = List.map run_one tests in
+ if List.for_all (fun (_, r) -> r) results then
+ eprintf "\nSUCCESS: all tests passed!\n"
+ else begin
+ eprintf "\nFAILURE: the following tests failed:\n";
+ List.iter (fun (name, r) -> if not r then eprintf "- %s\n" name) results;
+ exit 1
+ end
+;;
run_all () ;;