forked from FormatterKit/FormatterKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (53 loc) · 1.87 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
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
desc 'Run unit tests'
task :spec => :clean 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
if status.zero? && is_travis?
puts "travis_fold:end:ios.tests.#{lang}"
end
status
end.max
exit status
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 " "}"
end
end