[test determinator] Continuation of refactoring the test determinator code

Reviewed By: ngorogiannis

Differential Revision: D17499359

fbshipit-source-id: e4bd91eb1
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent 637fff5247
commit 825c7af581

@ -99,11 +99,8 @@ let run_clang_frontend ast_source =
L.(debug Capture Medium) L.(debug Capture Medium)
"Start %s of AST from %a@\n" Config.clang_frontend_action_string pp_ast_filename ast_source ; "Start %s of AST from %a@\n" Config.clang_frontend_action_string pp_ast_filename ast_source ;
if Config.linters then AL.do_frontend_checks trans_unit_ctx ast_decl ; if Config.linters then AL.do_frontend_checks trans_unit_ctx ast_decl ;
( if Config.export_changed_functions then if Config.export_changed_functions then
let source_file = trans_unit_ctx.CFrontend_config.source_file in ProcessAST.export_changed_functions trans_unit_ctx ast_decl ;
let clang_range_map = AstToRangeMap.process_ast ast_decl source_file in
TestDeterminator.compute_and_emit_relevant_methods ~clang_range_map ~source_file
~changed_lines_file:Config.modified_lines ) ;
if Config.capture then CFrontend.do_source_file trans_unit_ctx ast_decl ; if Config.capture then CFrontend.do_source_file trans_unit_ctx ast_decl ;
L.(debug Capture Medium) L.(debug Capture Medium)
"End %s of AST file %a... OK!@\n" Config.clang_frontend_action_string pp_ast_filename "End %s of AST file %a... OK!@\n" Config.clang_frontend_action_string pp_ast_filename

@ -0,0 +1,23 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module F = Format
let export_changed_functions trans_unit_ctx ast_decl =
let source_file = trans_unit_ctx.CFrontend_config.source_file in
let f () =
if Config.export_changed_functions then
let clang_range_map = AstToRangeMap.process_ast ast_decl source_file in
TestDeterminator.compute_and_emit_relevant_methods ~clang_range_map ~source_file
in
let call_f () =
CFrontend_errors.protect trans_unit_ctx
~recover:(fun () -> ())
~pp_context:(fun f () -> F.fprintf f "Error when processing %a" SourceFile.pp source_file)
~f
in
call_f ()

@ -0,0 +1,10 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val export_changed_functions :
CFrontend_config.translation_unit_context -> Clang_ast_t.decl -> unit

@ -147,10 +147,7 @@ let () =
if Config.debug_mode && CLOpt.is_originator then ( if Config.debug_mode && CLOpt.is_originator then (
L.progress "Logs in %s@." (Config.results_dir ^/ Config.log_file) ; L.progress "Logs in %s@." (Config.results_dir ^/ Config.log_file) ;
L.progress "Execution ID %Ld@." Config.execution_id ) ; L.progress "Execution ID %Ld@." Config.execution_id ) ;
( if Config.test_determinator then ( if Config.test_determinator then TestDeterminator.compute_and_emit_test_to_run ()
TestDeterminator.compute_and_emit_test_to_run ~changed_lines_file:Config.modified_lines
~test_samples_file:Config.profiler_samples ~code_graph_file:Config.method_decls_info
?clang_range_map:None ?source_file:None
else else
match Config.command with match Config.command with
| Analyze -> | Analyze ->

@ -157,7 +157,8 @@ let emit_relevant_methods relevant_methods =
YB.to_file outpath json YB.to_file outpath json
let compute_and_emit_relevant_methods ~clang_range_map ~source_file ~changed_lines_file = let compute_and_emit_relevant_methods ~clang_range_map ~source_file =
let changed_lines_file = Config.modified_lines in
let changed_lines_map = DiffLines.create_changed_lines_map changed_lines_file in let changed_lines_map = DiffLines.create_changed_lines_map changed_lines_file in
let relevant_methods = let relevant_methods =
compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_map compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_map
@ -166,8 +167,10 @@ let compute_and_emit_relevant_methods ~clang_range_map ~source_file ~changed_lin
(* test_to_run = { n | Affected_Method /\ ts_n != 0 } *) (* test_to_run = { n | Affected_Method /\ ts_n != 0 } *)
let test_to_run ?clang_range_map ?source_file ~code_graph_file ~changed_lines_file let test_to_run ?clang_range_map ?source_file () =
~test_samples_file = let test_samples_file = Config.profiler_samples in
let code_graph_file = Config.method_decls_info in
let changed_lines_file = Config.modified_lines in
let changed_lines_map = DiffLines.create_changed_lines_map changed_lines_file in let changed_lines_map = DiffLines.create_changed_lines_map changed_lines_file in
let affected_methods = let affected_methods =
match (clang_range_map, source_file) with match (clang_range_map, source_file) with
@ -191,10 +194,6 @@ let emit_tests_to_run relevant_tests =
YB.to_file outpath json YB.to_file outpath json
let compute_and_emit_test_to_run ?clang_range_map ?source_file ~code_graph_file ~changed_lines_file let compute_and_emit_test_to_run ?clang_range_map ?source_file () =
~test_samples_file = let relevant_tests = test_to_run ?clang_range_map ?source_file () in
let relevant_tests =
test_to_run ?clang_range_map ~code_graph_file ?source_file ~changed_lines_file
~test_samples_file
in
emit_tests_to_run relevant_tests emit_tests_to_run relevant_tests

@ -10,13 +10,8 @@ open! IStd
val compute_and_emit_test_to_run : val compute_and_emit_test_to_run :
?clang_range_map:(Location.t * Location.t) Typ.Procname.Map.t ?clang_range_map:(Location.t * Location.t) Typ.Procname.Map.t
-> ?source_file:SourceFile.t -> ?source_file:SourceFile.t
-> code_graph_file:string option -> unit
-> changed_lines_file:string option
-> test_samples_file:string option
-> unit -> unit
val compute_and_emit_relevant_methods : val compute_and_emit_relevant_methods :
clang_range_map:(Location.t * Location.t) Typ.Procname.Map.t clang_range_map:(Location.t * Location.t) Typ.Procname.Map.t -> source_file:SourceFile.t -> unit
-> source_file:SourceFile.t
-> changed_lines_file:string option
-> unit

Loading…
Cancel
Save