[cost] Report with relative paths on xcode_isysroot in tests

Summary:
This diff reports paths under the xcode isysroot as relative in tests.
This was a problem when another machine that has a different isysroot
directory is running the test.

Reviewed By: ezgicicek

Differential Revision: D23729222

fbshipit-source-id: 4e9681f65
master
Sungkeun Cho 5 years ago committed by Facebook GitHub Bot
parent 3f737cbd49
commit a40ad1c733

@ -109,8 +109,10 @@ CLANG_DEPS_NO_MODELS = $(INFER_BIN)
CLANG_DEPS = $(CLANG_DEPS_NO_MODELS) $(MODELS_RESULTS_FILE) CLANG_DEPS = $(CLANG_DEPS_NO_MODELS) $(MODELS_RESULTS_FILE)
XCODE_ISYSROOT_SUFFIX = Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
ifeq ($(HAS_OBJC),yes) ifeq ($(HAS_OBJC),yes)
XCODE_ISYSROOT = $(XCODE_BASE)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk XCODE_ISYSROOT = $(XCODE_BASE)/$(XCODE_ISYSROOT_SUFFIX)
endif endif
define copy_or_same_file define copy_or_same_file

@ -380,6 +380,10 @@ OPTIONS
--uninit-only --uninit-only
Activates: Enable uninit and disable all other checkers Activates: Enable uninit and disable all other checkers
(Conversely: --no-uninit-only) (Conversely: --no-uninit-only)
--xcode-isysroot-suffix string
Specify the suffix of Xcode isysroot directory, to avoid absolute
paths in tests
BUCK OPTIONS BUCK OPTIONS
--merge --merge
Activates: Merge the captured results directories specified in the Activates: Merge the captured results directories specified in the

@ -1199,6 +1199,10 @@ OPTIONS
Specify the path to Xcode developer directory, to use for Buck Specify the path to Xcode developer directory, to use for Buck
clang targets See also infer-capture(1). clang targets See also infer-capture(1).
--xcode-isysroot-suffix string
Specify the suffix of Xcode isysroot directory, to avoid absolute
paths in tests See also infer-analyze(1).
--xcpretty --xcpretty
Activates: Infer will use xcpretty together with xcodebuild to Activates: Infer will use xcpretty together with xcodebuild to
analyze an iOS app. xcpretty just needs to be in the path, infer analyze an iOS app. xcpretty just needs to be in the path, infer
@ -1962,6 +1966,9 @@ INTERNAL OPTIONS
--xcode-developer-dir-reset --xcode-developer-dir-reset
Cancel the effect of --xcode-developer-dir. Cancel the effect of --xcode-developer-dir.
--xcode-isysroot-suffix-reset
Cancel the effect of --xcode-isysroot-suffix.
ENVIRONMENT ENVIRONMENT
Extra arguments may be passed to all infer commands using the Extra arguments may be passed to all infer commands using the

@ -1199,6 +1199,10 @@ OPTIONS
Specify the path to Xcode developer directory, to use for Buck Specify the path to Xcode developer directory, to use for Buck
clang targets See also infer-capture(1). clang targets See also infer-capture(1).
--xcode-isysroot-suffix string
Specify the suffix of Xcode isysroot directory, to avoid absolute
paths in tests See also infer-analyze(1).
--xcpretty --xcpretty
Activates: Infer will use xcpretty together with xcodebuild to Activates: Infer will use xcpretty together with xcodebuild to
analyze an iOS app. xcpretty just needs to be in the path, infer analyze an iOS app. xcpretty just needs to be in the path, infer

@ -2388,6 +2388,12 @@ and xcode_developer_dir =
"Specify the path to Xcode developer directory, to use for Buck clang targets" "Specify the path to Xcode developer directory, to use for Buck clang targets"
and xcode_isysroot_suffix =
CLOpt.mk_string_opt ~long:"xcode-isysroot-suffix"
~in_help:InferCommand.[(Analyze, manual_generic)]
"Specify the suffix of Xcode isysroot directory, to avoid absolute paths in tests"
and xcpretty = and xcpretty =
CLOpt.mk_bool ~long:"xcpretty" ~default:false CLOpt.mk_bool ~long:"xcpretty" ~default:false
~in_help:InferCommand.[(Capture, manual_clang)] ~in_help:InferCommand.[(Capture, manual_clang)]
@ -3198,6 +3204,8 @@ and write_website = !write_website
and xcode_developer_dir = !xcode_developer_dir and xcode_developer_dir = !xcode_developer_dir
and xcode_isysroot_suffix = !xcode_isysroot_suffix
and xcpretty = !xcpretty and xcpretty = !xcpretty
(** Configuration values derived from command-line options *) (** Configuration values derived from command-line options *)

@ -617,6 +617,8 @@ val write_website : string option
val xcode_developer_dir : string option val xcode_developer_dir : string option
val xcode_isysroot_suffix : string option
val xcpretty : bool val xcpretty : bool
(** {2 Configuration values derived from command-line options} *) (** {2 Configuration values derived from command-line options} *)

@ -59,7 +59,12 @@ let to_string =
path path
| Absolute path -> | Absolute path ->
if force_relative then if force_relative then
Option.value_exn (Utils.filename_to_relative ~force_full_backtrack:true ~root path) let open IOption.Let_syntax in
(let* isysroot_suffix = Config.xcode_isysroot_suffix in
let+ pos = String.substr_index path ~pattern:isysroot_suffix in
"${XCODE_ISYSROOT}" ^ String.subo ~pos:(pos + String.length isysroot_suffix) path)
|> IOption.if_none_eval ~f:(fun () ->
Option.value_exn (Utils.filename_to_relative ~force_full_backtrack:true ~root path) )
else path else path

@ -6,7 +6,8 @@
TESTS_DIR = ../../.. TESTS_DIR = ../../..
CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS)
INFER_OPTIONS = --cost-only --bufferoverrun --debug-exceptions --project-root $(TESTS_DIR) INFER_OPTIONS = --cost-only --bufferoverrun --debug-exceptions --project-root $(TESTS_DIR) \
--report-force-relative-path --xcode-isysroot-suffix $(XCODE_ISYSROOT_SUFFIX)
INFERPRINT_OPTIONS = --issues-tests INFERPRINT_OPTIONS = --issues-tests
INFERPRINT_COST_OPTIONS = --cost-issues-tests INFERPRINT_COST_OPTIONS = --cost-issues-tests

@ -121,9 +121,6 @@ id nsarray_first_object_constant(NSArray* array) { return array.firstObject; }
id nsarray_last_object_constant(NSArray* array) { return array.lastObject; } id nsarray_last_object_constant(NSArray* array) { return array.lastObject; }
// find element // find element
// To be uncommented when we find a solution to avoiding absolute paths
// from the standard library in tests.
/*
NSInteger nsarray_binary_search_log_FN(NSArray* sorted_array) { NSInteger nsarray_binary_search_log_FN(NSArray* sorted_array) {
NSNumber* target = @5; NSNumber* target = @5;
return [sorted_array indexOfObject:target return [sorted_array indexOfObject:target
@ -133,7 +130,6 @@ NSInteger nsarray_binary_search_log_FN(NSArray* sorted_array) {
return [lhs compare:rhs]; return [lhs compare:rhs];
}]; }];
} }
*/
// sort array // sort array

@ -1,8 +1,10 @@
${XCODE_ISYSROOT}/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h, NSArray.indexOfObject:inSortedRange:options:usingComparator:[objc_blocknsarray_binary_search_log_FN_1], 0, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_access_constant, 50, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_access_constant, 50, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_access_linear, 3 + 7 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop] codetoanalyze/objc/performance/NSArray.m, nsarray_access_linear, 3 + 7 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_add_object_constant, 8, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_add_object_constant, 8, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_add_objects_from_array_linear, 9 + 3 ⋅ append_array->elements.length.ub + append_array->elements.length.ub + 3 ⋅ (append_array->elements.length.ub + 1), OnUIThread:false, [{append_array->elements.length.ub + 1},Loop,{append_array->elements.length.ub},Modeled call to NSArray.arrayByAddingObjectsFromArray:,{append_array->elements.length.ub},Loop] codetoanalyze/objc/performance/NSArray.m, nsarray_add_objects_from_array_linear, 9 + 3 ⋅ append_array->elements.length.ub + append_array->elements.length.ub + 3 ⋅ (append_array->elements.length.ub + 1), OnUIThread:false, [{append_array->elements.length.ub + 1},Loop,{append_array->elements.length.ub},Modeled call to NSArray.arrayByAddingObjectsFromArray:,{append_array->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_array_with_objects_constant, 27, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_array_with_objects_constant, 27, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_binary_search_log_FN, 9, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_contains_object_linear, 3 + array->elements.length.ub, OnUIThread:false, [{array->elements.length.ub},Modeled call to NSArray.containsObject:] codetoanalyze/objc/performance/NSArray.m, nsarray_contains_object_linear, 3 + array->elements.length.ub, OnUIThread:false, [{array->elements.length.ub},Modeled call to NSArray.containsObject:]
codetoanalyze/objc/performance/NSArray.m, nsarray_count_bounded_linear, 3 + 3 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop] codetoanalyze/objc/performance/NSArray.m, nsarray_count_bounded_linear, 3 + 3 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_empty_array_constant, 8, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_empty_array_constant, 8, OnUIThread:false, []
@ -23,6 +25,7 @@ codetoanalyze/objc/performance/NSArray.m, nsarray_next_object_linear, 5 + array-
codetoanalyze/objc/performance/NSArray.m, nsarray_object_at_indexed_constant, 34, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_object_at_indexed_constant, 34, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_sort_using_descriptors_constant, 39, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_sort_using_descriptors_constant, 39, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_sort_using_descriptors_nlogn, 9 + array->elements.length.ub × log(array->elements.length.ub), OnUIThread:false, [{array->elements.length.ub},Modeled call to NSArray.sortedArrayUsingDescriptors:,{array->elements.length.ub},Modeled call to NSArray.sortedArrayUsingDescriptors:] codetoanalyze/objc/performance/NSArray.m, nsarray_sort_using_descriptors_nlogn, 9 + array->elements.length.ub × log(array->elements.length.ub), OnUIThread:false, [{array->elements.length.ub},Modeled call to NSArray.sortedArrayUsingDescriptors:,{array->elements.length.ub},Modeled call to NSArray.sortedArrayUsingDescriptors:]
codetoanalyze/objc/performance/NSArray.m, objc_blocknsarray_binary_search_log_FN_1, 5, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_keys_linear1, 3 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_keys_linear1, 3 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_keys_linear2, 6 + 3 ⋅ dict->elements.length.ub + 3 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_keys_linear2, 6 + 3 ⋅ dict->elements.length.ub + 3 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_values_linear, 3 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_values_linear, 3 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]

Loading…
Cancel
Save