[test determinator] Merge test determinator results under buck capture all flavours, add test

Reviewed By: skcho

Differential Revision: D18039141

fbshipit-source-id: 3faef0615
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent 75a18b5027
commit d001db1e94

1
.gitignore vendored

@ -27,6 +27,7 @@ duplicates.txt
*.ast.biniou
/infer/tests/build_systems/buck_flavors_deterministic/capture_hash-*.sha
/infer/tests/build_systems/buck_flavors_diff/src/hello.c
/infer/tests/build_systems/buck_clang_test_determinator/diff.mod.test
/infer/tests/build_systems/buck_export_changed_functions/diff.mod.test
/infer/tests/build_systems/clang_compilation_db_escaped/compile_commands.json
/infer/tests/build_systems/clang_compilation_db_relpath/compile_commands.json

@ -80,6 +80,7 @@ ifneq ($(BUCK),no)
BUILD_SYSTEMS_TESTS += \
buck_blacklist \
buck-clang-db \
buck_clang_test_determinator \
buck_flavors \
buck_flavors_diff \
buck_flavors_run \

@ -27,9 +27,9 @@ let merge_global_tenvs infer_deps_file =
L.progress "Merging type environments took %a@." Mtime.Span.pp (Mtime_clock.count time0)
let merge_changed_functions_json infer_out_src =
let main_changed_fs_file = Config.results_dir ^/ Config.export_changed_functions_output in
let changed_fs_file = infer_out_src ^/ Config.export_changed_functions_output in
let merge_json_results infer_out_src json_file_name =
let main_changed_fs_file = Config.results_dir ^/ json_file_name in
let changed_fs_file = infer_out_src ^/ json_file_name in
let main_json = try YB.from_file main_changed_fs_file |> YBU.to_list with Sys_error _ -> [] in
let changed_json = try YB.from_file changed_fs_file |> YBU.to_list with Sys_error _ -> [] in
let all_fs =
@ -42,12 +42,25 @@ let merge_changed_functions_json infer_out_src =
YB.to_file main_changed_fs_file all_fs
let merge_changed_functions () =
L.progress "Merging changed functions files...@." ;
let merge_all_json_results merge_results results_json_str =
L.progress "Merging %s files...@." results_json_str ;
let infer_deps_file = Config.(results_dir ^/ buck_infer_deps_file_name) in
Utils.iter_infer_deps ~project_root:Config.project_root ~f:merge_changed_functions_json
infer_deps_file ;
L.progress "Done merging changed functions files@."
Utils.iter_infer_deps ~project_root:Config.project_root ~f:merge_results infer_deps_file ;
L.progress "Done merging %s files@." results_json_str
let merge_changed_functions () =
let merge_changed_functions_json infer_out_src =
merge_json_results infer_out_src Config.export_changed_functions_output
in
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 () =

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

@ -412,6 +412,8 @@ let analyze_and_report ?suppress_console_report ~changed_files mode =
in
if should_merge then (
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 () ;
RunState.set_merge_capture false ;
RunState.store () ) ;

@ -0,0 +1,41 @@
# 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.
TESTS_DIR = ../..
include $(TESTS_DIR)/base.make
A_C = src/a.c
B_C = src/b.c
BUCK_TARGET = //src:test
TEST_DETERMINATOR_RESULT = infer-out/test_determinator.json
DIFF_OUTPUT = diff.mod.test
INFER_OPTIONS = --flavors --process-clang-ast --no-linters --no-capture --test-determinator \
--modified-lines $(DIFF_OUTPUT) --project-root $(TESTS_DIR) --profiler-samples profiler_samples.json
$(DIFF_OUTPUT):
$(QUIET)echo -n '$(A_C):' > diff.mod.test
$(QUIET)(diff -N --unchanged-line-format="U" --old-line-format="O" --new-line-format="N" \
$(A_C) src/mod-a.c || [ $$? = 1 ]) >> diff.mod.test
$(QUIET)echo >> diff.mod.test
$(QUIET)echo -n '$(B_C):' >> diff.mod.test
$(QUIET)(diff -N --unchanged-line-format="U" --old-line-format="O" --new-line-format="N" \
$(B_C) src/mod-b.c || [ $$? = 1 ]) >> diff.mod.test
$(QUIET)echo >> diff.mod.test
$(TEST_DETERMINATOR_RESULT): $(DIFF_OUTPUT)
$(QUIET)$(call silent_on_success,Testing test-determinator for clang with set of changes,\
$(INFER_BIN) $(INFER_OPTIONS) -- buck build --no-cache $(BUCK_TARGET))
.PHONY: test
test: $(TEST_DETERMINATOR_RESULT)
$(QUIET)$(call check_no_diff,test_determinator.json.exp,$(TEST_DETERMINATOR_RESULT))
.PHONY: replace
replace: $(TEST_DETERMINATOR_RESULT)
$(COPY) $(TEST_DETERMINATOR_RESULT) test_determinator.json.exp
.PHONY: clean
clean:
$(REMOVE_DIR) *.test infer-out* buck-out*

@ -0,0 +1,35 @@
[
{
"field1": {},
"test": "label_a",
"field2": {},
"native_symbols": [
{
"name": "a_test"
},
{
"name": "example_function10",
"mangled_name" : "example_function10"
}
],
"field3": {}
},
{
"field1": {},
"field2": {},
"field3": {},
"test": "label_b",
"field4": {},
"native_symbols": [
{
"name": "b_test"
},
{
"name": "example_function20",
"mangled_name" : "example_function20"
}
],
"field5": {},
"field6": {}
}
]

@ -0,0 +1,6 @@
cxx_library(
name = 'test',
srcs = [
'a.c', 'b.c',
],
)

@ -0,0 +1,13 @@
/*
* 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.
*/
#include <stdlib.h>
void a_test() {
int* s = NULL;
*s = 42;
}

@ -0,0 +1,12 @@
/*
* 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.
*/
#include <stdlib.h>
void b_test() {
int* s = NULL;
*s = 42;
}

@ -0,0 +1,14 @@
/*
* 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.
*/
#include <stdlib.h>
/* comment */
void a_test() {
int* s = NULL;
*s = 42 + 1;
}

@ -0,0 +1,12 @@
/*
* 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.
*/
#include <stdlib.h>
void b_test() {
int* s = NULL;
*s = 42 + 3;
}
Loading…
Cancel
Save