Skip to content
Snippets Groups Projects
Commit 9ab45e6b authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[wp] differenciate report-in and report-out for json

parent 8d5abffb
No related branches found
No related tags found
No related merge requests found
...@@ -139,13 +139,22 @@ let do_wp_print_for goals = ...@@ -139,13 +139,22 @@ let do_wp_print_for goals =
let do_wp_report () = let do_wp_report () =
begin begin
let rfiles = Wp_parameters.Report.get () in let reports = Wp_parameters.Report.get () in
if rfiles <> [] then let jreport = Wp_parameters.ReportJson.get () in
if reports <> [] || jreport <> "" then
begin begin
let stats = WpReport.fcstat () in let stats = WpReport.fcstat () in
let jfile = Wp_parameters.ReportJson.get () in begin
if jfile <> "" then WpReport.export_json stats jfile ; match Transitioning.String.split_on_char ':' jreport with
List.iter (WpReport.export stats) rfiles ; | [] | [""] -> ()
| [joutput] ->
WpReport.export_json stats ~joutput () ;
| [jinput;joutput] ->
WpReport.export_json stats ~jinput ~joutput () ;
| _ ->
Wp_parameters.error "Invalid format for option -wp-report-json"
end ;
List.iter (WpReport.export stats) reports ;
end ; end ;
if Wp_parameters.MemoryContext.get () then if Wp_parameters.MemoryContext.get () then
wp_warn_memory_context () wp_warn_memory_context ()
......
...@@ -864,20 +864,29 @@ let export gstat specfile = ...@@ -864,20 +864,29 @@ let export gstat specfile =
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
let export_json gstat jfile = let export_json gstat ?jinput ~joutput () =
begin begin
Wp_parameters.feedback "Report '%s'" jfile ;
let js = let js =
try try
if Sys.file_exists jfile let jfile = match jinput with
then Json.load_file jfile else `Null | None ->
Wp_parameters.feedback "Report '%s'" joutput ;
joutput
| Some jinput ->
Wp_parameters.feedback "Report in: '%s'" jinput ;
Wp_parameters.feedback "Report out: '%s'" joutput ;
jinput
in
if Sys.file_exists jfile then
Json.load_file jfile
else `Null
with Json.Error(file,line,msg) -> with Json.Error(file,line,msg) ->
let source = Log.source ~file ~line in let source = Log.source ~file ~line in
Wp_parameters.error ~source "Incorrect json file: %s" msg ; Wp_parameters.error ~source "Incorrect json file: %s" msg ;
`Null `Null
in in
rankify_fcstat gstat js ; rankify_fcstat gstat js ;
Json.save_file jfile (json_of_fcstat gstat) ; Json.save_file joutput (json_of_fcstat gstat) ;
end end
......
...@@ -47,4 +47,4 @@ type fcstat ...@@ -47,4 +47,4 @@ type fcstat
val fcstat : unit -> fcstat val fcstat : unit -> fcstat
val export : fcstat -> string -> unit val export : fcstat -> string -> unit
val export_json : fcstat -> string -> unit val export_json : fcstat -> ?jinput:string -> joutput:string -> unit -> unit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment