[tests] make clang tests Makefile more functional

Summary:
This makes the tests depend on much fewer phony targets, thus reducing the need
to rerun the tests when nothing has changed.

Reviewed By: jberdine

Differential Revision: D4118457

fbshipit-source-id: 664b6e3
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 0b9727214d
commit c9bac51b81

1
.gitignore vendored

@ -13,6 +13,7 @@
*.rej
*.start
*.exp.test
duplicates.txt
infer/tests/codetoanalyze/java/*/codetoanalyze
# Directories generated by Ocamlbuild

@ -0,0 +1,46 @@
# 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.
ROOT_DIR = $(TESTS_DIR)/../..
include $(ROOT_DIR)/Makefile.config
INFERPRINT_OPTIONS = --issues-tests
OBJECTS = $(foreach source,$(SOURCES),$(basename $(source)).o)
CLEAN_EXTRA =
default: compile
infer-out/report.json: $(CLANG_DEPS) $(SOURCES)
$(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
issues.exp.test: $(INFERPRINT_BIN) infer-out/report.json
$(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) issues.exp.test
LC_ALL=C sort -t, -k1,1 -k2,2 -k3n,3 -o issues.exp.test issues.exp.test
$(OBJECTS): $(SOURCES)
clang $(CLANG_OPTIONS) $(SOURCES)
.PHONY: compile
compile: $(OBJECTS)
.PHONY: analyze
analyze: infer-out/report.json
.PHONY: print
print: issues.exp.test
.PHONY: test
test: issues.exp.test
diff -u issues.exp issues.exp.test
.PHONY: clean
clean:
$(REMOVE_DIR) duplicates.txt issues.exp.test infer-out $(OBJECTS) $(CLEAN_EXTRA)

@ -1,28 +0,0 @@
# 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.
ROOT_DIR = ../../../../..
include $(ROOT_DIR)/Makefile.config
ANALYZER = infer
INFERPRINT_OPTIONS = --issues-tests
CLEAN_EXTRA =
default: compile
print: analyze
$(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) issues.exp.test
LC_ALL=C sort -t, -k1,1 -k2,2 -k3n,3 -o issues.exp.test issues.exp.test
test: analyze print
$(MAKE) clean
diff -u issues.exp issues.exp.test
rm issues.exp.test
clean:
rm -rf *.o infer-out $(CLEAN_EXTRA) duplicates.txt

@ -5,16 +5,12 @@
# 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.
include ../../Makefile.clang
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
OPTIONS = -c
ANALYZER = infer
CLANG_OPTIONS = -c
INFER_OPTIONS = --report-custom-error --developer-mode
FILES = \
*/*.c \
compile:
clang $(OPTIONS) $(FILES)
analyze:
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --report-custom-error --check-duplicate-symbols --developer-mode -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
SOURCES = \
$(wildcard */*.c) \

@ -5,14 +5,15 @@
# 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.
include ../../Makefile.clang
OPTIONS = -x c++ -std=c++11 -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
ANALYZER = checkers
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c
INFER_OPTIONS = --cxx --ml-buckets cpp
INFERPRINT_OPTIONS = --issues-txt
FILES = \
SOURCES = \
siof/const.cpp \
siof/const_use.cpp \
siof/pod_across_translation_units-1.cpp \
@ -20,10 +21,3 @@ FILES = \
siof/pod_same_translation_unit.cpp \
siof/siof_across_translation_units-1.cpp \
siof/siof_across_translation_units-2.cpp \
compile:
clang $(OPTIONS) $(FILES)
analyze:
$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0

@ -5,36 +5,41 @@
# 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.
include ../../Makefile.clang
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
ANALYZER = infer
FILES = \
c_tests/*.cpp \
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
INFER_OPTIONS = --cxx --ml-buckets cpp
SOURCES = \
$(wildcard c_tests/*.cpp) \
include_header/header.h \
include_header/include_templ.cpp \
memory_leaks/*.cpp \
models/*.cpp \
npe/*.cpp \
numeric/*.cpp \
overwrite_attribute/*.cpp \
resource_leaks/*.cpp \
shared/attributes/*.cpp \
shared/conditional/*.cpp \
$(wildcard memory_leaks/*.cpp) \
$(wildcard models/*.cpp) \
$(wildcard npe/*.cpp) \
$(wildcard numeric/*.cpp) \
$(wildcard overwrite_attribute/*.cpp) \
$(wildcard resource_leaks/*.cpp) \
$(wildcard shared/attributes/*.cpp) \
$(wildcard shared/conditional/*.cpp) \
shared/constructors/constructor_init.cpp \
shared/constructors/constructor_new.cpp \
shared/constructors/constructor_with_body.cpp \
shared/constructors/copy_move_constructor.cpp \
shared/constructors/temp_object.cpp \
shared/exceptions/Exceptions.cpp \
shared/lambda/*.cpp \
$(wildcard shared/lambda/*.cpp) \
shared/methods/conversion_operator.cpp \
shared/methods/static.cpp \
shared/namespace/function.cpp \
shared/namespace/global_variable.cpp \
shared/methods/virtual_methods.cpp \
shared/nestedoperators/var_decl_inside_if.cpp \
shared/npe/*.cpp \
$(wildcard shared/npe/*.cpp) \
shared/reference/reference_field.cpp \
shared/reference/reference_struct_e2e.cpp \
shared/reference/reference_type_e2e.cpp \
@ -49,13 +54,6 @@ FILES = \
shared/types/struct_forward_declare.cpp \
shared/types/struct_pass_by_value.cpp \
shared/types/typeid_expr.cpp \
smart_ptr/*.cpp \
subtyping/*.cpp \
vector/*.cpp \
compile:
clang $(OPTIONS) $(FILES)
analyze:
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
$(wildcard smart_ptr/*.cpp) \
$(wildcard subtyping/*.cpp) \
$(wildcard vector/*.cpp) \

@ -5,20 +5,14 @@
# 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.
include ../../Makefile.clang
OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
ANALYZER = quandary
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
INFER_OPTIONS = --cxx --ml-buckets cpp
INFERPRINT_OPTIONS = --issues-txt
FILES = \
SOURCES = \
basics.cpp \
execs.cpp \
compile:
clang $(OPTIONS) $(FILES)
analyze:
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0

@ -5,18 +5,22 @@
# 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.
include ../../Makefile.clang
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
IPHONESIMULATOR_ISYSROOT_SUFFIX = /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
XCODEROOT = $(shell xcode-select -p)
OPTIONS = -x objective-c \
ANALYZER = infer
CLANG_OPTIONS = -x objective-c \
-isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \
-mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \
CLEAN_EXTRA = infer-out-arc infer-out-all
INFER_OPTIONS = --cxx --check-duplicate-symbols
FILES = \
SOURCES_DEFAULT = \
field_superclass/B.m \
memory_leaks_benchmark/FBViewExample.m \
memory_leaks_benchmark/MemoryLeakRaii.m \
@ -47,7 +51,7 @@ FILES = \
taint/sources.m \
taint/viewController.m \
FILES_BUCKET_ALL = \
SOURCES_BUCKET_ALL = \
field_superclass/field.c \
global_const/global_const.m \
initialization/compound_literal.c \
@ -71,7 +75,7 @@ FILES_BUCKET_ALL = \
shared/npe/npe_malloc.m \
warnings/ParameterNotNullableExample.m \
FILES_ARC = \
SOURCES_ARC = \
field_superclass/SubtypingExample.m \
initialization/struct_initlistexpr.c \
memory_leaks_benchmark/RetainReleaseExampleBucketingArc.m \
@ -92,18 +96,36 @@ FILES_ARC = \
subtyping/KindOfClassExample.m \
variadic_methods/premature_nil_termination.m \
compile:
clang $(OPTIONS) $(FILES) $(FILES_BUCKET_ALL)
clang $(OPTIONS) -fobjc-arc $(FILES_ARC)
SOURCES = $(SOURCES_DEFAULT) $(SOURCES_BUCKET_ALL) $(SOURCES_ARC)
CLEAN_EXTRA = infer-out-arc infer-out-all
OBJECTS_ARC = $(foreach source,$(SOURCES_ARC),$(basename $(source)).o)
OBJECTS_BUCKET_ALL = $(foreach source,$(SOURCES_BUCKET_ALL),$(basename $(source)).o)
OBJECTS_DEFAULT = $(foreach source,$(SOURCES_DEFAULT),$(basename $(source)).o)
$(OBJECTS_ARC): $(SOURCES_ARC)
clang $(CLANG_OPTIONS) -fobjc-arc $< -o $@
$(OBJECTS_BASE) $(OBJECTS_BUCKETS_ALL): $(SOURCES_BASE) $(SOURCES_BUCKET_ALL)
clang $(CLANG_OPTIONS) $< -o $@
analyze:
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets all --check-duplicate-symbols -o infer-out-all -- clang $(OPTIONS) $(FILES_BUCKET_ALL) 2>duplicates.txt)
infer-out-all/report.json: $(INFER_BIN) $(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
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cf --check-duplicate-symbols -o infer-out -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
infer-out-arc/report.json: $(INFER_BIN) $(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
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cf --check-duplicate-symbols -o infer-out-arc -- clang $(OPTIONS) -fobjc-arc $(FILES_ARC) 2>duplicates.txt)
infer-out-default/report.json: $(INFER_BIN) $(SOURCES_DEFAULT)
$(call silent_on_success,\
$(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) --ml-buckets cf -o infer-out-default -- \
clang $(CLANG_OPTIONS) $(SOURCES_DEFAULT) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
cp infer-out-all/specs/* infer-out/specs
cp infer-out-arc/specs/* infer-out/specs
infer-out/report.json: infer-out-all/report.json infer-out-arc/report.json infer-out-default/report.json
$(MKDIR_P) infer-out/specs
cp infer-out-{all,arc,default}/specs/* infer-out/specs

@ -59,7 +59,6 @@ procdescs/main.c, call_nslog, 2, MEMORY_LEAK
procdescs/main.c, call_nslog, 3, MEMORY_LEAK
property/ExplicitIvarName.m, ExplicitIvarNameA_testDefaultName, 7, NULL_DEREFERENCE
property/ExplicitIvarName.m, ExplicitIvarNameA_testExplicit, 6, NULL_DEREFERENCE
property/main.c, property_main, 2, MEMORY_LEAK
property/main.c, property_main, 3, MEMORY_LEAK
shared/assertions/NSAssert_example.m, NSAssert_addTarget:, 1, MEMORY_LEAK
shared/assertions/NSAssert_example.m, NSAssert_initWithRequest:, 1, MEMORY_LEAK

@ -5,19 +5,12 @@
# 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.
include ../../Makefile.clang
OPTIONS = -x objective-c -fobjc-arc -c
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
ANALYZER = linters
CLANG_OPTIONS = -x objective-c -fobjc-arc -c
FILES = \
*.m \
*/*.m \
compile:
clang $(OPTIONS) $(FILES)
analyze:
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
SOURCES = \
$(wildcard *.m) \
$(wildcard */*.m) \

@ -5,18 +5,11 @@
# 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.
include ../../Makefile.clang
OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c
TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make
ANALYZER = linters
CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c
FILES = \
*/*.mm \
compile:
clang $(OPTIONS) $(FILES)
analyze:
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
SOURCES = \
$(wildcard */*.mm) \

Loading…
Cancel
Save