forked from FormatterKit/FormatterKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
122 lines (109 loc) · 4.34 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
117
118
119
120
121
KNOWN_LANGUAGES = [
'Arabic', 'Catalan', 'Chinese-Simplified', 'Chinese-Traditional',
'Czech', 'Danish', 'Dutch', 'English', 'French', 'German', 'Greek',
'Hebrew', 'Hungarian', 'Indonesian', 'Italian', 'Japanese', 'Korean',
'Malay', 'Norwegian-Bokmal', 'Norwegian-Nynorsk', 'Polish', 'Portuguese',
'Portuguese-Brazil', 'Romanian', 'Russian', 'Spanish', 'Swedish', 'Thai',
'Turkish', 'Ukrainian', 'Vietnamese'
]
def run(command, min_exit_status = 0)
puts "Executing: `#{command}`"
system(command)
$?.exitstatus
end
def is_travis?
ENV.has_key?("TRAVIS")
end
task :default => :spec
task :clean do
run "rm -rf build/"
end
def languages
if ENV["TTT_LANGS"]
passed_langs = ENV["TTT_LANGS"].split(' ')
raise "Unknown language(s) in `#{ENV["TTT_LANGS"]}`" unless passed_langs.all? { |l| KNOWN_LANGUAGES.include?(l) }
passed_langs
else
KNOWN_LANGUAGES
end
end
desc 'Runs unit tests. '
task :spec do
status = languages.map do |lang|
if is_travis?
puts "travis_fold:start:ios.tests.#{lang}"
else
puts "===\n=== Running tests for #{lang}\n==="
end
status = run "xcodebuild -workspace FormatterKit.xcworkspace -scheme #{lang} -sdk iphonesimulator -derivedDataPath build/DerivedData/#{lang} test | bundle exec xcpretty --test && exit ${PIPESTATUS[0]}" || 0
puts "travis_fold:end:ios.tests.#{lang}" if is_travis? && status.zero?
status
end.max
exit status
end
desc 'Runs all integration tests. Note: exit status is not handled properly.'
task :integration_tests => [
'integration:cocoapods_ios',
'integration:cocoapods_ios_static',
'integration:cocoapods_osx',
'integration:cocoapods_watchos',
'integration:carthage_ios',
'integration:carthage_osx',
'integration:carthage_watchos',
]
namespace :integration do
task :cocoapods_ios do
puts "travis_fold:start:integration.cocoapods_ios" if is_travis?
run "cd ./IntegrationTests/CocoaPods-iOS && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_ios" if is_travis?
end
task :cocoapods_ios_static do
puts "travis_fold:start:integration.cocoapods_ios_static" if is_travis?
run "cd ./IntegrationTests/CocoaPods-iOS-static && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_ios_static" if is_travis?
end
task :cocoapods_osx do
puts "travis_fold:start:integration.cocoapods_osx" if is_travis?
run "cd ./IntegrationTests/CocoaPods-OSX && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_osx" if is_travis?
end
task :cocoapods_watchos do
puts "travis_fold:start:integration.cocoapods_watchos" if is_travis?
run "cd ./IntegrationTests/CocoaPods-watchOS && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_watchos" if is_travis?
end
task :carthage_ios do
puts "travis_fold:start:integration.cocoapods_carthage_ios" if is_travis?
run "cd ./IntegrationTests/Carthage-iOS && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_carthage_ios" if is_travis?
end
task :carthage_osx do
puts "travis_fold:start:integration.cocoapods_carthage_osx" if is_travis?
run "cd ./IntegrationTests/Carthage-OSX && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_carthage_osx" if is_travis?
end
task :carthage_watchos do
puts "travis_fold:start:integration.cocoapods_carthage_watchos" if is_travis?
run "cd ./IntegrationTests/Carthage-watchOS && ./run.sh; cd -"
puts "travis_fold:end:integration.cocoapods_carthage_watchos" if is_travis?
end
end
desc 'Prints code coverage statistics.'
task :coverage => ['coverage:consolidate'] do
run "bundle exec slather coverage"
end
namespace :coverage do
desc 'Consolidates coverage files generated by `rake spec` into one file.'
task :consolidate do
paths = languages.map do |lang|
"build/DerivedData/#{lang}/Build/Intermediates/CodeCoverage/Coverage.profdata"
end
# Let's save consolidated file in a place where slather can find it
# https://github.com/SlatherOrg/slather/blob/v2.1.0/lib/slather/project.rb#L150
dir = 'build/slather/FormatterKit\\ Example'
run "mkdir -p #{dir}"
run "xcrun llvm-profdata merge -output=#{dir}/Coverage.profdata #{paths.join " "}"
# Copy binary file for slather to find
run "cp -R build/DerivedData/#{languages.first}/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/FormatterKit.framework build/slather/"
end
end