-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRakefile
116 lines (92 loc) · 2.83 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
include Rake::DSL
SUPPORTED_PLATFORMS = "iphoneos"
CARTHAGE_PLATFORMS = {'platform' => "#{SUPPORTED_PLATFORMS}"}
SWIFT_3_1_TOOLCHAIN = {'toolchain' => 'com.apple.dt.toolchain.Swift_3_1'}
SCHEME = "Scenarios-iOS"
DESTINATION = "platform=iOS Simulator,name=iPhone 6s"
desc "Setup Scenarios for development"
task :setup do
CarthageTask::Bootstrap.execute
end
namespace :test do
desc "Attempts to build Scenarios and its dependencies"
task :build do
CarthageTask::Build.execute
end
desc "Runs the unit tests for Scenarios"
task :specs do
sh "xcodebuild test -configuration Release -scheme #{SCHEME} -destination '#{DESTINATION}' | xcpretty -c; exit ${PIPESTATUS[0]}"
end
desc "Runs the unit tests for Scenarios via swiftpm"
task :package do
sh "env SCENARIOS_SWIFTPM_TEST=true swift test"
end
desc "Runs the UI tests / demo for Scenarios"
task :demo do
sh "xcodebuild test -configuration Release -workspace Demo/Demo.xcworkspace -scheme Demo-iOS -destination '#{DESTINATION}' | xcpretty -c; exit ${PIPESTATUS[0]}"
end
desc "Run all tests"
task :all => ["test:package", "test:specs", "test:demo"]
end
desc "Run the specs & UI tests"
task :test => ["test:specs", "test:demo"]
desc "Cleans the Scenarios development workspace"
task :clean do
sh "xcodebuild clean -configuration Release -scheme #{SCHEME} -destination '#{DESTINATION}' | xcpretty -c; exit ${PIPESTATUS[0]}"
end
task :default => :test
# Utility
class Array
def includeAny? (arrayOfElements)
raise "'#{arrayOfElements}' is not an `Array`" unless arrayOfElements.is_a? Array
arrayOfElements.each { |element| return true if self.include? element }
return false
end
def appendUnique (element)
self << element unless self.include? element
end
end
class Task
@command
def initialize (task, arguments)
@task = task
@arguments = arguments
end
def execute
self.executeWith @arguments
end
def executeWith (arguments)
function = @command
function += " #{@task}"
arguments.each { |element|
if element.is_a? Hash
element.each { |flag, value|
function += " --#{flag}"
function += " #{value}" unless value.nil?
}
else
function += " --#{element}"
end
}
system exec function
end
end
class CarthageTask < Task
def initialize (task, arguments)
super(task, arguments)
@command = 'carthage'
end
def execute
arguments = @arguments
arguments.appendUnique SWIFT_3_1_TOOLCHAIN if canUseSwift2_3?
super.executeWith arguments
end
Bootstrap = CarthageTask.new 'bootstrap', ['no-use-binaries', CARTHAGE_PLATFORMS]
Build = CarthageTask.new 'build', ['no-skip-current', CARTHAGE_PLATFORMS]
end
def canUseSwift2_3?
`xcodebuild -version | grep 'Xcode 8'`
.split
.map { |text| text.to_f }
.includeAny? [8.0, 8.1, 8.2]
end