From 4e8d63ace93a06cb416618714408ae1c41223812 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Mon, 29 Sep 2014 14:41:29 +0200 Subject: Added the -t CLI option This option makes tamasheq print any exception that escaped the eval function. Thus, instead of crashing, tamasheq will exit normally. This option is used in run_tests.sh when some of the tests do fail on purpose (see tests/AssertFalse.ml). --- src/Tamasheq.ml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/Tamasheq.ml') diff --git a/src/Tamasheq.ml b/src/Tamasheq.ml index d5e17b0..22f9d8f 100644 --- a/src/Tamasheq.ml +++ b/src/Tamasheq.ml @@ -27,6 +27,7 @@ let files = Queue.create () let hooks = Queue.create () let intfs = Queue.create () let outdir = ref "." +let test = ref false let load_mli filename outdir = let open Pparse in @@ -108,6 +109,7 @@ let () = "-dlam", Unit (fun () -> denv := not (!dlam)), " Print the Lambda AST"; "-h" , String (fun s -> Queue.add s hooks) , " Run "; "-o" , String (fun s -> outdir := s) , " Output files in "; + "-t" , Unit (fun s -> test := not (!test)), " Always exit successfully"; "--" , Rest (fun s -> Queue.add s argsk) , " (undocumented)"; ] in @@ -144,8 +146,16 @@ let () = List.iter (Printlambda.lambda pp >> Format.print_newline) lambda ; - List.iter (fun l -> ignore @$ eval env [] l) lambda; - - if !denv then - Environment.dump env stderr + try + begin + List.iter (fun l -> ignore @$ eval env [] l) lambda; + + if !denv then + Environment.dump env stderr + end + with exn -> + if !test then + prerr_endline @$ Printexc.to_string exn + else + raise exn end -- cgit v1.2.3-70-g09d2