You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

# Copyright (c) 2018-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Convention: each Java file must have a single [main] method in the eponymous public class
# This is the root for class loads analysis, and the one executed in the JVM to log loads.
# There is no .exp file committed, the loads are generated by JVM during testing.
TESTS_DIR = ../../..
INFERPRINT_OPTIONS = --issues-tests
SOURCES = $(wildcard *.java)
LOADS = $(patsubst %.java,%.loads,$(SOURCES))
OBJECTS = $(patsubst %.java,%.class,$(SOURCES))
CLASS_LOADS_OPT = $(patsubst %.java,--class-loads-roots %.main,$(SOURCES))
INFER_OPTIONS = --class-loads-only $(CLASS_LOADS_OPT) --debug-exceptions
CLEAN_EXTRA = *.class *.loads loads.exp loads.exp.test
include $(TESTS_DIR)/java.make
INFER_OUT ?= infer-out$(TEST_SUFFIX)
include $(TESTS_DIR)/base.make
.PHONY: clean
clean:
$(REMOVE_DIR) codetoanalyze com issues.exp.test$(TEST_SUFFIX) $(OBJECTS) $(CLEAN_EXTRA)
ifneq ($(INFER_OUT),.)
$(REMOVE_DIR) $(INFER_OUT)
endif
PROJECT_ROOT ?= $(TESTS_DIR)
$(OBJECTS): $(SOURCES)
$(QUIET)$(JAVAC) -cp $(CLASSPATH) $(SOURCES)
issues.exp.test$(TEST_SUFFIX): $(INFER_OUT)/report.json $(INFER_BIN)
$(QUIET)$(INFER_BIN) report -q --results-dir $(<D) \
$(INFERPRINT_OPTIONS) $@ --from-json-report $<
infer-out/report.json: $(JAVA_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(QUIET)$(call silent_on_success,Testing infer/java in $(TEST_REL_DIR),\
$(INFER_BIN) --project-root $(PROJECT_ROOT) \
$(INFER_OPTIONS) -- \
$(JAVAC) -cp $(CLASSPATH) $(SOURCES))
%.loads: %.class
$(QUIET)java -verbose:class $* | grep "^\[Loaded" | cut -f2 -d' ' | grep -vE "^(java|sun)" > $@
loads.exp: $(LOADS)
$(QUIET)for F in $(LOADS) ; do sed -e "s#^#$(TEST_REL_DIR)/$${F%.*}.java, #" $$F ; done | sort > loads.exp
loads.exp.test: issues.exp.test$(TEST_SUFFIX)
$(QUIET)cat $< | sed 's/^\([^,]*\),.*[,\[]\([^,]*\)\]$$/\1, \2/' | sort > $@
.PHONY: test
test: loads.exp loads.exp.test
$(QUIET)cd $(TESTS_DIR) && \
$(call check_no_diff,$(TEST_REL_DIR)/loads.exp,$(TEST_REL_DIR)/loads.exp.test)