[test determinator] avoid exceptions

Summary: Remove unsafe invocations of `String.rsplit2_exn` as this code may run on C++.

Reviewed By: dulmarod, jvillard

Differential Revision: D22042750

fbshipit-source-id: b2879e17b
master
Nikos Gorogiannis 5 years ago committed by Facebook GitHub Bot
parent 753b909bfa
commit 75302f2de8

@ -15,9 +15,7 @@ module YBU = Yojson.Basic.Util
let use_signature = false let use_signature = false
module MethodRangeMap = struct module MethodRangeMap = struct
let split_class_method_name qualified_method_name = let split_class_method_name qualified_method_name = String.rsplit2 qualified_method_name ~on:'.'
String.rsplit2_exn qualified_method_name ~on:'.'
let create_java_method_range_map code_graph_file_opt = let create_java_method_range_map code_graph_file_opt =
match code_graph_file_opt with match code_graph_file_opt with
@ -44,14 +42,13 @@ module MethodRangeMap = struct
; file= SourceFile.create ~warn_on_error:false decl.source_file } ; file= SourceFile.create ~warn_on_error:false decl.source_file }
in in
let range = (start_location, end_location) in let range = (start_location, end_location) in
let classname, methodname = split_class_method_name decl.method_name in match (split_class_method_name decl.method_name, decl.signature) with
match decl.signature with | Some (classname, methodname), Some signature ->
| Some signature ->
let key = let key =
JProcname.create_procname ~use_signature ~classname ~methodname ~signature JProcname.create_procname ~use_signature ~classname ~methodname ~signature
in in
Procname.Map.add key (range, ()) acc Procname.Map.add key (range, ()) acc
| None -> | _ ->
acc ) acc )
| _ -> | _ ->
L.die UserError "Missing method declaration info argument" L.die UserError "Missing method declaration info argument"
@ -69,7 +66,10 @@ module DiffLines = struct
match Utils.read_file changed_lines_file with match Utils.read_file changed_lines_file with
| Ok cl_list -> | Ok cl_list ->
List.fold cl_list ~init:String.Map.empty ~f:(fun acc cl_item -> List.fold cl_list ~init:String.Map.empty ~f:(fun acc cl_item ->
let fname, cl = String.rsplit2_exn ~on:':' cl_item in match String.rsplit2 ~on:':' cl_item with
| None ->
acc
| Some (fname, cl) ->
String.Map.set acc ~key:fname ~data:(FileDiff.parse_unix_diff cl) ) String.Map.set acc ~key:fname ~data:(FileDiff.parse_unix_diff cl) )
| Error _ -> | Error _ ->
L.die UserError "Could not read file %s" changed_lines_file ) L.die UserError "Could not read file %s" changed_lines_file )

Loading…
Cancel
Save