Skip to content

Commit

Permalink
Add percentage count do --dry runs
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomhmpereira authored and filipeom committed Oct 4, 2024
1 parent b29147a commit cb621ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ let test debug solver prover_mode print_statistics dry files =
(* TODO: Add proper logs *)
let debug fmt k = if debug then k (Fmt.epr fmt) in
let exception_log = ref [] in
let total_tests = ref 0 in
let exception_count = ref 0 in
let rec test_path state path =
if Sys.is_directory (Fpath.to_string path) then test_dir state path
else begin
debug "File %a...@." (fun k -> k Fpath.pp path);
try
incr total_tests;
let ast = Compile.until_rewrite path in
if dry then begin
state
Expand All @@ -55,6 +58,7 @@ let test debug solver prover_mode print_statistics dry files =
Some (Interpret.start ?state ast)
end
with exn ->
incr exception_count;
let exn_msg = Printexc.to_string exn in
exception_log := (path, exn_msg) :: !exception_log;
debug "Error processing file %a@." (fun k -> k Fpath.pp path);
Expand All @@ -72,6 +76,12 @@ let test debug solver prover_mode print_statistics dry files =
let state = test_files files in
let write_exception_log () =
let oc = open_out "exceptions.log" in
let total = !total_tests in
let exceptions = !exception_count in
let percentage = if total = 0 then 0.0 else (float_of_int exceptions /. float_of_int total) *. 100.0 in
Printf.fprintf oc "Total tests: %d\n" total;
Printf.fprintf oc "Exceptions: %d\n" exceptions;
Printf.fprintf oc "Exception percentage: %.2f%%\n\n" percentage;
List.iter
(fun (path, exn_msg) ->
Printf.fprintf oc "File: %s\nError: %s\n\n" (Fpath.to_string path)
Expand Down
2 changes: 1 addition & 1 deletion src/parser/smtlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ module Statement = struct
let name = (match Symbol.name id with
| Simple name -> name
| _ -> assert false) in
Hashtbl.add custom_sorts name (Expr.ty t);
Hashtbl.replace custom_sorts name (Expr.ty t);
Echo ""

let datatypes ?loc:_ = assert false
Expand Down

0 comments on commit cb621ca

Please sign in to comment.