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
master
Phoebe Nichols 5 years ago committed by Facebook Github Bot
parent f066776b17
commit fc17a0fce3

1
.gitignore vendored

@ -45,6 +45,7 @@ duplicates.txt
/infer/tests/build_systems/differential_*/**/Diff*.java /infer/tests/build_systems/differential_*/**/Diff*.java
/infer/tests/build_systems/genrule/report.json /infer/tests/build_systems/genrule/report.json
/infer/tests/build_systems/incremental_analysis_remove_file/src /infer/tests/build_systems/incremental_analysis_remove_file/src
/infer/tests/build_systems/incremental_analysis_cost_change/src
/infer/tests/build_systems/java_test_determinator/*.test /infer/tests/build_systems/java_test_determinator/*.test
/infer/tests/codetoanalyze/java/classloads/*.loads /infer/tests/codetoanalyze/java/classloads/*.loads
/infer/tests/codetoanalyze/java/classloads/loads.exp /infer/tests/codetoanalyze/java/classloads/loads.exp

@ -127,6 +127,7 @@ ifeq ($(BUILD_JAVA_ANALYZERS),yes)
BUILD_SYSTEMS_TESTS += \ BUILD_SYSTEMS_TESTS += \
differential_interesting_paths_filter \ differential_interesting_paths_filter \
differential_of_costs_report \ differential_of_costs_report \
incremental_analysis_cost_change \
differential_skip_anonymous_class_renamings \ differential_skip_anonymous_class_renamings \
differential_skip_duplicated_types_on_filenames \ differential_skip_duplicated_types_on_filenames \
differential_skip_duplicated_types_on_filenames_with_renamings \ differential_skip_duplicated_types_on_filenames_with_renamings \

@ -33,7 +33,7 @@ $(CURRENT_REPORT): $(INFER_CLANG_DEPS) $(SOURCES)
$(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT) $(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT)
$(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR) $(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR)
$(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR) $(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR)
$(QUIET)$(REMOVE_DIR) $@ $(QUIET)$(REMOVE) $@
$(QUIET)$(INFER_BIN) -o $(PREVIOUS_DIR) $(INFER_OPTIONS) -- clang -c src/*.c $(QUIET)$(INFER_BIN) -o $(PREVIOUS_DIR) $(INFER_OPTIONS) -- clang -c src/*.c
$(QUIET)$(COPY) $(PREVIOUS_DIR)/reverse_analysis_callgraph.dot \ $(QUIET)$(COPY) $(PREVIOUS_DIR)/reverse_analysis_callgraph.dot \
reverse_analysis_callgraph.dot.test reverse_analysis_callgraph.dot.test

@ -0,0 +1,45 @@
# 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.
# E2E test involving the interesting_paths_filter function
TESTS_DIR = ../..
MODIFIED_FILES_FILE = changed_files.txt
SOURCES = $(wildcard src_after/*.java src_before/*.java)
INFER_OPTIONS = --changed-files-index $(MODIFIED_FILES_FILE) \
--incremental-analysis \
--debug-level-analysis 1
include $(TESTS_DIR)/differential.make
.PHONY: compare_cg
compare_cg: $(PREVIOUS_REPORT)
$(QUIET)$(call check_no_diff,\
reverse_analysis_callgraph.dot,\
reverse_analysis_callgraph.dot.test)
replace_cg: $(PREVIOUS_REPORT)
$(COPY) reverse_analysis_callgraph.dot.test reverse_analysis_callgraph.dot
test: compare_cg
replace: replace_cg
$(CURRENT_REPORT): $(INFER_CLANG_DEPS) $(SOURCES)
$(QUIET)$(REMOVE_DIR) src
$(QUIET)$(MKDIR_P) src
$(QUIET)$(COPY) src_after/* src/
$(QUIET)$(INFER_BIN) -o $(CURRENT_DIR) --cost-only --enable-issue-type INFINITE_EXECUTION_TIME -- javac src/*.java
$(PREVIOUS_REPORT): $(INFER_CLANG_DEPS) $(SOURCES) $(CURRENT_REPORT)
$(QUIET)$(REMOVE_DIR) src
$(QUIET)$(MKDIR_P) src
$(QUIET)$(COPY) src_before/* src/
$(QUIET)$(REMOVE_DIR) $(PREVIOUS_DIR)
$(QUIET)$(COPY) -r $(CURRENT_DIR) $(PREVIOUS_DIR)
$(QUIET)$(REMOVE) $@
$(QUIET)$(INFER_BIN) -o $(PREVIOUS_DIR) $(INFER_OPTIONS) --cost-only --enable-issue-type INFINITE_EXECUTION_TIME -- javac src/*.java
$(QUIET)$(COPY) $(PREVIOUS_DIR)/reverse_analysis_callgraph.dot \
reverse_analysis_callgraph.dot.test

@ -0,0 +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}]}

@ -0,0 +1 @@
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/Test.java, Test.complexityDecrease(int):void, 0

@ -0,0 +1 @@
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/Test.java, Test.complexityIncrease(int):void, 0

@ -0,0 +1,26 @@
digraph callgraph {
N1 [ label = "Test.<init>()", flag = true ];
N5 [ label = "void Test.main(java.lang.String[])", flag = true ];
N0 [ label = "Object.<init>()", flag = false ];
N0 -> N6 ;
N0 -> N1 ;
N7 [ label = "void PrintStream.println(String)", flag = false ];
N7 -> N2 ;
N6 [ label = "Unchanged.<init>()", flag = false ];
N4 [ label = "void Test.complexityIncrease(int)", flag = true ];
N4 -> N5 ;
N2 [ label = "void Unchanged.orderN(int)", flag = false ];
N2 -> N4 ;
N2 -> N3 ;
N3 [ label = "void Test.complexityDecrease(int)", flag = true ];
N3 -> N5 ;
}

@ -0,0 +1,22 @@
/*
* 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.
*/
class Test {
public static void complexityDecrease(int n) {
Unchanged.orderN(n);
}
public static void complexityIncrease(int n) {
Unchanged.orderN(n);
}
public static void main(String args[]) {
complexityDecrease(10);
complexityIncrease(10);
}
}

@ -0,0 +1,15 @@
/*
* 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.
*/
class Unchanged {
public static void orderN(int n) {
for (int i = 0; i < n; i++) {
System.out.println("hi");
}
}
}

@ -0,0 +1,24 @@
/*
* 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.
*/
class Test {
public static void complexityDecrease(int n) {
for (int i = 0; i < n; i++) {
Unchanged.orderN(i);
}
}
public static void complexityIncrease(int n) {
Unchanged.orderN(1);
}
public static void main(String args[]) {
complexityDecrease(10);
complexityIncrease(10);
}
}

@ -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.
*/
class Unchanged {
public static void orderN(int n) {
for (int i = 0; i < n; i++) {
System.out.println("hi");
}
}
}
Loading…
Cancel
Save