[test determinator] Run test determinator with the buck compilation database flag

Reviewed By: skcho

Differential Revision: D18114215

fbshipit-source-id: 00aba2aa3
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent 0f625659d0
commit 4e7c794334

@ -1214,4 +1214,6 @@ let main ~report_json =
pp_json_report_by_report_kind formats_by_report_kind fname pp_json_report_by_report_kind formats_by_report_kind fname
| None -> | None ->
pp_summary_and_issues formats_by_report_kind issue_formats ) ; pp_summary_and_issues formats_by_report_kind issue_formats ) ;
if Config.test_determinator && Config.process_clang_ast then
TestDeterminator.merge_test_determinator_results () ;
PerfStats.get_reporter PerfStats.Reporting () PerfStats.get_reporter PerfStats.Reporting ()

@ -56,13 +56,6 @@ let merge_changed_functions () =
merge_all_json_results merge_changed_functions_json "changed functions" merge_all_json_results merge_changed_functions_json "changed functions"
let merge_test_determinator_results () =
let merge_test_determinator_json infer_out_src =
merge_json_results infer_out_src Config.test_determinator_output
in
merge_all_json_results merge_test_determinator_json "test determinator result"
let merge_captured_targets () = let merge_captured_targets () =
let time0 = Mtime_clock.counter () in let time0 = Mtime_clock.counter () in
L.progress "Merging captured Buck targets...@\n%!" ; L.progress "Merging captured Buck targets...@\n%!" ;

@ -10,5 +10,3 @@ open! IStd
val merge_captured_targets : unit -> unit val merge_captured_targets : unit -> unit
val merge_changed_functions : unit -> unit val merge_changed_functions : unit -> unit
val merge_test_determinator_results : unit -> unit

@ -296,6 +296,8 @@ let specs_files_suffix = ".specs"
let starvation_issues_dir_name = "starvation_issues" let starvation_issues_dir_name = "starvation_issues"
let test_determinator_results = "test_determinator_results"
(** Enable detailed tracing information during array abstraction *) (** Enable detailed tracing information during array abstraction *)
let trace_absarray = false let trace_absarray = false

@ -179,6 +179,8 @@ val specs_files_suffix : string
val starvation_issues_dir_name : string val starvation_issues_dir_name : string
val test_determinator_results : string
val trace_absarray : bool val trace_absarray : bool
val trace_events_file : string val trace_events_file : string

@ -412,8 +412,6 @@ let analyze_and_report ?suppress_console_report ~changed_files mode =
in in
if should_merge then ( if should_merge then (
if Config.export_changed_functions then MergeCapture.merge_changed_functions () ; if Config.export_changed_functions then MergeCapture.merge_changed_functions () ;
if Config.test_determinator && Config.process_clang_ast then
MergeCapture.merge_test_determinator_results () ;
MergeCapture.merge_captured_targets () ; MergeCapture.merge_captured_targets () ;
RunState.set_merge_capture false ; RunState.set_merge_capture false ;
RunState.store () ) ; RunState.store () ) ;

@ -9,6 +9,7 @@ open! IStd
module L = Logging module L = Logging
module F = Format module F = Format
module YB = Yojson.Basic module YB = Yojson.Basic
module YBU = Yojson.Basic.Util
(* a flag used to make the method search signature sensitive *) (* a flag used to make the method search signature sensitive *)
let use_signature = false let use_signature = false
@ -241,18 +242,47 @@ let clang_test_to_run ~clang_range_map ~source_file () =
else acc ) else acc )
let emit_tests_to_run relevant_tests = let emit_tests_to_run_java relevant_tests =
let json = `List (List.map ~f:(fun t -> `String t) relevant_tests) in let json = `List (List.map ~f:(fun t -> `String t) relevant_tests) in
let outpath = Config.results_dir ^/ Config.test_determinator_output in let outpath = Config.results_dir ^/ Config.test_determinator_output in
YB.to_file outpath json YB.to_file outpath json
let emit_tests_to_run_clang source_file relevant_tests =
if not (List.is_empty relevant_tests) then (
let json = `List (List.map ~f:(fun t -> `String t) relevant_tests) in
let abbrev_source_file = DB.source_file_encoding source_file in
let test_determinator_results_path = Config.results_dir ^/ Config.test_determinator_results in
let outpath = test_determinator_results_path ^/ abbrev_source_file ^ ".json" in
Utils.create_dir test_determinator_results_path ;
Utils.write_json_to_file outpath json )
let compute_and_emit_test_to_run ?clang_range_map ?source_file () = let compute_and_emit_test_to_run ?clang_range_map ?source_file () =
let relevant_tests =
match (clang_range_map, source_file) with match (clang_range_map, source_file) with
| Some clang_range_map, Some source_file -> | Some clang_range_map, Some source_file ->
clang_test_to_run ~clang_range_map ~source_file () let relevant_tests = clang_test_to_run ~clang_range_map ~source_file () in
emit_tests_to_run_clang source_file relevant_tests
| _ -> | _ ->
java_test_to_run () let relevant_tests = java_test_to_run () in
emit_tests_to_run_java relevant_tests
let merge_test_determinator_results () =
let main_results_list = ref [] in
let merge_json_results intermediate_result =
let changed_json =
try YB.from_file intermediate_result |> YBU.to_list with Sys_error _ -> []
in
main_results_list := List.append changed_json !main_results_list
in
let test_determinator_results_path = Config.results_dir ^/ Config.test_determinator_results in
let main_results_file = Config.results_dir ^/ Config.test_determinator_output in
Utils.directory_iter merge_json_results test_determinator_results_path ;
let main_results_list_sorted =
List.dedup_and_sort
~compare:(fun s1 s2 ->
match (s1, s2) with `String s1, `String s2 -> String.compare s1 s2 | _ -> 0 )
!main_results_list
in in
emit_tests_to_run relevant_tests YB.to_file main_results_file (`List main_results_list_sorted)

@ -17,3 +17,5 @@ val compute_and_emit_relevant_methods :
clang_range_map:((Location.t * Location.t) * ClangProc.t option) Typ.Procname.Map.t clang_range_map:((Location.t * Location.t) * ClangProc.t option) Typ.Procname.Map.t
-> source_file:SourceFile.t -> source_file:SourceFile.t
-> unit -> unit
val merge_test_determinator_results : unit -> unit

@ -11,8 +11,8 @@ B_C = src/b.c
BUCK_TARGET = //src:test BUCK_TARGET = //src:test
TEST_DETERMINATOR_RESULT = infer-out/test_determinator.json TEST_DETERMINATOR_RESULT = infer-out/test_determinator.json
DIFF_OUTPUT = diff.mod.test DIFF_OUTPUT = diff.mod.test
INFER_OPTIONS = --flavors --process-clang-ast --no-linters --no-capture --test-determinator \ INFER_OPTIONS = --buck-compilation-database no-deps --process-clang-ast --no-linters --no-capture --test-determinator \
--modified-lines $(DIFF_OUTPUT) --project-root $(TESTS_DIR) --profiler-samples profiler_samples.json --modified-lines $(DIFF_OUTPUT) --profiler-samples profiler_samples.json
$(DIFF_OUTPUT): $(DIFF_OUTPUT):
$(QUIET)echo -n '$(A_C):' > diff.mod.test $(QUIET)echo -n '$(A_C):' > diff.mod.test

@ -1 +1 @@
["label1_block","label1_objc_method","label1_c_function"] ["label1_block","label1_c_function","label1_objc_method"]

@ -1 +1 @@
["label2_block","label2_objc_method","label2_c_function"] ["label2_block","label2_c_function","label2_objc_method"]
Loading…
Cancel
Save