xcodebuild-helper 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +20 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +110 -0
- data/Guardfile +18 -0
- data/README.md +7 -0
- data/Rakefile +7 -0
- data/TODO.md +3 -0
- data/bin/oclint +5 -0
- data/bin/oclint-0.8 +5 -0
- data/bin/oclint-json-compilation-database +5 -0
- data/bin/oclint-xcodebuild +5 -0
- data/externals/oclint/LICENSE +69 -0
- data/externals/oclint/bin/oclint +0 -0
- data/externals/oclint/bin/oclint-0.10.2 +0 -0
- data/externals/oclint/bin/oclint-json-compilation-database +88 -0
- data/externals/oclint/bin/oclint-xcodebuild +218 -0
- data/externals/oclint/lib/clang/3.7.0/asan_blacklist.txt +13 -0
- data/externals/oclint/lib/clang/3.7.0/include/Intrin.h +958 -0
- data/externals/oclint/lib/clang/3.7.0/include/__stddef_max_align_t.h +43 -0
- data/externals/oclint/lib/clang/3.7.0/include/__wmmintrin_aes.h +72 -0
- data/externals/oclint/lib/clang/3.7.0/include/__wmmintrin_pclmul.h +34 -0
- data/externals/oclint/lib/clang/3.7.0/include/adxintrin.h +88 -0
- data/externals/oclint/lib/clang/3.7.0/include/altivec.h +13528 -0
- data/externals/oclint/lib/clang/3.7.0/include/ammintrin.h +215 -0
- data/externals/oclint/lib/clang/3.7.0/include/arm_acle.h +304 -0
- data/externals/oclint/lib/clang/3.7.0/include/arm_neon.h +68419 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx2intrin.h +1256 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512bwintrin.h +1250 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512cdintrin.h +131 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512dqintrin.h +242 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512erintrin.h +285 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512fintrin.h +2457 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512vlbwintrin.h +1907 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512vldqintrin.h +353 -0
- data/externals/oclint/lib/clang/3.7.0/include/avx512vlintrin.h +1982 -0
- data/externals/oclint/lib/clang/3.7.0/include/avxintrin.h +1308 -0
- data/externals/oclint/lib/clang/3.7.0/include/bmi2intrin.h +99 -0
- data/externals/oclint/lib/clang/3.7.0/include/bmiintrin.h +153 -0
- data/externals/oclint/lib/clang/3.7.0/include/cpuid.h +209 -0
- data/externals/oclint/lib/clang/3.7.0/include/cuda_builtin_vars.h +110 -0
- data/externals/oclint/lib/clang/3.7.0/include/emmintrin.h +1480 -0
- data/externals/oclint/lib/clang/3.7.0/include/f16cintrin.h +63 -0
- data/externals/oclint/lib/clang/3.7.0/include/float.h +124 -0
- data/externals/oclint/lib/clang/3.7.0/include/fma4intrin.h +236 -0
- data/externals/oclint/lib/clang/3.7.0/include/fmaintrin.h +234 -0
- data/externals/oclint/lib/clang/3.7.0/include/fxsrintrin.h +55 -0
- data/externals/oclint/lib/clang/3.7.0/include/htmintrin.h +226 -0
- data/externals/oclint/lib/clang/3.7.0/include/htmxlintrin.h +363 -0
- data/externals/oclint/lib/clang/3.7.0/include/ia32intrin.h +101 -0
- data/externals/oclint/lib/clang/3.7.0/include/immintrin.h +203 -0
- data/externals/oclint/lib/clang/3.7.0/include/inttypes.h +102 -0
- data/externals/oclint/lib/clang/3.7.0/include/iso646.h +43 -0
- data/externals/oclint/lib/clang/3.7.0/include/limits.h +118 -0
- data/externals/oclint/lib/clang/3.7.0/include/lzcntintrin.h +72 -0
- data/externals/oclint/lib/clang/3.7.0/include/mm3dnow.h +167 -0
- data/externals/oclint/lib/clang/3.7.0/include/mm_malloc.h +75 -0
- data/externals/oclint/lib/clang/3.7.0/include/mmintrin.h +507 -0
- data/externals/oclint/lib/clang/3.7.0/include/module.modulemap +196 -0
- data/externals/oclint/lib/clang/3.7.0/include/nmmintrin.h +35 -0
- data/externals/oclint/lib/clang/3.7.0/include/pmmintrin.h +122 -0
- data/externals/oclint/lib/clang/3.7.0/include/popcntintrin.h +50 -0
- data/externals/oclint/lib/clang/3.7.0/include/prfchwintrin.h +39 -0
- data/externals/oclint/lib/clang/3.7.0/include/rdseedintrin.h +59 -0
- data/externals/oclint/lib/clang/3.7.0/include/rtmintrin.h +59 -0
- data/externals/oclint/lib/clang/3.7.0/include/s390intrin.h +39 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/allocator_interface.h +66 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/asan_interface.h +155 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/common_interface_defs.h +118 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/coverage_interface.h +63 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/dfsan_interface.h +114 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/linux_syscall_hooks.h +3070 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/lsan_interface.h +84 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/msan_interface.h +107 -0
- data/externals/oclint/lib/clang/3.7.0/include/sanitizer/tsan_interface_atomic.h +222 -0
- data/externals/oclint/lib/clang/3.7.0/include/shaintrin.h +79 -0
- data/externals/oclint/lib/clang/3.7.0/include/smmintrin.h +487 -0
- data/externals/oclint/lib/clang/3.7.0/include/stdalign.h +35 -0
- data/externals/oclint/lib/clang/3.7.0/include/stdarg.h +52 -0
- data/externals/oclint/lib/clang/3.7.0/include/stdatomic.h +190 -0
- data/externals/oclint/lib/clang/3.7.0/include/stdbool.h +44 -0
- data/externals/oclint/lib/clang/3.7.0/include/stddef.h +137 -0
- data/externals/oclint/lib/clang/3.7.0/include/stdint.h +707 -0
- data/externals/oclint/lib/clang/3.7.0/include/stdnoreturn.h +30 -0
- data/externals/oclint/lib/clang/3.7.0/include/tbmintrin.h +154 -0
- data/externals/oclint/lib/clang/3.7.0/include/tgmath.h +1374 -0
- data/externals/oclint/lib/clang/3.7.0/include/tmmintrin.h +230 -0
- data/externals/oclint/lib/clang/3.7.0/include/unwind.h +282 -0
- data/externals/oclint/lib/clang/3.7.0/include/vadefs.h +65 -0
- data/externals/oclint/lib/clang/3.7.0/include/varargs.h +26 -0
- data/externals/oclint/lib/clang/3.7.0/include/vecintrin.h +8946 -0
- data/externals/oclint/lib/clang/3.7.0/include/wmmintrin.h +42 -0
- data/externals/oclint/lib/clang/3.7.0/include/x86intrin.h +81 -0
- data/externals/oclint/lib/clang/3.7.0/include/xmmintrin.h +1008 -0
- data/externals/oclint/lib/clang/3.7.0/include/xopintrin.h +809 -0
- data/externals/oclint/lib/clang/3.7.0/include/xtestintrin.h +41 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.builtins-i386.a +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.builtins-x86_64.a +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.profile_osx.a +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.safestack_osx.a +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.ubsan_iossim_dynamic.dylib +0 -0
- data/externals/oclint/lib/clang/3.7.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib +0 -0
- data/externals/oclint/lib/oclint/reporters/libHTMLReporter.dylib +0 -0
- data/externals/oclint/lib/oclint/reporters/libJSONReporter.dylib +0 -0
- data/externals/oclint/lib/oclint/reporters/libPMDReporter.dylib +0 -0
- data/externals/oclint/lib/oclint/reporters/libTextReporter.dylib +0 -0
- data/externals/oclint/lib/oclint/reporters/libXMLReporter.dylib +0 -0
- data/externals/oclint/lib/oclint/reporters/libXcodeReporter.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libAvoidBranchingStatementAsLastInLoopRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libAvoidDefaultArgumentsOnVirtualMethodsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libAvoidPrivateStaticMembersRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libBaseClassDestructorShouldBeVirtualOrProtectedRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libBitwiseOperatorInConditionalRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libBrokenNullCheckRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libBrokenOddnessCheckRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libCollapsibleIfStatementsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libConstantConditionalOperatorRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libConstantIfExpressionRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libCoveredSwitchStatementsDontNeedDefaultRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libCyclomaticComplexityRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libDeadCodeRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libDefaultLabelNotLastInSwitchStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libDestructorOfVirtualClassRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libDoubleNegativeRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyCatchStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyDoWhileStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyElseBlockRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyFinallyStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyForStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyIfStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptySwitchStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyTryStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libEmptyWhileStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libForLoopShouldBeWhileLoopRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libGotoStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libInvertedLogicRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libJumbledIncrementerRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libLongClassRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libLongLineRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libLongMethodRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libLongVariableNameRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libMisplacedNullCheckRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libMissingBreakInSwitchStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libMultipleUnaryOperatorRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libNPathComplexityRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libNcssMethodCountRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libNestedBlockDepthRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libNonCaseLabelInSwitchStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCAssignIvarOutsideAccessorsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCBoxedExpressionsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCContainerLiteralsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCNSNumberLiteralsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCObjectSubscriptingRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCVerifyIsEqualHashRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCVerifyMustCallSuperRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCVerifyProhibitedCallRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCVerifyProtectedMethodRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libObjCVerifySubclassMustImplementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libParameterReassignmentRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libPreferEarlyExitRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libRedundantConditionalOperatorRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libRedundantIfStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libRedundantLocalVariableRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libRedundantNilCheckRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libReturnFromFinallyBlockRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libShortVariableNameRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libSwitchStatementsShouldHaveDefaultRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libThrowExceptionFromFinallyBlockRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libTooFewBranchesInSwitchStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libTooManyFieldsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libTooManyMethodsRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libTooManyParametersRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libUnnecessaryElseStatementRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libUnnecessaryNullCheckForCXXDeallocRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libUnusedLocalVariableRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libUnusedMethodParameterRule.dylib +0 -0
- data/externals/oclint/lib/oclint/rules/libUselessParenthesesRule.dylib +0 -0
- data/lib/coverage_plan.rb +19 -0
- data/lib/device.rb +27 -0
- data/lib/execute.rb +7 -0
- data/lib/lint_plan.rb +41 -0
- data/lib/rules.rb +23 -0
- data/lib/test_plan.rb +11 -0
- data/lib/version.rb +3 -0
- data/lib/xcode.rb +128 -0
- data/lib/xcodebuild-helper.rb +110 -0
- data/spec/coverage_plan_spec.rb +18 -0
- data/spec/device_spec.rb +24 -0
- data/spec/lint_plan_spec.rb +35 -0
- data/spec/rule_spec.rb +37 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/test_plan_spec.rb +11 -0
- data/spec/xcode_dsl_actions_spec.rb +136 -0
- data/spec/xcode_dsl_spec.rb +176 -0
- data/spec/xcode_spec.rb +79 -0
- data/xcodebuild-helper.gemspec +26 -0
- metadata +327 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'xcode'
|
2
|
+
require 'execute'
|
3
|
+
|
4
|
+
module XCodeBuildHelper
|
5
|
+
@registry = {}
|
6
|
+
def self.[](name)
|
7
|
+
@registry[name]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.define(name, &block)
|
11
|
+
xcode = @registry[name]
|
12
|
+
if xcode == nil
|
13
|
+
xcode = XCodeBuildHelper::XCode.new
|
14
|
+
end
|
15
|
+
xcode.instance_eval(&block)
|
16
|
+
@registry[name] = xcode
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.build(name, device = nil)
|
20
|
+
xcode = @registry[name]
|
21
|
+
|
22
|
+
unless xcode == nil
|
23
|
+
cmd = create_base_cmd(xcode)
|
24
|
+
if device != nil
|
25
|
+
cmd += parse_destination(xcode.get_device(device))
|
26
|
+
end
|
27
|
+
XCodeBuildHelper::Execute.call(cmd + "clean build | bundle exec xcpretty --color --report json-compilation-database")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.test_suite(name, plan, device = nil)
|
32
|
+
xcode = @registry[name]
|
33
|
+
|
34
|
+
unless xcode == nil
|
35
|
+
cmd = create_base_cmd(xcode)
|
36
|
+
if device != nil
|
37
|
+
cmd += parse_destination(xcode.get_device(device))
|
38
|
+
end
|
39
|
+
XCodeBuildHelper::Execute.call(cmd + "test | bundle exec xcpretty --color --report #{xcode.get_test_plan(plan).get_report_type}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.create_base_cmd(project)
|
44
|
+
"xcodebuild -workspace \"#{project.get_workspace}.xcworkspace\" -scheme #{project.get_scheme} -sdk #{project.get_sdk} -config #{project.get_config} "
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.parse_destination(device)
|
48
|
+
if device == nil
|
49
|
+
""
|
50
|
+
else
|
51
|
+
"-destination 'platform=#{device.get_platform},name=#{device.get_name},OS=#{device.get_os}' "
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.base_app_location(xcode)
|
56
|
+
unless xcode == nil
|
57
|
+
cmd = create_base_cmd(xcode)
|
58
|
+
result = XCodeBuildHelper::Execute.call(cmd + "-showBuildSettings")
|
59
|
+
parse_app_settings(result)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.parse_app_settings(settings)
|
64
|
+
result = /OBJROOT = ([a-zA-Z0-9\/ _\-]+)/.match(settings)
|
65
|
+
if result != nil
|
66
|
+
result[1]
|
67
|
+
else
|
68
|
+
""
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.app_binary_location(project)
|
73
|
+
Dir.glob(base_app_location(project) + "/CodeCoverage/#{project.get_scheme}/Products/#{project.get_config}-#{project.get_sdk}/#{project.get_workspace.gsub(/\s+/, '\\ ')}.app/#{project.get_workspace.gsub(/\s+/,"\\ ")}").first
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.profdata_location(project)
|
77
|
+
Dir.glob(base_app_location(project) + "/CodeCoverage/#{project.get_scheme}/Coverage.profdata").first
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.generate_coverage(name, plan)
|
81
|
+
xcode = @registry[name]
|
82
|
+
unless xcode == nil
|
83
|
+
coverage_plan = xcode.get_coverage_plan(plan)
|
84
|
+
result = XCodeBuildHelper::Execute.call("xcrun llvm-cov show -instr-profile \"#{profdata_location(xcode)}\" \"#{app_binary_location(xcode)}\" #{coverage_plan.get_source_files.first}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.lint(name, plan)
|
89
|
+
xcode = @registry[name]
|
90
|
+
lint_plan = xcode.get_lint_plan(plan)
|
91
|
+
|
92
|
+
cmd = "bundle exec oclint-json-compilation-database"
|
93
|
+
if(lint_plan.get_ignore)
|
94
|
+
cmd += " -e \"#{lint_plan.get_ignore}\""
|
95
|
+
end
|
96
|
+
cmd += " --"
|
97
|
+
if(lint_plan.get_report_type && lint_plan.get_output)
|
98
|
+
cmd += " -report-type #{lint_plan.get_report_type} -o #{lint_plan.get_output}"
|
99
|
+
end
|
100
|
+
|
101
|
+
rules = lint_plan.get_rules
|
102
|
+
rules.get_attribute_list.each do |key|
|
103
|
+
u_key = rules.send("key_" + key.to_s)
|
104
|
+
value = rules.send("get_" + key.to_s)
|
105
|
+
cmd += " -rc #{u_key}=#{value}"
|
106
|
+
end
|
107
|
+
|
108
|
+
XCodeBuildHelper::Execute.call(cmd)
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'coverage_plan'
|
2
|
+
|
3
|
+
RSpec.describe XCodeBuildHelper::CoveragePlan do
|
4
|
+
context "Setter methods" do
|
5
|
+
before(:each) do
|
6
|
+
@coverage_plan = XCodeBuildHelper::CoveragePlan.new
|
7
|
+
end
|
8
|
+
it "should set the report type" do
|
9
|
+
@coverage_plan.report_type "REPORT_TYPE"
|
10
|
+
expect(@coverage_plan.get_report_type).to eq "REPORT_TYPE"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set the source files" do
|
14
|
+
@coverage_plan.source_files ["path/tofiles/*.m"]
|
15
|
+
expect(@coverage_plan.get_source_files).to eq ["path/tofiles/*.m"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/device_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'device'
|
2
|
+
|
3
|
+
RSpec.describe XCodeBuildHelper::Device do
|
4
|
+
context "Setter methods" do
|
5
|
+
before(:each) do
|
6
|
+
@device = XCodeBuildHelper::Device.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set the platform name" do
|
10
|
+
@device.platform "PLATFORM"
|
11
|
+
expect(@device.get_platform).to eq "PLATFORM"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should set the name" do
|
15
|
+
@device.name "NAME"
|
16
|
+
expect(@device.get_name).to eq "NAME"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should set the name" do
|
20
|
+
@device.os "9.2"
|
21
|
+
expect(@device.get_os).to eq "9.2"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'lint_plan'
|
2
|
+
require 'rules'
|
3
|
+
|
4
|
+
RSpec.describe XCodeBuildHelper::LintPlan do
|
5
|
+
before(:each) do
|
6
|
+
@lint_plan = XCodeBuildHelper::LintPlan.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Setter methods" do
|
10
|
+
it "should set the report type" do
|
11
|
+
@lint_plan.report_type "REPORT_TYPE"
|
12
|
+
expect(@lint_plan.get_report_type).to eq "REPORT_TYPE"
|
13
|
+
end
|
14
|
+
it "should set the output type" do
|
15
|
+
@lint_plan.output "OUTPUT_LOCATION"
|
16
|
+
expect(@lint_plan.get_output).to eq "OUTPUT_LOCATION"
|
17
|
+
end
|
18
|
+
it "should set the ignore type" do
|
19
|
+
@lint_plan.ignore "IGNORE"
|
20
|
+
expect(@lint_plan.get_ignore).to eq "IGNORE"
|
21
|
+
end
|
22
|
+
context "setting rules" do
|
23
|
+
before(:each) do
|
24
|
+
@rules = XCodeBuildHelper::Rules.new
|
25
|
+
@rules.long_line 120
|
26
|
+
@rules.short_variable_name 3
|
27
|
+
end
|
28
|
+
it "should set the rule list" do
|
29
|
+
@lint_plan.rules @rules
|
30
|
+
expect(@lint_plan.get_rules.get_long_line).to eq 120
|
31
|
+
expect(@lint_plan.get_rules.get_short_variable_name).to eq 3
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/rule_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rules'
|
2
|
+
|
3
|
+
RSpec.describe XCodeBuildHelper::Rules do
|
4
|
+
before(:each) do
|
5
|
+
@rules = XCodeBuildHelper::Rules.new
|
6
|
+
end
|
7
|
+
context "Setter methods" do
|
8
|
+
it "should set the long line rule" do
|
9
|
+
@rules.long_line 120
|
10
|
+
expect(@rules.get_long_line).to eq 120
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set the shor variable name rule" do
|
14
|
+
@rules.short_variable_name 3
|
15
|
+
expect(@rules.get_short_variable_name).to eq 3
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "key methods" do
|
20
|
+
it "should return the uppercase version of the method" do
|
21
|
+
@rules.long_line 120
|
22
|
+
expect(@rules.key_long_line).to eq "LONG_LINE"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the uppercase version of the method" do
|
26
|
+
expect(@rules.key_long_line).to eq nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "get list of attributes" do
|
31
|
+
it "should return a list of attributes" do
|
32
|
+
@rules.long_line 120
|
33
|
+
@rules.short_variable_name 3
|
34
|
+
expect(@rules.get_attribute_list).to eq [:long_line, :short_variable_name]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
7
|
+
end
|
8
|
+
|
9
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
10
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
11
|
+
config.mock_with :rspec do |mocks|
|
12
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
13
|
+
# a real object. This is generally recommended, and will default to
|
14
|
+
# `true` in RSpec 4.
|
15
|
+
mocks.verify_partial_doubles = true
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_plan'
|
2
|
+
|
3
|
+
RSpec.describe XCodeBuildHelper::TestPlan do
|
4
|
+
context "setter methods" do
|
5
|
+
it "should set the report type" do
|
6
|
+
@test_plan = XCodeBuildHelper::TestPlan.new
|
7
|
+
@test_plan.report_type "REPORT_TYPE"
|
8
|
+
expect(@test_plan.get_report_type).to eq "REPORT_TYPE"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'xcodebuild-helper'
|
2
|
+
|
3
|
+
RSpec.describe "DSL actions" do
|
4
|
+
context "build" do
|
5
|
+
before(:each) do
|
6
|
+
XCodeBuildHelper.define :default do
|
7
|
+
workspace "WORK SPACE"
|
8
|
+
scheme "SCHEME"
|
9
|
+
sdk "SDK"
|
10
|
+
config "CONFIG"
|
11
|
+
device :ipad do
|
12
|
+
platform "PLATFORM"
|
13
|
+
name "NAME"
|
14
|
+
os "OS"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create the proper CLI to build the app" do
|
20
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcodebuild -workspace \"WORK SPACE.xcworkspace\" -scheme SCHEME -sdk SDK -config CONFIG clean build | bundle exec xcpretty --color --report json-compilation-database")
|
21
|
+
XCodeBuildHelper.build(:default)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should create the proper CLI for the ipad" do
|
25
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcodebuild -workspace \"WORK SPACE.xcworkspace\" -scheme SCHEME -sdk SDK -config CONFIG -destination 'platform=PLATFORM,name=NAME,OS=OS' clean build | bundle exec xcpretty --color --report json-compilation-database")
|
26
|
+
XCodeBuildHelper.build(:default, :ipad)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "test_suite" do
|
31
|
+
before(:each) do
|
32
|
+
XCodeBuildHelper.define :default do
|
33
|
+
workspace "WORK SPACE"
|
34
|
+
scheme "SCHEME"
|
35
|
+
sdk "SDK"
|
36
|
+
config "CONFIG"
|
37
|
+
|
38
|
+
device :ipad do
|
39
|
+
platform "PLATFORM"
|
40
|
+
name "NAME"
|
41
|
+
os "OS"
|
42
|
+
end
|
43
|
+
|
44
|
+
test_plan :plan_a do
|
45
|
+
report_type 'html'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should create the proper CLI for testing" do
|
51
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcodebuild -workspace \"WORK SPACE.xcworkspace\" -scheme SCHEME -sdk SDK -config CONFIG test | bundle exec xcpretty --color --report html")
|
52
|
+
XCodeBuildHelper.test_suite(:default, :plan_a)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should create the proper CLI for testing for ipad" do
|
56
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcodebuild -workspace \"WORK SPACE.xcworkspace\" -scheme SCHEME -sdk SDK -config CONFIG -destination 'platform=PLATFORM,name=NAME,OS=OS' test | bundle exec xcpretty --color --report html")
|
57
|
+
XCodeBuildHelper.test_suite(:default, :plan_a, :ipad)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "code coverage" do
|
62
|
+
before(:each) do
|
63
|
+
XCodeBuildHelper.define :default do
|
64
|
+
workspace "WORK SPACE"
|
65
|
+
scheme "SCHEME"
|
66
|
+
sdk "SDK"
|
67
|
+
config "CONFIG"
|
68
|
+
|
69
|
+
device :ipad do
|
70
|
+
platform "PLATFORM"
|
71
|
+
name "NAME"
|
72
|
+
os "OS"
|
73
|
+
end
|
74
|
+
|
75
|
+
coverage_plan :plan_a do
|
76
|
+
report_type "xml"
|
77
|
+
source_files ["path/to/files/*"]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "will find the base app directory" do
|
83
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcodebuild -workspace \"WORK SPACE.xcworkspace\" -scheme SCHEME -sdk SDK -config CONFIG -showBuildSettings")
|
84
|
+
XCodeBuildHelper.base_app_location(XCodeBuildHelper[:default])
|
85
|
+
end
|
86
|
+
|
87
|
+
it "will find the app binary" do
|
88
|
+
allow(XCodeBuildHelper).to receive(:base_app_location).and_return("/path/to/app")
|
89
|
+
expect(Dir).to receive(:glob).with("/path/to/app/CodeCoverage/SCHEME/Products/CONFIG-SDK/WORK\\ SPACE.app/WORK\\ SPACE").and_return([])
|
90
|
+
XCodeBuildHelper.app_binary_location(XCodeBuildHelper[:default])
|
91
|
+
end
|
92
|
+
|
93
|
+
it "will find the app profdata" do
|
94
|
+
allow(XCodeBuildHelper).to receive(:base_app_location).and_return("/path/to/app")
|
95
|
+
expect(Dir).to receive(:glob).with("/path/to/app/CodeCoverage/SCHEME/Coverage.profdata").and_return([])
|
96
|
+
XCodeBuildHelper.profdata_location(XCodeBuildHelper[:default])
|
97
|
+
end
|
98
|
+
|
99
|
+
it "will return the CLI for finding code coverage" do
|
100
|
+
allow(XCodeBuildHelper).to receive(:app_binary_location).and_return("/path/to/app/bin")
|
101
|
+
allow(XCodeBuildHelper).to receive(:profdata_location).and_return("/path/to/app/prof")
|
102
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcrun llvm-cov show -instr-profile \"/path/to/app/prof\" \"/path/to/app/bin\" path/to/files/*")
|
103
|
+
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "lint" do
|
108
|
+
before(:each) do
|
109
|
+
XCodeBuildHelper.define :default do
|
110
|
+
workspace "WORK SPACE"
|
111
|
+
scheme "SCHEME"
|
112
|
+
sdk "SDK"
|
113
|
+
config "CONFIG"
|
114
|
+
|
115
|
+
device :ipad do
|
116
|
+
platform "PLATFORM"
|
117
|
+
name "NAME"
|
118
|
+
os "OS"
|
119
|
+
end
|
120
|
+
|
121
|
+
lint_plan :plan_a do
|
122
|
+
report_type "REPORT_TYPE"
|
123
|
+
output "OUTPUT"
|
124
|
+
ignore "IGNORE"
|
125
|
+
rules do
|
126
|
+
long_line 120
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
it "should call the correct CLI for the lint" do
|
132
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("bundle exec oclint-json-compilation-database -e \"IGNORE\" -- -report-type REPORT_TYPE -o OUTPUT -rc LONG_LINE=120")
|
133
|
+
XCodeBuildHelper.lint(:default, :plan_a)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'xcodebuild-helper'
|
2
|
+
|
3
|
+
RSpec.describe "DSL" do
|
4
|
+
context "define" do
|
5
|
+
before(:each) do
|
6
|
+
XCodeBuildHelper.define :default do
|
7
|
+
workspace "WORK SPACE"
|
8
|
+
scheme "SCHEME"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should register the default with a workspace" do
|
13
|
+
expect(XCodeBuildHelper[:default].get_workspace).to eq("WORK SPACE")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should register the default with a scheme" do
|
17
|
+
expect(XCodeBuildHelper[:default].get_scheme).to eq("SCHEME")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "registering a device" do
|
22
|
+
before(:each) do
|
23
|
+
XCodeBuildHelper.define :default do
|
24
|
+
workspace "WORK SPACE"
|
25
|
+
scheme "SCHEME"
|
26
|
+
device :ipad do
|
27
|
+
platform "PLATFORM"
|
28
|
+
name "NAME"
|
29
|
+
os "9.2"
|
30
|
+
end
|
31
|
+
|
32
|
+
device :iphone do
|
33
|
+
platform "PLATFORM_2"
|
34
|
+
name "NAME_2"
|
35
|
+
os "7.0"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
it "should register an ipad on the project" do
|
40
|
+
expect(XCodeBuildHelper[:default].get_device(:ipad).get_platform).to eq "PLATFORM"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should register an iphone on the project" do
|
44
|
+
expect(XCodeBuildHelper[:default].get_device(:iphone).get_os).to eq "7.0"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not overwrite the device" do
|
48
|
+
XCodeBuildHelper.define :default do
|
49
|
+
device :ipad do
|
50
|
+
name "IPAD"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
expect(XCodeBuildHelper[:default].get_device(:ipad).get_platform).to eq "PLATFORM"
|
54
|
+
expect(XCodeBuildHelper[:default].get_device(:ipad).get_name).to eq "IPAD"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "register a test plan" do
|
59
|
+
before(:each) do
|
60
|
+
XCodeBuildHelper.define :default do
|
61
|
+
workspace "WORK SPACE"
|
62
|
+
scheme "SCHEME"
|
63
|
+
test_plan :plan_a do
|
64
|
+
report_type 'junit'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should register a test plan a on the project" do
|
70
|
+
report_type = XCodeBuildHelper[:default].get_test_plan(:plan_a).get_report_type
|
71
|
+
expect(report_type).to eq 'junit'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not overwrite the test plan" do
|
75
|
+
XCodeBuildHelper.define :default do
|
76
|
+
test_plan :plan_a do
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
report_type = XCodeBuildHelper[:default].get_test_plan(:plan_a).get_report_type
|
81
|
+
expect(report_type).to eq 'junit'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "register a coverage plan" do
|
86
|
+
before(:each) do
|
87
|
+
XCodeBuildHelper.define :default do
|
88
|
+
workspace "WORK SPACE"
|
89
|
+
scheme "SCHEME"
|
90
|
+
coverage_plan :plan_a do
|
91
|
+
source_files ['/path/to/files/*.m']
|
92
|
+
report_type "REPORT_TYPE"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
it "should set the source files" do
|
97
|
+
expect(XCodeBuildHelper[:default].get_coverage_plan(:plan_a).get_source_files).to eq ['/path/to/files/*.m']
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not overwrite the coverage plan" do
|
101
|
+
XCodeBuildHelper.define :default do
|
102
|
+
coverage_plan :plan_a do
|
103
|
+
report_type "EXPECTED"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
expect(XCodeBuildHelper[:default].get_coverage_plan(:plan_a).get_report_type).to eq "EXPECTED"
|
108
|
+
expect(XCodeBuildHelper[:default].get_coverage_plan(:plan_a).get_source_files).to eq ['/path/to/files/*.m']
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "register a lint plan" do
|
113
|
+
before(:each) do
|
114
|
+
XCodeBuildHelper.define :default do
|
115
|
+
workspace "WORK SPACE"
|
116
|
+
lint_plan :plan_a do
|
117
|
+
report_type "REPORT_TYPE"
|
118
|
+
output "OUTPUT"
|
119
|
+
ignore "IGNORE"
|
120
|
+
rules do
|
121
|
+
long_line 120
|
122
|
+
short_variable_name 3
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should set the lint plan" do
|
130
|
+
expect(XCodeBuildHelper[:default].get_lint_plan(:plan_a).get_report_type).to eq "REPORT_TYPE"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should set the rules" do
|
134
|
+
expect(XCodeBuildHelper[:default].get_lint_plan(:plan_a).get_rules.get_long_line).to eq 120
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should not overwrite the lint_plan" do
|
138
|
+
XCodeBuildHelper.define :default do
|
139
|
+
lint_plan :plan_a do
|
140
|
+
report_type "EXPECTED"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
expect(XCodeBuildHelper[:default].get_lint_plan(:plan_a).get_report_type).to eq "EXPECTED"
|
145
|
+
expect(XCodeBuildHelper[:default].get_lint_plan(:plan_a).get_output).to eq "OUTPUT"
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should not overwrite previous rules" do
|
149
|
+
XCodeBuildHelper.define :default do
|
150
|
+
lint_plan :plan_a do
|
151
|
+
rules do
|
152
|
+
long_line 100
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
expect(XCodeBuildHelper[:default].get_lint_plan(:plan_a).get_rules.get_long_line).to eq 100
|
158
|
+
expect(XCodeBuildHelper[:default].get_lint_plan(:plan_a).get_rules.get_short_variable_name).to eq 3
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context "edit an existing build plan" do
|
163
|
+
it "should overwrite the workspace but not the scheme" do
|
164
|
+
XCodeBuildHelper.define :default do
|
165
|
+
workspace "WORK SPACE"
|
166
|
+
scheme "SCHEME"
|
167
|
+
end
|
168
|
+
|
169
|
+
XCodeBuildHelper.define :default do
|
170
|
+
workspace "EXPECTED"
|
171
|
+
end
|
172
|
+
expect(XCodeBuildHelper[:default].get_workspace).to eq "EXPECTED"
|
173
|
+
expect(XCodeBuildHelper[:default].get_scheme).to eq "SCHEME"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|