forked from ziyingzhishang/piwik-sdk-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
72 lines (58 loc) · 2.24 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
include FileUtils::Verbose
namespace :test do
desc 'Prepare tests'
task :prepare do
end
desc 'Run the PiwikTracker Unit tests'
task ios: :prepare do
run_tests('PiwikTracker', 'iphonesimulator')
run_tests('PiwikTracker', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=10.2')
run_tests('PiwikTracker', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=9.3')
run_tests('PiwikTracker', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=8.4')
end
desc 'Build the PiwikTracker iOS demo'
task ios_demo: :prepare do
run_build('ios', 'iphonesimulator')
build_failed('iOS') unless $?.success?
end
desc 'Build the PiwikTracker OSX demo'
task osx_demo: :prepare do
run_build('macos', 'macosx', 'platform=macOS,arch=x86_64')
build_failed('macOS') unless $?.success?
end
desc 'Build the PiwikTracker tvOS demo'
task tvos_demo: :prepare do
run_build('tvos', 'appletvsimulator', 'platform=tvOS Simulator,name=Apple TV 1080p,OS=10.2')
build_failed('tvOS') unless $?.success?
end
end
desc 'Run the PiwikTracker tests for iOS & Mac OS X'
task :test do
Rake::Task['test:ios'].invoke
Rake::Task['test:ios_demo'].invoke
Rake::Task['test:osx_demo'].invoke
Rake::Task['test:tvos_demo'].invoke
end
task default: 'test'
private
def run_build(scheme, sdk, destination = 'platform=iOS Simulator,name=iPhone 6,OS=10.3.1')
sh("xcodebuild -workspace PiwikTracker.xcworkspace -scheme '#{scheme}' -sdk '#{sdk}' -destination '#{destination}' -configuration Release clean build | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
end
def run_tests(scheme, sdk, destination = 'platform=iOS Simulator,name=iPhone 6,OS=10.3.1')
sh("xcodebuild -workspace PiwikTracker.xcworkspace -scheme '#{scheme}' -sdk '#{sdk}' -destination '#{destination}' -configuration Debug clean test | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
end
def is_mavericks_or_above
osx_version = `sw_vers -productVersion`.chomp
Gem::Version.new(osx_version) >= Gem::Version.new('10.9')
end
def build_failed(platform)
puts red("#{platform} build failed")
exit $?.exitstatus
end
def tests_failed(platform)
puts red("#{platform} unit tests failed")
exit $?.exitstatus
end
def red(string)
"\033[0;31m! #{string}"
end