Skip to content

Commit

Permalink
Don't crash when report doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Dec 10, 2024
1 parent 1c97737 commit 5925d7a
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions bench/runner2/cmd_run.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ module Json = Yojson.Basic

let parse_report output_dir =
let report_path = Fpath.(output_dir / "report.json") in
let json = Json.from_file (Fpath.to_string report_path) in
let json_list = Json.Util.to_list json in
let control_path =
List.exists
(fun json ->
let failures = Json.Util.(member "failures" json |> to_list) in
List.length failures > 0 )
json_list
in
let exploit =
List.exists
(fun json ->
let failures = Json.Util.(member "failures" json |> to_list) in
List.exists
(fun json ->
Json.Util.member "exploit" json
|> Json.Util.member "success" |> Json.Util.to_bool )
failures )
json_list
in
(Fmt.str "%a" (Json.pretty_print ~std:true) json, control_path, exploit)
if not (Sys.file_exists (Fpath.to_string report_path)) then ("", false, false)
else
let json = Json.from_file (Fpath.to_string report_path) in
let json_list = Json.Util.to_list json in
let control_path =
List.exists
(fun json ->
let failures = Json.Util.(member "failures" json |> to_list) in
List.length failures > 0 )
json_list
in
let exploit =
List.exists
(fun json ->
let failures = Json.Util.(member "failures" json |> to_list) in
List.exists
(fun json ->
Json.Util.member "exploit" json
|> Json.Util.member "success" |> Json.Util.to_bool )
failures )
json_list
in
(Fmt.str "%a" (Json.pretty_print ~std:true) json, control_path, exploit)

let work db ({ timestamp; time_limit; output_dir; filter; _ } : Run_metadata.t)
(pkg : Package.t) : Run_result.t list =
Expand Down

0 comments on commit 5925d7a

Please sign in to comment.