Skip to content

Commit fc17a0f

Browse files
Phoebe Nicholsfacebook-github-bot
authored andcommitted
Add test for cost change detection with incremental analysis
Summary: Test that cost analysis works with incremental analysis enabled Reviewed By: ezgicicek Differential Revision: D16620101 fbshipit-source-id: b41403954
1 parent f066776 commit fc17a0f

14 files changed

Lines changed: 153 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ duplicates.txt
4545
/infer/tests/build_systems/differential_*/**/Diff*.java
4646
/infer/tests/build_systems/genrule/report.json
4747
/infer/tests/build_systems/incremental_analysis_remove_file/src
48+
/infer/tests/build_systems/incremental_analysis_cost_change/src
4849
/infer/tests/build_systems/java_test_determinator/*.test
4950
/infer/tests/codetoanalyze/java/classloads/*.loads
5051
/infer/tests/codetoanalyze/java/classloads/loads.exp

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ ifeq ($(BUILD_JAVA_ANALYZERS),yes)
127127
BUILD_SYSTEMS_TESTS += \
128128
differential_interesting_paths_filter \
129129
differential_of_costs_report \
130+
incremental_analysis_cost_change \
130131
differential_skip_anonymous_class_renamings \
131132
differential_skip_duplicated_types_on_filenames \
132133
differential_skip_duplicated_types_on_filenames_with_renamings \

infer/tests/build_systems/incremental_analysis_change_procedure/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $(CURRENT_REPORT): $(INFER_CLANG_DEPS) $(SOURCES)
3333
$(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT)
3434
$(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR)
3535
$(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR)
36-
$(QUIET)$(REMOVE_DIR) $@
36+
$(QUIET)$(REMOVE) $@
3737
$(QUIET)$(INFER_BIN) -o $(PREVIOUS_DIR) $(INFER_OPTIONS) -- clang -c src/*.c
3838
$(QUIET)$(COPY) $(PREVIOUS_DIR)/reverse_analysis_callgraph.dot \
3939
reverse_analysis_callgraph.dot.test
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
# E2E test involving the interesting_paths_filter function
7+
8+
TESTS_DIR = ../..
9+
10+
MODIFIED_FILES_FILE = changed_files.txt
11+
SOURCES = $(wildcard src_after/*.java src_before/*.java)
12+
INFER_OPTIONS = --changed-files-index $(MODIFIED_FILES_FILE) \
13+
--incremental-analysis \
14+
--debug-level-analysis 1
15+
16+
include $(TESTS_DIR)/differential.make
17+
18+
.PHONY: compare_cg
19+
compare_cg: $(PREVIOUS_REPORT)
20+
$(QUIET)$(call check_no_diff,\
21+
reverse_analysis_callgraph.dot,\
22+
reverse_analysis_callgraph.dot.test)
23+
24+
replace_cg: $(PREVIOUS_REPORT)
25+
$(COPY) reverse_analysis_callgraph.dot.test reverse_analysis_callgraph.dot
26+
27+
test: compare_cg
28+
replace: replace_cg
29+
30+
$(CURRENT_REPORT): $(INFER_CLANG_DEPS) $(SOURCES)
31+
$(QUIET)$(REMOVE_DIR) src
32+
$(QUIET)$(MKDIR_P) src
33+
$(QUIET)$(COPY) src_after/* src/
34+
$(QUIET)$(INFER_BIN) -o $(CURRENT_DIR) --cost-only --enable-issue-type INFINITE_EXECUTION_TIME -- javac src/*.java
35+
36+
$(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT)
37+
$(QUIET)$(REMOVE_DIR) src
38+
$(QUIET)$(MKDIR_P) src
39+
$(QUIET)$(COPY) src_before/* src/
40+
$(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR)
41+
$(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR)
42+
$(QUIET)$(REMOVE) $@
43+
$(QUIET)$(INFER_BIN) -o $(PREVIOUS_DIR) $(INFER_OPTIONS) --cost-only --enable-issue-type INFINITE_EXECUTION_TIME -- javac src/*.java
44+
$(QUIET)$(COPY) $(PREVIOUS_DIR)/reverse_analysis_callgraph.dot \
45+
reverse_analysis_callgraph.dot.test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/Test.java
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"top":{"current":0,"previous":0},"zero":{"current":6,"previous":6},"degrees":[{"degree":0,"current":3,"previous":4},{"degree":100,"current":3,"previous":1},{"degree":200,"current":0,"previous":1}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/Test.java, Test.complexityDecrease(int):void, 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/Test.java, Test.complexityIncrease(int):void, 0

infer/tests/build_systems/incremental_analysis_cost_change/preexisting.exp

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
digraph callgraph {
3+
N1 [ label = "Test.<init>()", flag = true ];
4+
5+
N5 [ label = "void Test.main(java.lang.String[])", flag = true ];
6+
7+
N0 [ label = "Object.<init>()", flag = false ];
8+
N0 -> N6 ;
9+
N0 -> N1 ;
10+
11+
N7 [ label = "void PrintStream.println(String)", flag = false ];
12+
N7 -> N2 ;
13+
14+
N6 [ label = "Unchanged.<init>()", flag = false ];
15+
16+
N4 [ label = "void Test.complexityIncrease(int)", flag = true ];
17+
N4 -> N5 ;
18+
19+
N2 [ label = "void Unchanged.orderN(int)", flag = false ];
20+
N2 -> N4 ;
21+
N2 -> N3 ;
22+
23+
N3 [ label = "void Test.complexityDecrease(int)", flag = true ];
24+
N3 -> N5 ;
25+
26+
}

0 commit comments

Comments
 (0)