diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2014-09-29 14:41:29 +0200 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2014-09-29 14:43:44 +0200 |
| commit | 4e8d63ace93a06cb416618714408ae1c41223812 (patch) | |
| tree | a34251b24b0882a91caf8d7824f874f663451095 /src | |
| parent | 5d3d357c39412d2e429668adb04c0b894729e158 (diff) | |
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).
Diffstat (limited to 'src')
| -rw-r--r-- | src/Tamasheq.ml | 16 |
1 files changed, 13 insertions, 3 deletions
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) , "<hook> Run <hook>"; "-o" , String (fun s -> outdir := s) , "<dir> Output files in <dir>"; + "-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; + try + begin + List.iter (fun l -> ignore @$ eval env [] l) lambda; - if !denv then - Environment.dump env stderr + if !denv then + Environment.dump env stderr + end + with exn -> + if !test then + prerr_endline @$ Printexc.to_string exn + else + raise exn end |
