[test determinator] Remove the module JPS.ProfilerSamples that is really just a set of Procnames

Summary: This makes more explicit what we are talking about here. Also, in extending test determinator to clang, the name is incorrect, but the set is generic procnames which is fine to use for clang, just the name is wrong.

Reviewed By: ngorogiannis

Differential Revision: D17855338

fbshipit-source-id: e93bae083
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent df40a1dbd4
commit 16bbc9b934

@ -94,8 +94,8 @@ end
[@@@warning "-32"] [@@@warning "-32"]
let pp_profiler_sample_set fmt s = let pp_profiler_sample_set fmt s =
F.fprintf fmt " (set size = %i) " (JPS.ProfilerSample.cardinal s) ; F.fprintf fmt " (set size = %i) " (Typ.Procname.Set.cardinal s) ;
JPS.ProfilerSample.iter (fun m -> F.fprintf fmt "@\n <Method:> %a " Typ.Procname.pp m) s Typ.Procname.Set.iter (fun m -> F.fprintf fmt "@\n <Method:> %a " Typ.Procname.pp m) s
module TestSample = struct module TestSample = struct
@ -126,16 +126,16 @@ let affected_methods method_range_map file_changed_lines changed_lines =
if if
String.equal method_file file_changed_lines String.equal method_file file_changed_lines
&& List.exists ~f:(fun l -> in_range l range) changed_lines && List.exists ~f:(fun l -> in_range l range) changed_lines
then JPS.ProfilerSample.add key acc then Typ.Procname.Set.add key acc
else acc ) else acc )
method_range_map JPS.ProfilerSample.empty method_range_map Typ.Procname.Set.empty
let compute_affected_methods_java changed_lines_map method_range_map = let compute_affected_methods_java changed_lines_map method_range_map =
String.Map.fold changed_lines_map ~init:JPS.ProfilerSample.empty String.Map.fold changed_lines_map ~init:Typ.Procname.Set.empty
~f:(fun ~key:file_changed_lines ~data acc -> ~f:(fun ~key:file_changed_lines ~data acc ->
let am = affected_methods method_range_map file_changed_lines data in let am = affected_methods method_range_map file_changed_lines data in
JPS.ProfilerSample.union am acc ) Typ.Procname.Set.union am acc )
let compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_map = let compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_map =
@ -144,13 +144,13 @@ let compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_
| Some changed_lines -> | Some changed_lines ->
affected_methods clang_range_map fname changed_lines affected_methods clang_range_map fname changed_lines
| None -> | None ->
JPS.ProfilerSample.empty Typ.Procname.Set.empty
let emit_relevant_methods relevant_methods = let emit_relevant_methods relevant_methods =
let cleaned_methods = let cleaned_methods =
List.dedup_and_sort ~compare:String.compare List.dedup_and_sort ~compare:String.compare
(List.map (JPS.ProfilerSample.elements relevant_methods) ~f:Typ.Procname.to_string) (List.map (Typ.Procname.Set.elements relevant_methods) ~f:Typ.Procname.to_string)
in in
let json = `List (List.map ~f:(fun t -> `String t) cleaned_methods) in let json = `List (List.map ~f:(fun t -> `String t) cleaned_methods) in
let outpath = Config.results_dir ^/ Config.export_changed_functions_output in let outpath = Config.results_dir ^/ Config.export_changed_functions_output in
@ -181,11 +181,11 @@ let test_to_run ?clang_range_map ?source_file () =
compute_affected_methods_java changed_lines_map method_range compute_affected_methods_java changed_lines_map method_range
in in
let profiler_samples = TestSample.read_test_sample test_samples_file in let profiler_samples = TestSample.read_test_sample test_samples_file in
if JPS.ProfilerSample.is_empty affected_methods then [] if Typ.Procname.Set.is_empty affected_methods then []
else else
List.fold profiler_samples ~init:[] ~f:(fun acc (label, profiler_samples) -> List.fold profiler_samples ~init:[] ~f:(fun acc (label, profiler_samples) ->
let intersection = JPS.ProfilerSample.inter affected_methods profiler_samples in let intersection = Typ.Procname.Set.inter affected_methods profiler_samples in
if JPS.ProfilerSample.is_empty intersection then acc else label :: acc ) if Typ.Procname.Set.is_empty intersection then acc else label :: acc )
let emit_tests_to_run relevant_tests = let emit_tests_to_run relevant_tests =

@ -7,7 +7,6 @@
open! IStd open! IStd
module L = Logging module L = Logging
module ProfilerSample = Caml.Set.Make (Typ.Procname)
module JNI = struct module JNI = struct
(* https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html *) (* https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html *)
@ -282,13 +281,13 @@ let create_procname ~classname ~methodname ~signature =
Typ.Procname.Java.Non_Static) Typ.Procname.Java.Non_Static)
type labeled_profiler_sample = string * ProfilerSample.t [@@deriving compare] type labeled_profiler_sample = string * Typ.Procname.Set.t [@@deriving compare]
let equal_labeled_profiler_sample = [%compare.equal: labeled_profiler_sample] let equal_labeled_profiler_sample = [%compare.equal: labeled_profiler_sample]
let from_java_profiler_samples j ~use_signature = let from_java_profiler_samples j ~use_signature =
let process_methods methods = let process_methods methods =
ProfilerSample.of_list Typ.Procname.Set.of_list
(List.map (List.map
~f:(fun {Java_profiler_samples_t.classname; methodname; signature} -> ~f:(fun {Java_profiler_samples_t.classname; methodname; signature} ->
let signature = let signature =

@ -7,8 +7,6 @@
open! IStd open! IStd
module ProfilerSample : Caml.Set.S with type elt = Typ.Procname.t
module JNI : sig module JNI : sig
val void_method_with_no_arguments : string val void_method_with_no_arguments : string
@ -41,7 +39,7 @@ module JNI : sig
end end
end end
type labeled_profiler_sample = string * ProfilerSample.t [@@deriving compare] type labeled_profiler_sample = string * Typ.Procname.Set.t [@@deriving compare]
val equal_labeled_profiler_sample : labeled_profiler_sample -> labeled_profiler_sample -> bool val equal_labeled_profiler_sample : labeled_profiler_sample -> labeled_profiler_sample -> bool

@ -163,7 +163,7 @@ let test_from_json_string_with_valid_input =
assert_equal ~cmp:(List.equal JavaProfilerSamples.equal_labeled_profiler_sample) expected found assert_equal ~cmp:(List.equal JavaProfilerSamples.equal_labeled_profiler_sample) expected found
in in
let input1 = "[{\"test\": \"label1\",\"methods\": []}]" in let input1 = "[{\"test\": \"label1\",\"methods\": []}]" in
let expected1 = [("label1", JavaProfilerSamples.ProfilerSample.of_list [])] in let expected1 = [("label1", Typ.Procname.Set.of_list [])] in
let input2 = let input2 =
Printf.sprintf Printf.sprintf
"[{\"foo\":{},\"test\": \"label1\",\"methods\": [{\"class\": \"ggg.hhh.Iii\", \"boo\": \ "[{\"foo\":{},\"test\": \"label1\",\"methods\": [{\"class\": \"ggg.hhh.Iii\", \"boo\": \
@ -178,7 +178,7 @@ let test_from_json_string_with_valid_input =
in in
let expected2 = let expected2 =
[ ( "label1" [ ( "label1"
, JavaProfilerSamples.ProfilerSample.of_list , Typ.Procname.Set.of_list
[ Typ.Procname.( [ Typ.Procname.(
Java Java
(Java.make (Java.make
@ -198,7 +198,7 @@ let test_from_json_string_with_valid_input =
; mk_split (None, "long") ] ; mk_split (None, "long") ]
Java.Non_Static)) ] ) Java.Non_Static)) ] )
; ( "label2" ; ( "label2"
, JavaProfilerSamples.ProfilerSample.of_list , Typ.Procname.Set.of_list
[ Typ.Procname.( [ Typ.Procname.(
Java Java
(Java.make (Java.make
@ -218,7 +218,7 @@ let test_from_json_string_with_valid_input =
in in
let expected3 = let expected3 =
[ ( "label1" [ ( "label1"
, JavaProfilerSamples.ProfilerSample.of_list , Typ.Procname.Set.of_list
[ Typ.Procname.( [ Typ.Procname.(
Java Java
(Java.make (Java.make
@ -230,7 +230,7 @@ let test_from_json_string_with_valid_input =
(Typ.Name.Java.from_string "ggg.hhh.Iii") (Typ.Name.Java.from_string "ggg.hhh.Iii")
None "<clinit>" [] Java.Non_Static)) ] ) None "<clinit>" [] Java.Non_Static)) ] )
; ( "label2" ; ( "label2"
, JavaProfilerSamples.ProfilerSample.of_list , Typ.Procname.Set.of_list
[ Typ.Procname.( [ Typ.Procname.(
Java Java
(Java.make (Java.make

Loading…
Cancel
Save