From a6be58848b000c0b87969cbed5425d8c32fcaa27 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 15 Dec 2016 08:59:58 -0800 Subject: [PATCH] [make] make frontend tests more functional Summary: These direct tests were still mostly relying on PHONY targets. Reviewed By: jberdine Differential Revision: D4326469 fbshipit-source-id: 37b2d0a --- Makefile.config.in | 8 +- infer/tests/build_systems/ant/Makefile | 2 +- infer/tests/build_systems/buck/Makefile | 4 +- .../clang_compilation_db/Makefile | 8 +- .../build_systems/clang_translation/Makefile | 43 ++++----- infer/tests/clang-base.make | 18 ++++ infer/tests/clang-frontend.make | 38 ++++++-- infer/tests/clang.make | 16 +--- infer/tests/codetoanalyze/c/frontend/Makefile | 6 -- .../tests/codetoanalyze/cpp/checkers/Makefile | 2 +- infer/tests/codetoanalyze/cpp/errors/Makefile | 2 +- .../tests/codetoanalyze/cpp/frontend/Makefile | 12 +-- .../tests/codetoanalyze/cpp/quandary/Makefile | 2 +- .../tests/codetoanalyze/objc/errors/Makefile | 8 +- .../codetoanalyze/objc/frontend/Makefile | 94 +++---------------- .../codetoanalyze/objc/frontend/arc/Makefile | 31 ++++++ .../objc/frontend/noarc/Makefile | 70 ++++++++++++++ .../codetoanalyze/objcpp/frontend/Makefile | 6 -- infer/tests/javac.make | 2 +- 19 files changed, 206 insertions(+), 166 deletions(-) create mode 100644 infer/tests/clang-base.make create mode 100644 infer/tests/codetoanalyze/objc/frontend/arc/Makefile create mode 100644 infer/tests/codetoanalyze/objc/frontend/noarc/Makefile diff --git a/Makefile.config.in b/Makefile.config.in index fc9c596f8..352e5862a 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -52,17 +52,13 @@ XCODE_SELECT = @XCODE_SELECT@ ifneq (,$(findstring s,$(MAKEFLAGS))) # quiet mode LN_S = @LN_S@ -REMOVE = rm -f -REMOVE_DIR = rm -rf -RSYNC_A = rsync -av else LN_S = @LN_S@ -v -REMOVE = rm -vf -REMOVE_DIR = rm -rvf -RSYNC_A = rsync -aq endif COPY = cp -f COPY_DIR = cp -Rf +REMOVE = rm -f +REMOVE_DIR = rm -rf ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd) diff --git a/infer/tests/build_systems/ant/Makefile b/infer/tests/build_systems/ant/Makefile index 0c705ecdd..c5a024725 100644 --- a/infer/tests/build_systems/ant/Makefile +++ b/infer/tests/build_systems/ant/Makefile @@ -18,7 +18,7 @@ include $(TESTS_DIR)/base.make $(OBJECTS): $(SOURCES) ant -infer-out/report.json: $(INFER_BIN) $(SOURCES) +infer-out/report.json: $(JAVA_DEPS) $(SOURCES) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) --project-root $(TESTS_DIR) --inferconfig-home . -- ant) diff --git a/infer/tests/build_systems/buck/Makefile b/infer/tests/build_systems/buck/Makefile index b5d7470e3..b463dc61c 100644 --- a/infer/tests/build_systems/buck/Makefile +++ b/infer/tests/build_systems/buck/Makefile @@ -5,8 +5,6 @@ # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. -CURDIR = $(shell pwd) - TESTS_DIR = ../.. ROOT_DIR = $(TESTS_DIR)/../.. @@ -26,5 +24,5 @@ $(JAR_OUTPUT): $(JAVA_SOURCE_FILES) genrule: $(JAR_OUTPUT) cd $(ROOT_DIR) && $(call silent_on_success, INFER_BIN=$(INFER_BIN) NO_BUCKD=1 GENERATE_INFER_GENRULES=1 buck build --no-cache //infer/tests/build_systems/genrule/module2:module2_infer) -infer-out/report.json: genrule $(INFER_BIN) $(JAVA_SOURCE_FILES) +infer-out/report.json: genrule $(JAVA_DEPS) $(JAVA_SOURCE_FILES) cd $(ROOT_DIR) && $(call silent_on_success, INFER_BIN=$(INFER_BIN) NO_BUCKD=1 $(INFER_BIN) -a $(ANALYZER) --results-dir $(CURDIR)/infer-out -- buck build --no-cache //infer/tests/codetoanalyze/java/infer:compile) diff --git a/infer/tests/build_systems/clang_compilation_db/Makefile b/infer/tests/build_systems/clang_compilation_db/Makefile index 544ac1cfb..c81f128ae 100644 --- a/infer/tests/build_systems/clang_compilation_db/Makefile +++ b/infer/tests/build_systems/clang_compilation_db/Makefile @@ -12,7 +12,7 @@ CMAKE_BUILD_DIR = $(CMAKE_DIR)/_build ANALYZER = infer CLEAN_EXTRA = $(CMAKE_BUILD_DIR) -INFER_OPTIONS = --cxx --report-custom-error --developer-mode --project-root $(CMAKE_DIR) +INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(CMAKE_DIR) SOURCES = $(CMAKE_DIR)/hello.cpp OBJECTS = $(CMAKE_BUILD_DIR)/compile_commands.json INFERPRINT_OPTIONS = --issues-tests @@ -29,15 +29,15 @@ $(CMAKE_BUILD_DIR)/compile_commands.json: $(SOURCES) $(CMAKE_DIR)/CMakeLists.txt infer-out/report.json: # make this target empty - since this test defines issues.exp.test directly -infer-out-with-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(INFER_BIN) $(SOURCES) +infer-out-with-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG_DEPS) $(SOURCES) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -o infer-out-with-index --changed-files-index $(CMAKE_DIR)/index.txt --clang-compilation-db-files $<) -infer-out-no-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(INFER_BIN) $(SOURCES) +infer-out-no-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG_DEPS) $(SOURCES) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -o infer-out-no-index --clang-compilation-db-files $<) -infer-out-reactive-capture/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(INFER_BIN) $(SOURCES) +infer-out-reactive-capture/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG_DEPS) $(SOURCES) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -o infer-out-reactive-capture --reactive-capture \ --changed-files-index $(CMAKE_DIR)/index.txt --clang-compilation-db-files $<) diff --git a/infer/tests/build_systems/clang_translation/Makefile b/infer/tests/build_systems/clang_translation/Makefile index 554777af2..29fa30edf 100644 --- a/infer/tests/build_systems/clang_translation/Makefile +++ b/infer/tests/build_systems/clang_translation/Makefile @@ -19,40 +19,35 @@ SOURCES = \ $(SYM_ROOT)/main_symlink.cpp \ $(SYM_ROOT)/main_default_symlink.cpp \ -include $(TESTS_DIR)/clang-frontend.make +DOT_FILES = $(SOURCES:=.test.dot) +CLEAN_EXTRA = $(DOT_FILES) $(foreach source,$(SOURCES),infer-out-$(basename $(notdir $(source)))) -INFER_OPTIONS = -a capture --frontend-tests --cxx --skip-translation-headers exclude_dir +include $(TESTS_DIR)/clang-frontend.make -compile: - clang $(CLANG_OPTIONS) $(SOURCES) +INFER_OPTIONS = -a capture --frontend-tests --skip-translation-headers exclude_dir -capture: - $(call silent_on_success,\ - $(INFER_BIN) $(INFER_OPTIONS) --project-root $(ROOT) \ - --icfg-dotty-outfile $(ROOT)/main.cpp.test.dot -- \ - clang $(CLANG_OPTIONS) $(ROOT)/main.cpp) - - $(call silent_on_success,\ - $(INFER_BIN) $(INFER_OPTIONS) --project-root $(SYM_ROOT) \ - --icfg-dotty-outfile $(SYM_ROOT)/main_symlink.cpp.test.dot -- \ - clang $(CLANG_OPTIONS) $(SYM_ROOT)/main.cpp) +capture: $(DOT_FILES) - cd $(ROOT) && \ +$(ROOT)/main.cpp.test.dot $(SYM_ROOT)/main_symlink.cpp.test.dot: $(SOURCES) $(CLANG_DEPS) $(call silent_on_success,\ - $(INFER_BIN) $(INFER_OPTIONS) --icfg-dotty-outfile main_default_root.cpp.test.dot -- \ - clang $(CLANG_OPTIONS) main.cpp) + $(INFER_BIN) $(INFER_OPTIONS) --results-dir infer-out-$(basename $(@F:.test.dot=)) \ + --project-root $(ROOT) --icfg-dotty-outfile $@ -- \ + clang $(CLANG_OPTIONS) $(@:.test.dot=)) - cd $(SYM_ROOT) && \ +$(ROOT)/main_default_root.cpp.test.dot $(SYM_ROOT)/main_default_symlink.cpp.test.dot: \ + $(CLANG_DEPS) $(SOURCES) + cd $(@D) && \ $(call silent_on_success,\ - $(INFER_BIN) $(INFER_OPTIONS) --icfg-dotty-outfile main_default_symlink.cpp.test.dot -- \ - clang $(CLANG_OPTIONS) main.cpp) + $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out-$(basename $(@F:.test.dot=)) \ + --icfg-dotty-outfile $(@F) -- \ + clang $(CLANG_OPTIONS) $(@F:.test.dot=)) # test_extra needs to be separate target. Otherwise commands from test # target in common Makefile won't run test: test_extra # all dot files should be exactly the same - if they aren't there is something wrong -test_extra: - diff $(ROOT)/main.cpp.dot $(SYM_ROOT)/main_symlink.cpp.dot && \ - diff $(ROOT)/main.cpp.dot $(ROOT)/main_default_root.cpp.dot && \ - diff $(ROOT)/main.cpp.dot $(SYM_ROOT)/main_default_symlink.cpp.dot +test_extra: $(DOT_FILES) + diff -u $(ROOT)/main.cpp.test.dot $(SYM_ROOT)/main_symlink.cpp.test.dot + diff -u $(ROOT)/main.cpp.test.dot $(ROOT)/main_default_root.cpp.test.dot + diff -u $(ROOT)/main.cpp.test.dot $(SYM_ROOT)/main_default_symlink.cpp.test.dot diff --git a/infer/tests/clang-base.make b/infer/tests/clang-base.make new file mode 100644 index 000000000..ede85a4f3 --- /dev/null +++ b/infer/tests/clang-base.make @@ -0,0 +1,18 @@ +# Copyright (c) 2016 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +%.o: %.c + clang $(CLANG_OPTIONS) -o $@ $< + +%.o: %.cpp + clang++ $(CLANG_OPTIONS) -o $@ $< + +%.o: %.m + clang $(CLANG_OPTIONS) -o $@ $< + +%.o: %.mm + clang++ $(CLANG_OPTIONS) -o $@ $< diff --git a/infer/tests/clang-frontend.make b/infer/tests/clang-frontend.make index 4407f256f..4f05d1a90 100644 --- a/infer/tests/clang-frontend.make +++ b/infer/tests/clang-frontend.make @@ -8,20 +8,40 @@ ROOT_DIR = $(TESTS_DIR)/../.. include $(ROOT_DIR)/Makefile.config +OBJECTS = $(foreach source,$(SOURCES),$(basename $(source)).o) + +include $(TESTS_DIR)/clang-base.make + +ONE_SOURCE = $(lastword $(SOURCES)) + default: compile +compile: $(OBJECTS) + +$(ONE_SOURCE).test.dot: $(CLANG_DEPS) $(SOURCES) $(HEADERS) + $(call silent_on_success, \ + $(INFER_BIN) -a capture --frontend-tests --project-root $(TESTS_DIR) $(INFER_OPTIONS) -- \ + clang $(CLANG_OPTIONS) $(SOURCES)) + +.PHONY: capture +capture: $(ONE_SOURCE).test.dot + +.PHONY: print +print: capture + +.PHONY: test test: capture - set -e; \ - for file in $(SOURCES) ; do \ - diff -u $$file.dot $$file.test.dot ; \ - done - $(MAKE) clean + @for file in $(SOURCES) ; do \ + diff -u $$file.dot $$file.test.dot || error=1 ; \ + done ; \ + if [ 0$$error -eq 1 ]; then exit 1; fi +.PHONY: replace replace: capture - for file in $(SOURCES) ; do \ - mv $$file.test.dot $$file.dot ; \ + @for file in $(SOURCES) ; do \ + mv $$file.test.dot $$file.dot ; \ done - $(MAKE) clean +.PHONY: clean clean: - rm -rf infer-out *.o */*.test.dot */*/*.test.dot + $(REMOVE_DIR) infer-out $(OBJECTS) */*.test.dot */*/*.test.dot $(CLEAN_EXTRA) diff --git a/infer/tests/clang.make b/infer/tests/clang.make index 817c72e7a..33d11f1bd 100644 --- a/infer/tests/clang.make +++ b/infer/tests/clang.make @@ -7,24 +7,14 @@ ROOT_DIR = $(TESTS_DIR)/../.. -OBJECTS = $(foreach source,$(SOURCES),$(basename $(source)).o) CLEAN_EXTRA += duplicates.txt +OBJECTS = $(foreach source,$(SOURCES),$(basename $(source)).o) + include $(TESTS_DIR)/base.make +include $(TESTS_DIR)/clang-base.make infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(HEADERS) $(call silent_on_success,\ $(INFER_BIN) --check-duplicate-symbols $(INFER_OPTIONS) -a $(ANALYZER) -- clang $(CLANG_OPTIONS) $(SOURCES) 2>duplicates.txt) grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 - -%.o: %.c - clang $(CLANG_OPTIONS) -o $@ $< - -%.o: %.cpp - clang++ $(CLANG_OPTIONS) -o $@ $< - -%.o: %.m - clang $(CLANG_OPTIONS) -o $@ $< - -%.o: %.mm - clang++ $(CLANG_OPTIONS) -o $@ $< diff --git a/infer/tests/codetoanalyze/c/frontend/Makefile b/infer/tests/codetoanalyze/c/frontend/Makefile index 010499b96..6e6cb853d 100644 --- a/infer/tests/codetoanalyze/c/frontend/Makefile +++ b/infer/tests/codetoanalyze/c/frontend/Makefile @@ -14,9 +14,3 @@ SOURCES = \ $(wildcard */*.cpp) \ include $(TESTS_DIR)/clang-frontend.make - -compile: - clang $(CLANG_OPTIONS) $(SOURCES) - -capture: - $(call silent_on_success,$(INFER_BIN) -a capture --frontend-tests --cxx --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES)) diff --git a/infer/tests/codetoanalyze/cpp/checkers/Makefile b/infer/tests/codetoanalyze/cpp/checkers/Makefile index 4c41574a8..f2437e383 100644 --- a/infer/tests/codetoanalyze/cpp/checkers/Makefile +++ b/infer/tests/codetoanalyze/cpp/checkers/Makefile @@ -10,7 +10,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers # see explanations in cpp/errors/Makefile for the custom isystem CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/cpp/errors/Makefile b/infer/tests/codetoanalyze/cpp/errors/Makefile index 32610a465..611b88b03 100644 --- a/infer/tests/codetoanalyze/cpp/errors/Makefile +++ b/infer/tests/codetoanalyze/cpp/errors/Makefile @@ -12,7 +12,7 @@ ANALYZER = infer # Use the system headers of our own clang. This way, we always use the same system headers # regardless of the libraries installed on the machine. CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/cpp/frontend/Makefile b/infer/tests/codetoanalyze/cpp/frontend/Makefile index b24e44865..1c55f02f9 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/cpp/frontend/Makefile @@ -8,16 +8,14 @@ TESTS_DIR=../../.. # see explanations in cpp/errors/Makefile for the custom isystem -CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c +CLANG_OPTIONS = \ + -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ \ + -x c++ -std=c++11 -c +INFER_OPTIONS = --headers + SOURCES = \ $(wildcard */*.cpp) \ $(wildcard shared/*/*.cpp) \ include $(TESTS_DIR)/clang-frontend.make - -compile: - clang $(CLANG_OPTIONS) $(SOURCES) - -capture: - $(call silent_on_success,$(INFER_BIN) -a capture --frontend-tests --cxx --headers --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES)) diff --git a/infer/tests/codetoanalyze/cpp/quandary/Makefile b/infer/tests/codetoanalyze/cpp/quandary/Makefile index dc373ef9b..2d34259f8 100644 --- a/infer/tests/codetoanalyze/cpp/quandary/Makefile +++ b/infer/tests/codetoanalyze/cpp/quandary/Makefile @@ -10,7 +10,7 @@ TESTS_DIR = ../../.. ANALYZER = quandary # see explanations in cpp/errors/Makefile for the custom isystem CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c -INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/objc/errors/Makefile b/infer/tests/codetoanalyze/objc/errors/Makefile index a61b21356..445672ce2 100644 --- a/infer/tests/codetoanalyze/objc/errors/Makefile +++ b/infer/tests/codetoanalyze/objc/errors/Makefile @@ -18,7 +18,7 @@ CLANG_OPTIONS = -x objective-c \ CLEAN_EXTRA = infer-out-arc infer-out-all infer-out-all infer-out-arc \ issues.exp.test.all issues.exp.test.arc issues.exp.test.default -INFER_OPTIONS = --cxx --check-duplicate-symbols --no-filtering --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --check-duplicate-symbols --no-filtering --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES_DEFAULT = \ @@ -110,19 +110,19 @@ $(OBJECTS_ARC): $(SOURCES_ARC) $(OBJECTS_BASE) $(OBJECTS_BUCKETS_ALL): $(SOURCES_BASE) $(SOURCES_BUCKET_ALL) clang $(CLANG_OPTIONS) $* -infer-out-all/report.json: $(INFER_BIN) $(SOURCES_BUCKET_ALL) +infer-out-all/report.json: $(CLANG_DEPS) $(SOURCES_BUCKET_ALL) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) --ml-buckets all -o infer-out-all -- \ clang $(CLANG_OPTIONS) $(SOURCES_BUCKET_ALL) 2>duplicates.txt) grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 -infer-out-arc/report.json: $(INFER_BIN) $(SOURCES_ARC) +infer-out-arc/report.json: $(CLANG_DEPS) $(SOURCES_ARC) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) --ml-buckets cf -o infer-out-arc -- \ clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC) 2>duplicates.txt) grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 -infer-out/report.json: $(INFER_BIN) $(SOURCES_DEFAULT) +infer-out/report.json: $(CLANG_DEPS) $(SOURCES_DEFAULT) $(call silent_on_success,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) --ml-buckets cf -o infer-out -- \ clang $(CLANG_OPTIONS) $(SOURCES_DEFAULT) 2>duplicates.txt) diff --git a/infer/tests/codetoanalyze/objc/frontend/Makefile b/infer/tests/codetoanalyze/objc/frontend/Makefile index 3e376ec39..0d13b5bc9 100644 --- a/infer/tests/codetoanalyze/objc/frontend/Makefile +++ b/infer/tests/codetoanalyze/objc/frontend/Makefile @@ -5,88 +5,24 @@ # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. -TESTS_DIR=../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk +.PHONY: arc.clean noarc.clean +%.clean: + @$(MAKE) -C $% clean -XCODEROOT = $(shell xcode-select -p) +.PHONY: arc.print noarc.print +%.print: + @$(MAKE) -C $% print -CLANG_OPTIONS = -x objective-c \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ +.PHONY: arc.test noarc.test +%.test: + @$(MAKE) -C $% test -SOURCES_NOARC = \ - block/retain_cycle.m \ - block/static.m \ - boxing/Boxing.m \ - boxing/array.m \ - boxing/array_literal.c \ - boxing/dict_literal.c \ - boxing/string_literal.c \ - conditional_operation/ConditionalOperation.m \ - exceptions/ExceptionExample.m \ - fast_enumeration/Fast_enumeration.m \ - property/PropertyCustomAccessor.m \ - property/PropertyImplSetter.m \ - property/Property_getter.m \ - property/aclass.m \ - property/main_car.m \ - property_in_protocol/Test.m \ - protocol/protocol.m \ - returnstmt/void_return.m \ - self_static/Self.m \ - self_static/static.m \ - shared/block/block-it.m \ - shared/block/block.m \ - shared/block/block_no_args.m \ - shared/block/block_release.m \ - shared/block/dispatch.m \ - shared/block/dispatch_examples.m \ - shared/block/dispatch_in_macro.m \ - shared/category_procdesc/EOCPerson.m \ - shared/category_procdesc/main.c \ - shared/field_superclass/SuperExample.m \ - shared/memory_leaks_benchmark/AutoreleaseExample.m \ - shared/memory_leaks_benchmark/MemoryLeakExample.m \ - shared/memory_leaks_benchmark/RetainReleaseExample.m \ - shared/memory_leaks_benchmark/RetainReleaseExample2.m \ - shared/memory_leaks_benchmark/TollBridgeExample.m \ - shared/npe/npe_malloc.m \ - shared/property/GetterExample.m \ - shared/property/PropertyAttributes.m \ - shared/protocol_procdesc/Bicycle.m \ - shared/protocol_procdesc/main.c \ - strings/global_string_literal.m \ - strings/string_literal.m \ - subclass/MyClass.m \ - subclass/MySubClass.m \ - subclass/main.c \ - types/testloop.m \ - vardecl/aclass.m \ - vardecl/aclass_2.m \ - vardecl/last_af.m \ +.PHONY: clean +clean: arc.clean noarc.clean -SOURCES_ARC = \ - predefined_expr/PredefinedExprExample.m \ - types/attributes.m \ - types/void_call.m \ - vardecl/initlist.m \ - shared/assertions/NSAssert_example.m \ - shared/block/BlockVar.m \ - shared/memory_leaks_benchmark/ArcExample.m \ - shared/memory_leaks_benchmark/arc_methods.m \ - shared/npe/Nonnull_attribute_example.m \ +.PHONY: print +print: arc.print noarc.print -SOURCES = \ - $(SOURCES_NOARC) \ - $(SOURCES_ARC) \ - -include $(TESTS_DIR)/clang-frontend.make - -compile: - clang $(CLANG_OPTIONS) $(SOURCES_NOARC) - clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC) - -capture: - $(call silent_on_success,$(INFER_BIN) -a capture --cxx --frontend-tests --continue --reactive --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES_NOARC)) - $(call silent_on_success,$(INFER_BIN) -a capture --cxx --frontend-tests --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES_ARC)) +.PHONY: test +test: arc.test noarc.test diff --git a/infer/tests/codetoanalyze/objc/frontend/arc/Makefile b/infer/tests/codetoanalyze/objc/frontend/arc/Makefile new file mode 100644 index 000000000..cbc7b46c7 --- /dev/null +++ b/infer/tests/codetoanalyze/objc/frontend/arc/Makefile @@ -0,0 +1,31 @@ +# Copyright (c) 2016 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +TESTS_DIR = ../../../.. + +IPHONESIMULATOR_ISYSROOT_SUFFIX = \ + /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk + +XCODEROOT = $(shell xcode-select -p) + +CLANG_OPTIONS = -x objective-c \ + -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ + -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ + -fbobjc-arc + +SOURCES = \ + ../predefined_expr/PredefinedExprExample.m \ + ../types/attributes.m \ + ../types/void_call.m \ + ../vardecl/initlist.m \ + ../shared/assertions/NSAssert_example.m \ + ../shared/block/BlockVar.m \ + ../shared/memory_leaks_benchmark/ArcExample.m \ + ../shared/memory_leaks_benchmark/arc_methods.m \ + ../shared/npe/Nonnull_attribute_example.m \ + +include $(TESTS_DIR)/clang-frontend.make diff --git a/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile b/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile new file mode 100644 index 000000000..189253c03 --- /dev/null +++ b/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile @@ -0,0 +1,70 @@ +# Copyright (c) 2016 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +TESTS_DIR = ../../../.. + +IPHONESIMULATOR_ISYSROOT_SUFFIX = \ + /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk + +XCODEROOT = $(shell xcode-select -p) + +CLANG_OPTIONS = -x objective-c \ + -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ + -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c + +SOURCES = \ + ../block/retain_cycle.m \ + ../block/static.m \ + ../boxing/Boxing.m \ + ../boxing/array.m \ + ../boxing/array_literal.c \ + ../boxing/dict_literal.c \ + ../boxing/string_literal.c \ + ../conditional_operation/ConditionalOperation.m \ + ../exceptions/ExceptionExample.m \ + ../fast_enumeration/Fast_enumeration.m \ + ../property/PropertyCustomAccessor.m \ + ../property/PropertyImplSetter.m \ + ../property/Property_getter.m \ + ../property/aclass.m \ + ../property/main_car.m \ + ../property_in_protocol/Test.m \ + ../protocol/protocol.m \ + ../returnstmt/void_return.m \ + ../self_static/Self.m \ + ../self_static/static.m \ + ../shared/block/block-it.m \ + ../shared/block/block.m \ + ../shared/block/block_no_args.m \ + ../shared/block/block_release.m \ + ../shared/block/dispatch.m \ + ../shared/block/dispatch_examples.m \ + ../shared/block/dispatch_in_macro.m \ + ../shared/category_procdesc/EOCPerson.m \ + ../shared/category_procdesc/main.c \ + ../shared/field_superclass/SuperExample.m \ + ../shared/memory_leaks_benchmark/AutoreleaseExample.m \ + ../shared/memory_leaks_benchmark/MemoryLeakExample.m \ + ../shared/memory_leaks_benchmark/RetainReleaseExample.m \ + ../shared/memory_leaks_benchmark/RetainReleaseExample2.m \ + ../shared/memory_leaks_benchmark/TollBridgeExample.m \ + ../shared/npe/npe_malloc.m \ + ../shared/property/GetterExample.m \ + ../shared/property/PropertyAttributes.m \ + ../shared/protocol_procdesc/Bicycle.m \ + ../shared/protocol_procdesc/main.c \ + ../strings/global_string_literal.m \ + ../strings/string_literal.m \ + ../subclass/MyClass.m \ + ../subclass/MySubClass.m \ + ../subclass/main.c \ + ../types/testloop.m \ + ../vardecl/aclass.m \ + ../vardecl/aclass_2.m \ + ../vardecl/last_af.m \ + +include $(TESTS_DIR)/clang-frontend.make diff --git a/infer/tests/codetoanalyze/objcpp/frontend/Makefile b/infer/tests/codetoanalyze/objcpp/frontend/Makefile index 935ee86a6..fba92e78d 100644 --- a/infer/tests/codetoanalyze/objcpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/objcpp/frontend/Makefile @@ -19,9 +19,3 @@ SOURCES = \ $(wildcard */*.mm) \ include $(TESTS_DIR)/clang-frontend.make - -compile: - clang $(CLANG_OPTIONS) $(SOURCES) - -capture: - $(call silent_on_success,$(INFER_BIN) -a capture --cxx --frontend-tests --continue --reactive --project-root $(TESTS_DIR) -- clang $(CLANG_OPTIONS) $(SOURCES)) diff --git a/infer/tests/javac.make b/infer/tests/javac.make index 839ba92e1..1fc122a44 100644 --- a/infer/tests/javac.make +++ b/infer/tests/javac.make @@ -20,6 +20,6 @@ include $(TESTS_DIR)/base.make $(OBJECTS): $(SOURCES) javac -cp $(CLASSPATH) $(SOURCES) -infer-out/report.json: $(INFER_BIN) $(SOURCES) +infer-out/report.json: $(JAVA_DEPS) $(SOURCES) $(call silent_on_success,\ $(INFER_BIN) --project-root $(TESTS_DIR) --inferconfig-home . $(INFER_OPTIONS) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(SOURCES))