diff --git a/.buckconfig b/.buckconfig index e2316f9a6..ecce14977 100644 --- a/.buckconfig +++ b/.buckconfig @@ -14,8 +14,5 @@ # TODO: this line exists only to support buck integration in infer/tests/build_systems/build_integration_tests.py infer = //infer/tests/endtoend/java/infer:infer - linters = //infer/tests/endtoend:linters - componentkit = //infer/tests/endtoend:componentkit - [project] ignore = .git, .ml, .mli diff --git a/.inferconfig b/.inferconfig index aa8eb321f..72a3f0d9f 100644 --- a/.inferconfig +++ b/.inferconfig @@ -1,7 +1,4 @@ { - "enable_checks": [ - "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL" - ], "skip_translation": [ { "language": "Java", diff --git a/Makefile b/Makefile index 7ca167588..1944faedf 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ DIRECT_TESTS += java_checkers_test java_eradicate_test java_infer_test java_trac endif ifneq ($(XCODE_SELECT),no) TARGETS_TO_TEST += objc objcpp -DIRECT_TESTS += objc_infer_test +DIRECT_TESTS += objc_infer_test objc_linters objcpp_linters endif TARGETS_TO_TEST := $(shell echo $(TARGETS_TO_TEST)) @@ -136,6 +136,12 @@ java_quandary_test: objc_infer_test: make -C ./infer/tests/codetoanalyze/objc/errors test +objc_linters: + make -C ./infer/tests/codetoanalyze/objc/linters test + +objcpp_linters: + make -C ./infer/tests/codetoanalyze/objcpp/linters test + buck_test: infer make $(DIRECT_TESTS) NO_BUCKD=1 buck clean diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index edd577767..4f771eea2 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -482,16 +482,24 @@ let module IssuesTests = { | Some proc_loc => let line_offset = loc.Location.line - proc_loc.Location.line; (proc_loc.Location.file, line_offset) - | None => (loc.Location.file, 0) + | None => (loc.Location.file, loc.Location.line) }; let should_report = ekind == Exceptions.Kerror || IList.exists (Localise.equal error_name) [ - Localise.return_value_ignored, + Localise.assign_pointer_warning, + Localise.bad_pointer_comparison, + Localise.cxx_reference_captured_in_objc_block, + Localise.direct_atomic_property_access, + Localise.field_not_null_checked, + Localise.global_variable_initialized_with_function_or_method_call, + Localise.mutable_local_variable_in_component_file, Localise.parameter_not_null_checked, - Localise.field_not_null_checked + Localise.registered_observer_being_deallocated, + Localise.return_value_ignored, + Localise.strong_delegate_warning ]; if (in_footprint && should_report && error_filter source_file error_desc error_name) { F.fprintf diff --git a/infer/src/backend/localise.ml b/infer/src/backend/localise.ml index d88397b68..c3fa8c335 100644 --- a/infer/src/backend/localise.ml +++ b/infer/src/backend/localise.ml @@ -32,26 +32,32 @@ let compare (s1: string) (s2: string) = Pervasives.compare s1 s2 let equal s1 s2 = compare s1 s2 = 0 -let context_leak = "CONTEXT_LEAK" let analysis_stops = "ANALYSIS_STOPS" let array_out_of_bounds_l1 = "ARRAY_OUT_OF_BOUNDS_L1" let array_out_of_bounds_l2 = "ARRAY_OUT_OF_BOUNDS_L2" let array_out_of_bounds_l3 = "ARRAY_OUT_OF_BOUNDS_L3" +let assign_pointer_warning = "ASSIGN_POINTER_WARNING" let bad_pointer_comparison = "BAD_POINTER_COMPARISON" let class_cast_exception = "CLASS_CAST_EXCEPTION" let comparing_floats_for_equality = "COMPARING_FLOAT_FOR_EQUALITY" let condition_is_assignment = "CONDITION_IS_ASSIGNMENT" let condition_always_false = "CONDITION_ALWAYS_FALSE" let condition_always_true = "CONDITION_ALWAYS_TRUE" +let context_leak = "CONTEXT_LEAK" +let cxx_reference_captured_in_objc_block = "CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK" let dangling_pointer_dereference = "DANGLING_POINTER_DEREFERENCE" let deallocate_stack_variable = "DEALLOCATE_STACK_VARIABLE" let deallocate_static_memory = "DEALLOCATE_STATIC_MEMORY" let deallocation_mismatch = "DEALLOCATION_MISMATCH" +let direct_atomic_property_access = "DIRECT_ATOMIC_PROPERTY_ACCESS" let divide_by_zero = "DIVIDE_BY_ZERO" let empty_vector_access = "EMPTY_VECTOR_ACCESS" let field_not_null_checked = "IVAR_NOT_NULL_CHECKED" +let global_variable_initialized_with_function_or_method_call = + "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL" let inherently_dangerous_function = "INHERENTLY_DANGEROUS_FUNCTION" let memory_leak = "MEMORY_LEAK" +let mutable_local_variable_in_component_file = "MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE" let null_dereference = "NULL_DEREFERENCE" let parameter_not_null_checked = "PARAMETER_NOT_NULL_CHECKED" let null_test_after_dereference = "NULL_TEST_AFTER_DEREFERENCE" @@ -68,6 +74,7 @@ let return_statement_missing = "RETURN_STATEMENT_MISSING" let skip_function = "SKIP_FUNCTION" let skip_pointer_dereference = "SKIP_POINTER_DEREFERENCE" let stack_variable_address_escape = "STACK_VARIABLE_ADDRESS_ESCAPE" +let strong_delegate_warning = "STRONG_DELEGATE_WARNING" let tainted_value_reaching_sensitive_function = "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION" let unary_minus_applied_to_unsigned_expression = "UNARY_MINUS_APPLIED_TO_UNSIGNED_EXPRESSION" let unsafe_guarded_by_access = "UNSAFE_GUARDED_BY_ACCESS" @@ -789,9 +796,9 @@ let desc_registered_observer_being_deallocated pvar loc = let tags = Tags.create () in let obj_str = Pvar.to_string pvar in { no_desc with descriptions = [ registered_observer_being_deallocated_str obj_str ^ at_line tags loc ^ - ". Being still registered as observer of the notification " ^ - "center, the deallocated object " - ^ obj_str ^ " may be notified in the future." ]; tags = !tags } + ". Being still registered as observer of the notification " ^ + "center, the deallocated object " + ^ obj_str ^ " may be notified in the future." ]; tags = !tags } let desc_return_statement_missing loc = let tags = Tags.create () in diff --git a/infer/src/backend/localise.mli b/infer/src/backend/localise.mli index ffb376d91..f192e3d1e 100644 --- a/infer/src/backend/localise.mli +++ b/infer/src/backend/localise.mli @@ -29,26 +29,31 @@ val compare : t -> t -> int val equal : t -> t -> bool -val context_leak : t val analysis_stops : t val array_out_of_bounds_l1 : t val array_out_of_bounds_l2 : t val array_out_of_bounds_l3 : t +val assign_pointer_warning : t val bad_pointer_comparison : t val class_cast_exception : t +val comparing_floats_for_equality : t val condition_is_assignment : t val condition_always_false : t val condition_always_true : t -val comparing_floats_for_equality : t +val context_leak : t +val cxx_reference_captured_in_objc_block : t val dangling_pointer_dereference : t val deallocate_stack_variable : t val deallocate_static_memory : t val deallocation_mismatch : t +val direct_atomic_property_access : t val divide_by_zero : t val empty_vector_access : t val field_not_null_checked : t +val global_variable_initialized_with_function_or_method_call : t val inherently_dangerous_function : t val memory_leak : t +val mutable_local_variable_in_component_file : t val null_dereference : t val parameter_not_null_checked : t val null_test_after_dereference : t @@ -63,6 +68,7 @@ val return_value_ignored : t val return_expression_required : t val return_statement_missing : t val stack_variable_address_escape : t +val strong_delegate_warning : t val unary_minus_applied_to_unsigned_expression : t val uninitialized_value : t val unsafe_guarded_by_access : t diff --git a/infer/src/clang/cIssue.ml b/infer/src/clang/cIssue.ml index ffff49f73..a01709ddd 100644 --- a/infer/src/clang/cIssue.ml +++ b/infer/src/clang/cIssue.ml @@ -18,18 +18,25 @@ type issue = | Strong_delegate_warning let to_string issue = - match issue with - | Assign_pointer_warning -> "ASSIGN_POINTER_WARNING" - | Bad_pointer_comparison -> "BAD_POINTER_COMPARISON" - | Cxx_reference_captured_in_objc_block -> - "CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK" - | Direct_atomic_property_access -> "DIRECT_ATOMIC_PROPERTY_ACCESS" - | Global_variable_initialized_with_function_or_method_call -> - "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL" - | Mutable_local_variable_in_component_file -> "MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE" - | Registered_observer_being_deallocated -> - Localise.to_string (Localise.registered_observer_being_deallocated) - | Strong_delegate_warning -> "STRONG_DELEGATE_WARNING" + Localise.to_string + (match issue with + | Assign_pointer_warning -> + Localise.assign_pointer_warning + | Bad_pointer_comparison -> + Localise.bad_pointer_comparison + | Cxx_reference_captured_in_objc_block -> + Localise.cxx_reference_captured_in_objc_block + | Direct_atomic_property_access -> + Localise.direct_atomic_property_access + | Global_variable_initialized_with_function_or_method_call -> + Localise.global_variable_initialized_with_function_or_method_call + | Mutable_local_variable_in_component_file -> + Localise.mutable_local_variable_in_component_file + | Registered_observer_being_deallocated -> + Localise.registered_observer_being_deallocated + | Strong_delegate_warning -> + Localise.strong_delegate_warning + ) let severity_of_issue issue = match issue with diff --git a/infer/tests/BUCK b/infer/tests/BUCK index e9e482c06..47e696db7 100644 --- a/infer/tests/BUCK +++ b/infer/tests/BUCK @@ -1,7 +1,6 @@ java_test( name='objc_tests', deps=[ - '//infer/tests/endtoend:objc_endtoend_tests', '//infer/tests/frontend:objc_frontend_tests', ], ) diff --git a/infer/tests/codetoanalyze/objc/linters/Makefile b/infer/tests/codetoanalyze/objc/linters/Makefile new file mode 100644 index 000000000..dd1813d57 --- /dev/null +++ b/infer/tests/codetoanalyze/objc/linters/Makefile @@ -0,0 +1,23 @@ +# 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. + +include ../../Makefile.clang + +OPTIONS = -x objective-c -fobjc-arc -c + +ANALYZER = linters + +FILES = \ + **.m \ + */*.m \ + +compile: + clang $(OPTIONS) $(FILES) + +analyze: + $(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets all --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt + grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 diff --git a/infer/tests/codetoanalyze/objc/linters/issues.exp b/infer/tests/codetoanalyze/objc/linters/issues.exp new file mode 100644 index 000000000..733d9bd0a --- /dev/null +++ b/infer/tests/codetoanalyze/objc/linters/issues.exp @@ -0,0 +1,31 @@ +assign_pointer.m, frontend_checks_006677034375a1c7e7ccfd3694390282, 18, ASSIGN_POINTER_WARNING +assign_pointer.m, frontend_checks_006677034375a1c7e7ccfd3694390282, 20, ASSIGN_POINTER_WARNING +assign_pointer.m, frontend_checks_006677034375a1c7e7ccfd3694390282, 22, ASSIGN_POINTER_WARNING +atomic_prop.m, A_bla, 98, DIRECT_ATOMIC_PROPERTY_ACCESS +atomic_prop.m, A_bla, 99, DIRECT_ATOMIC_PROPERTY_ACCESS +atomic_prop.m, A_readP, 77, DIRECT_ATOMIC_PROPERTY_ACCESS +atomic_prop.m, A_readQ, 86, DIRECT_ATOMIC_PROPERTY_ACCESS +atomic_prop.m, A_writeQ:, 82, DIRECT_ATOMIC_PROPERTY_ACCESS +atomic_prop.m, __objc_anonymous_block_______1, 114, DIRECT_ATOMIC_PROPERTY_ACCESS +badpointer.m, bad1, 17, BAD_POINTER_COMPARISON +badpointer.m, bad10, 139, BAD_POINTER_COMPARISON +badpointer.m, bad2, 26, BAD_POINTER_COMPARISON +badpointer.m, bad3, 33, BAD_POINTER_COMPARISON +badpointer.m, bad4, 85, BAD_POINTER_COMPARISON +badpointer.m, bad5, 99, BAD_POINTER_COMPARISON +badpointer.m, bad6, 106, BAD_POINTER_COMPARISON +badpointer.m, bad7, 121, BAD_POINTER_COMPARISON +badpointer.m, bad8, 128, BAD_POINTER_COMPARISON +badpointer.m, bad9, 135, BAD_POINTER_COMPARISON +nsnumber.m, bad1, 13, BAD_POINTER_COMPARISON +nsnumber.m, bad2, 18, BAD_POINTER_COMPARISON +nsnumber.m, bad3, 23, BAD_POINTER_COMPARISON +nsnumber.m, bad4, 43, BAD_POINTER_COMPARISON +registered_observer/Person.m, frontend_checks_e09ed2cbfd6c3584b50a5fd5783367c9, 80, REGISTERED_OBSERVER_BEING_DEALLOCATED +registered_observer/Person.m, frontend_checks_e09ed2cbfd6c3584b50a5fd5783367c9, 97, REGISTERED_OBSERVER_BEING_DEALLOCATED +registered_observer/ViewController3.m, frontend_checks_6eb87af45b67f4c5dda049872d80dc43, 14, REGISTERED_OBSERVER_BEING_DEALLOCATED +strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 15, STRONG_DELEGATE_WARNING +strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 19, STRONG_DELEGATE_WARNING +strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 21, STRONG_DELEGATE_WARNING +strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 23, STRONG_DELEGATE_WARNING +strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 25, STRONG_DELEGATE_WARNING diff --git a/infer/tests/codetoanalyze/objcpp/linters/.inferconfig b/infer/tests/codetoanalyze/objcpp/linters/.inferconfig new file mode 100644 index 000000000..93f5f13b4 --- /dev/null +++ b/infer/tests/codetoanalyze/objcpp/linters/.inferconfig @@ -0,0 +1,11 @@ +{ + "enable_checks": [ + "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL" + ], + "skip_translation": [ + { + "language": "Java", + "source_contains": "_SHOULD_BE_SKIPPED_" + } + ] +} diff --git a/infer/tests/codetoanalyze/objcpp/linters/Makefile b/infer/tests/codetoanalyze/objcpp/linters/Makefile new file mode 100644 index 000000000..f7dbe3a8e --- /dev/null +++ b/infer/tests/codetoanalyze/objcpp/linters/Makefile @@ -0,0 +1,22 @@ +# 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. + +include ../../Makefile.clang + +OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c + +ANALYZER = linters + +FILES = \ + */*.mm \ + +compile: + clang $(OPTIONS) $(FILES) + +analyze: + $(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets all --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt + grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 diff --git a/infer/tests/codetoanalyze/objcpp/componentkit/Test.mm b/infer/tests/codetoanalyze/objcpp/linters/componentkit/Test.mm similarity index 100% rename from infer/tests/codetoanalyze/objcpp/componentkit/Test.mm rename to infer/tests/codetoanalyze/objcpp/linters/componentkit/Test.mm diff --git a/infer/tests/codetoanalyze/objcpp/componentkit/Test2.mm b/infer/tests/codetoanalyze/objcpp/linters/componentkit/Test2.mm similarity index 100% rename from infer/tests/codetoanalyze/objcpp/componentkit/Test2.mm rename to infer/tests/codetoanalyze/objcpp/linters/componentkit/Test2.mm diff --git a/infer/tests/codetoanalyze/objcpp/linters/issues.exp b/infer/tests/codetoanalyze/objcpp/linters/issues.exp new file mode 100644 index 000000000..ec24dc3ef --- /dev/null +++ b/infer/tests/codetoanalyze/objcpp/linters/issues.exp @@ -0,0 +1,13 @@ +componentkit/Test.mm, BarComponent_new, 103, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, BarComponent_new, 105, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 69, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 74, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 76, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 80, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 85, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, SomeClass_init, 58, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +cxx_reference_in_block/block.mm, A_foo3:param2:, 37, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK +cxx_reference_in_block/block.mm, A_foo:, 20, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK +global-var/B.mm, frontend_checks_a1a4821f6afe8cbd5bde0f8905d6f284, 30, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL +global-var/B.mm, frontend_checks_a1a4821f6afe8cbd5bde0f8905d6f284, 32, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL +global-var/B.mm, frontend_checks_a1a4821f6afe8cbd5bde0f8905d6f284, 34, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL diff --git a/infer/tests/endtoend/BUCK b/infer/tests/endtoend/BUCK index 319e40d6a..18193d9e3 100644 --- a/infer/tests/endtoend/BUCK +++ b/infer/tests/endtoend/BUCK @@ -11,24 +11,11 @@ tests_dependencies = [ '//infer/tests/codetoanalyze/java/infer:infer', ] -# ############### ObjC endtoend tests ######################## -java_test( - name='objc_endtoend_tests', - deps=[ - '//infer/tests/endtoend/objc/linters:linters', - ], - visibility=[ - 'PUBLIC', - ], -) - # ############### ObjCpp endtoend tests ######################## java_test( name='objcpp_endtoend_tests', deps=[ '//infer/tests/endtoend/objcpp/infer:infer', - '//infer/tests/endtoend/objcpp/linters:linters', - '//infer/tests/endtoend/objcpp/componentkit:componentkit', ], visibility=[ 'PUBLIC', @@ -47,22 +34,3 @@ java_test( 'PUBLIC', ], ) - -# ############### Linters tests ######################## - -java_test( - name='linters', - deps=[ - '//infer/tests/endtoend/objc/linters:linters', - '//infer/tests/endtoend/objcpp/linters:linters', - ], -) - -# ############### ComponentKit tests ######################## - -java_test( - name='componentkit', - deps=[ - '//infer/tests/endtoend/objcpp/componentkit:componentkit', - ], -) diff --git a/infer/tests/endtoend/objc/linters/AssignPointerTest.java b/infer/tests/endtoend/objc/linters/AssignPointerTest.java deleted file mode 100644 index b6c47927f..000000000 --- a/infer/tests/endtoend/objc/linters/AssignPointerTest.java +++ /dev/null @@ -1,63 +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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class AssignPointerTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/linters/assign_pointer.m"; - - private static ImmutableList inferCmd; - - public static final String ASSIGN_POINTER_WARNING = "ASSIGN_POINTER_WARNING"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommand( - folder, - FILE); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain the correct " + ASSIGN_POINTER_WARNING, - inferResults, - containsOnlyLines( - new int[]{ - 18, - 20, - 22 - })); - } - -} diff --git a/infer/tests/endtoend/objc/linters/AtomicPropertyTest.java b/infer/tests/endtoend/objc/linters/AtomicPropertyTest.java deleted file mode 100644 index 0641a1b01..000000000 --- a/infer/tests/endtoend/objc/linters/AtomicPropertyTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class AtomicPropertyTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/linters/atomic_prop.m"; - - private static ImmutableList inferCmd; - - public static final String DIRECT_ATOMIC_PROPERTY_ACCESS = "DIRECT_ATOMIC_PROPERTY_ACCESS"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommand( - folder, - FILE); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain the correct " + DIRECT_ATOMIC_PROPERTY_ACCESS, - inferResults, - containsOnlyLines( - new int[]{ - 77, - 82, - 86, - 98, - 99, - 114 - })); - } - -} diff --git a/infer/tests/endtoend/objc/linters/BUCK b/infer/tests/endtoend/objc/linters/BUCK deleted file mode 100644 index cc5ba4fc0..000000000 --- a/infer/tests/endtoend/objc/linters/BUCK +++ /dev/null @@ -1,35 +0,0 @@ -tests_dependencies = [ - '//infer/lib/java/android:android', - '//dependencies/java/guava:guava', - '//dependencies/java/junit:hamcrest', - '//dependencies/java/jackson:jackson', - '//dependencies/java/jsr-305:jsr-305', - '//dependencies/java/junit:junit', - '//dependencies/java/opencsv:opencsv', - '//infer/tests/utils:utils', -] - -objc_linters_test_sources = glob(['*.java']) -objc_linters_test_deps = [] -for test_source in objc_linters_test_sources: - target_name = test_source.replace("/", "_")[:-len(".java")] - objc_linters_test_deps.append(target_name) - - java_test( - name=target_name, - srcs=[test_source], - deps=tests_dependencies, - visibility=[ - 'PUBLIC', - ], - source='7', - target='7', - ) - -java_test( - name='linters', - deps=[':' + x for x in objc_linters_test_deps], - visibility=[ - 'PUBLIC', - ], -) diff --git a/infer/tests/endtoend/objc/linters/NSNumber2Test.java b/infer/tests/endtoend/objc/linters/NSNumber2Test.java deleted file mode 100644 index 3abafd8e2..000000000 --- a/infer/tests/endtoend/objc/linters/NSNumber2Test.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NSNumber2Test { - - public static final String NSNUMBER_FILE = - "infer/tests/codetoanalyze/objc/linters/badpointer.m"; - - private static ImmutableList inferCmd; - - public static final String BAD_POINTER_COMPARISON = "BAD_POINTER_COMPARISON"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommand( - folder, - NSNUMBER_FILE); - } - - @Test - public void badNSNumberPointerComparisonShouldBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain " + BAD_POINTER_COMPARISON, - inferResults, - containsOnlyLines(new int[]{17, 26, 33, 85, 99, 106, 121, 128, 135, 139})); - } - -} diff --git a/infer/tests/endtoend/objc/linters/NSNumberTest.java b/infer/tests/endtoend/objc/linters/NSNumberTest.java deleted file mode 100644 index cd23dca47..000000000 --- a/infer/tests/endtoend/objc/linters/NSNumberTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class NSNumberTest { - - public static final String NSNUMBER_FILE = - "infer/tests/codetoanalyze/objc/linters/nsnumber.m"; - - private static ImmutableList inferCmd; - - public static final String BAD_POINTER_COMPARISON = "BAD_POINTER_COMPARISON"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommand( - folder, - NSNUMBER_FILE); - } - - @Test - public void badNSNumberPointerComparisonShouldBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain " + BAD_POINTER_COMPARISON, - inferResults, - containsOnlyLines(new int[]{13, 18, 23, 43}) - ); - } - -} diff --git a/infer/tests/endtoend/objc/linters/RegisteredObserver.java b/infer/tests/endtoend/objc/linters/RegisteredObserver.java deleted file mode 100644 index 1490fb8ec..000000000 --- a/infer/tests/endtoend/objc/linters/RegisteredObserver.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RegisteredObserver { - - public static final String VCFile = - "infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController.m"; - - private static ImmutableList inferCmd; - - public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommandSimple( - folder, - VCFile); - } - - @Test - public void RegisteredObserverShouldBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] methods = { - //"fooError", "barError" - }; - assertThat( - "Results should contain " + REGISTERED_OBSERVER, - inferResults, - containsExactly( - REGISTERED_OBSERVER, - VCFile, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/linters/RegisteredObserver2.java b/infer/tests/endtoend/objc/linters/RegisteredObserver2.java deleted file mode 100644 index 30de415b0..000000000 --- a/infer/tests/endtoend/objc/linters/RegisteredObserver2.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RegisteredObserver2 { - - public static final String VCFile2 = - "infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController2.m"; - - private static ImmutableList inferCmd; - - public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommandSimple( - folder, - VCFile2); - } - - @Test - public void RegisteredObserverShouldNotBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] methods = {}; - assertThat( - "Results should contain " + REGISTERED_OBSERVER, - inferResults, - containsExactly( - REGISTERED_OBSERVER, - VCFile2, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/objc/linters/RegisteredObserver3.java b/infer/tests/endtoend/objc/linters/RegisteredObserver3.java deleted file mode 100644 index 2b63ff2ba..000000000 --- a/infer/tests/endtoend/objc/linters/RegisteredObserver3.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RegisteredObserver3 { - - public static final String VCFile3 = - "infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController3.m"; - - private static ImmutableList inferCmd; - - public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - - inferCmd = InferRunner.createObjCLintersCommandSimple( - folder, - VCFile3); - } - - @Test - public void RegisteredObserverShouldBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - String[] methods = { - "frontendChecks" - }; - assertThat( - "Results should contain " + REGISTERED_OBSERVER, - inferResults, - containsOnlyLines(new int[]{14})); - } -} diff --git a/infer/tests/endtoend/objc/linters/RegisteredObserver4.java b/infer/tests/endtoend/objc/linters/RegisteredObserver4.java deleted file mode 100644 index 7da454e55..000000000 --- a/infer/tests/endtoend/objc/linters/RegisteredObserver4.java +++ /dev/null @@ -1,58 +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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class RegisteredObserver4 { - - public static final String VCFile = - "infer/tests/codetoanalyze/objc/linters/registered_observer/Person.m"; - - private static ImmutableList inferCmd; - - public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCLintersCommandSimple( - folder, - VCFile); - } - - @Test - public void RegisteredObserverShouldBeFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain " + REGISTERED_OBSERVER, - inferResults, - containsOnlyLines(new int[] {80, 97}) - ); - } - -} diff --git a/infer/tests/endtoend/objc/linters/StrongDelegateTest.java b/infer/tests/endtoend/objc/linters/StrongDelegateTest.java deleted file mode 100644 index b919db1e5..000000000 --- a/infer/tests/endtoend/objc/linters/StrongDelegateTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objc.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class StrongDelegateTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objc/linters/strong_delegate.m"; - - private static ImmutableList inferCmdFraction; - - public static final String STRONG_DELEGATE_WARNING = "STRONG_DELEGATE_WARNING"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdFraction = InferRunner.createObjCLintersCommand( - folder, - FILE); - } - - @Test - public void whenInferRunsOnStrongDelegate() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain " + STRONG_DELEGATE_WARNING, - inferResults, - containsOnlyLines(new int[]{15, 19, 21, 23, 25})); - } - -} diff --git a/infer/tests/endtoend/objcpp/componentkit/BUCK b/infer/tests/endtoend/objcpp/componentkit/BUCK deleted file mode 100644 index 460a77bbd..000000000 --- a/infer/tests/endtoend/objcpp/componentkit/BUCK +++ /dev/null @@ -1,35 +0,0 @@ -tests_dependencies = [ - '//infer/lib/java/android:android', - '//dependencies/java/guava:guava', - '//dependencies/java/junit:hamcrest', - '//dependencies/java/jackson:jackson', - '//dependencies/java/jsr-305:jsr-305', - '//dependencies/java/junit:junit', - '//dependencies/java/opencsv:opencsv', - '//infer/tests/utils:utils', -] - -objcpp_linters_test_sources = glob(['*.java']) -objcpp_linters_test_deps = [] -for test_source in objcpp_linters_test_sources: - target_name = test_source.replace("/", "_")[:-len(".java")] - objcpp_linters_test_deps.append(target_name) - - java_test( - name=target_name, - srcs=[test_source], - deps=tests_dependencies, - visibility=[ - 'PUBLIC', - ], - source='7', - target='7', - ) - -java_test( - name='componentkit', - deps=[':' + x for x in objcpp_linters_test_deps], - visibility=[ - 'PUBLIC', - ], -) diff --git a/infer/tests/endtoend/objcpp/componentkit/MutableLocalVariableInNonComponentTest.java b/infer/tests/endtoend/objcpp/componentkit/MutableLocalVariableInNonComponentTest.java deleted file mode 100644 index 52d831344..000000000 --- a/infer/tests/endtoend/objcpp/componentkit/MutableLocalVariableInNonComponentTest.java +++ /dev/null @@ -1,51 +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. - */ - -package endtoend.objcpp.componentkit; - - import static org.hamcrest.MatcherAssert.assertThat; - import static utils.matchers.ResultContainsLineNumbers.containsLinesOfError; - import static org.hamcrest.core.IsNot.not; - import com.google.common.collect.ImmutableList; - import org.junit.BeforeClass; - import org.junit.ClassRule; - import org.junit.Test; - import java.io.IOException; - import utils.DebuggableTemporaryFolder; - import utils.InferException; - import utils.InferResults; - import utils.InferRunner; - - public class MutableLocalVariableInNonComponentTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objcpp/componentkit/Test2.mm"; - private static ImmutableList inferCmd; - public static final String MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE = - "MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCPPLintersCommand( - folder, - FILE); - } - @Test - public void MLVsInComponentFile() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should not contain " + MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, - inferResults, - not(containsLinesOfError(new int[]{38}, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE))); - } -} diff --git a/infer/tests/endtoend/objcpp/componentkit/MutableLocalVariableTest.java b/infer/tests/endtoend/objcpp/componentkit/MutableLocalVariableTest.java deleted file mode 100644 index e76a75206..000000000 --- a/infer/tests/endtoend/objcpp/componentkit/MutableLocalVariableTest.java +++ /dev/null @@ -1,66 +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. - */ - -package endtoend.objcpp.componentkit; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; -import static utils.matchers.ResultContainsErrorInMethod.contains; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class MutableLocalVariableTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objcpp/componentkit/Test.mm"; - private static ImmutableList inferCmd; - public static final String MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE = - "MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE"; - - @ClassRule - public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCPPLintersCommand( - folder, - FILE); - } - - @Test - public void MLVsInComponentFile() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain " + MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, - inferResults, - containsOnlyLines(new int[]{58, 69, 74, 76, 80, 85, 103, 105})); - } - - @Test - public void MLVsInNewWithString() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain " + MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, - inferResults, - contains(MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, FILE, "newWithString:")); - } -} diff --git a/infer/tests/endtoend/objcpp/linters/BUCK b/infer/tests/endtoend/objcpp/linters/BUCK deleted file mode 100644 index 390f608f0..000000000 --- a/infer/tests/endtoend/objcpp/linters/BUCK +++ /dev/null @@ -1,35 +0,0 @@ -tests_dependencies = [ - '//infer/lib/java/android:android', - '//dependencies/java/guava:guava', - '//dependencies/java/junit:hamcrest', - '//dependencies/java/jackson:jackson', - '//dependencies/java/jsr-305:jsr-305', - '//dependencies/java/junit:junit', - '//dependencies/java/opencsv:opencsv', - '//infer/tests/utils:utils', -] - -objcpp_linters_test_sources = glob(['*.java']) -objcpp_linters_test_deps = [] -for test_source in objcpp_linters_test_sources: - target_name = test_source.replace("/", "_")[:-len(".java")] - objcpp_linters_test_deps.append(target_name) - - java_test( - name=target_name, - srcs=[test_source], - deps=tests_dependencies, - visibility=[ - 'PUBLIC', - ], - source='7', - target='7', - ) - -java_test( - name='linters', - deps=[':' + x for x in objcpp_linters_test_deps], - visibility=[ - 'PUBLIC', - ], -) diff --git a/infer/tests/endtoend/objcpp/linters/BlockCaptureCXXRefTest.java b/infer/tests/endtoend/objcpp/linters/BlockCaptureCXXRefTest.java deleted file mode 100644 index d2bf9490b..000000000 --- a/infer/tests/endtoend/objcpp/linters/BlockCaptureCXXRefTest.java +++ /dev/null @@ -1,59 +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. - */ - -package endtoend.objcpp.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class BlockCaptureCXXRefTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm"; - - private static ImmutableList inferCmd; - - public static final String REFERENCE_CAPTURED = "CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createObjCPPLintersCommand(folder, FILE); - } - - @Test - public void matchErrors() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmd); - assertThat( - "Results should contain the correct " + REFERENCE_CAPTURED, - inferResults, - containsOnlyLines( - new int[]{ - 20, - 37 - })); - } -} diff --git a/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java b/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java deleted file mode 100644 index 063c19821..000000000 --- a/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.objcpp.linters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines; - -import com.google.common.collect.ImmutableList; - -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.IOException; - -import utils.DebuggableTemporaryFolder; -import utils.InferException; -import utils.InferResults; -import utils.InferRunner; - -public class GlobalVarTest { - - public static final String FILE = - "infer/tests/codetoanalyze/objcpp/linters/global-var/B.mm"; - - private static ImmutableList inferCmdFraction; - - public static final String GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL = - "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmdFraction = InferRunner.createObjCPPLintersCommand( - folder, - FILE); - } - - @Test - public void whenInferRunsGlobalVar() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction); - assertThat( - "Results should contain " + GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL, - inferResults, - containsOnlyLines(new int[]{30, 32, 34})); - } - -} diff --git a/infer/tests/utils/InferRunner.java b/infer/tests/utils/InferRunner.java index 681de87c4..5f83aa851 100644 --- a/infer/tests/utils/InferRunner.java +++ b/infer/tests/utils/InferRunner.java @@ -563,48 +563,6 @@ public class InferRunner { ImmutableList.of()); } - public static ImmutableList createLintersCommand( - TemporaryFolder folder, - String sourceFile, - Language lang) throws IOException, InterruptedException { - return createClangInferCommand( - folder, - sourceFile, - lang, - "linters", - getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, - null, - true, - ImmutableList.of()); - } - - public static ImmutableList createObjCLintersCommand( - TemporaryFolder folder, - String sourceFile) throws IOException, InterruptedException { - return createLintersCommand(folder, sourceFile, Language.ObjC); - } - - public static ImmutableList createObjCLintersCommandSimple( - TemporaryFolder folder, - String sourceFile) throws IOException, InterruptedException { - return createClangInferCommand( - folder, - sourceFile, - Language.ObjC, - "linters", - null, - null, - true, - ImmutableList.of()); - } - - public static ImmutableList createObjCPPLintersCommand( - TemporaryFolder folder, - String sourceFile) throws IOException, InterruptedException { - return createLintersCommand(folder, sourceFile, Language.ObjCPP); - } - - @Nullable public static File runInferFrontend(ImmutableList inferCmd) throws IOException, InterruptedException, InferException {