forked from Gareth-swifter/SpreadsheetView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
78 lines (70 loc) · 2.53 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
require 'xcjobs'
namespace :test do
desc 'test on simulator'
XCJobs::Test.new("simulator") do |t|
configuration = ENV['CONFIGURATION'] || 'Release'
destinations = eval(ENV['DESTINATIONS'] || '[]')
testcase = ENV['TESTCASE']
swift_version = ENV['SWIFT_VERSION'] || '4.0'
t.workspace = 'SpreadsheetView'
t.scheme = 'SpreadsheetView'
t.sdk = 'iphonesimulator'
t.configuration = configuration
destinations.each { |destination| t.add_destination(destination) }
t.add_only_testing("SpreadsheetViewTests/#{testcase}") if testcase
t.add_build_option('-enableCodeCoverage', 'YES')
t.add_build_setting('ENABLE_TESTABILITY', 'YES')
t.add_build_setting('ONLY_ACTIVE_ARCH', 'NO')
t.add_build_setting('SWIFT_VERSION', swift_version)
t.build_dir = 'build'
t.after_action do
build_coverage_reports()
end
end
end
namespace 'build-for-testing' do
desc 'build for testing'
XCJobs::BuildForTesting.new("simulator") do |t|
configuration = ENV['CONFIGURATION'] || 'Release'
t.workspace = 'SpreadsheetView'
t.scheme = 'SpreadsheetView'
t.sdk = 'iphonesimulator'
t.configuration = configuration
t.add_build_option('-enableCodeCoverage', 'YES')
t.add_build_setting('ENABLE_TESTABILITY', 'YES')
t.add_build_setting('ONLY_ACTIVE_ARCH', 'NO')
t.build_dir = 'build'
t.hide_shell_script_environment = true
end
end
namespace 'test-without-building' do
desc 'test on simulator without building'
XCJobs::TestWithoutBuilding.new("simulator") do |t|
configuration = ENV['CONFIGURATION'] || 'Release'
destinations = eval(ENV['DESTINATIONS'] || '[]')
testcase = ENV['TESTCASE']
t.workspace = 'SpreadsheetView'
t.scheme = 'SpreadsheetView'
t.sdk = 'iphonesimulator'
t.configuration = configuration
destinations.each { |destination| t.add_destination(destination) }
t.add_only_testing("SpreadsheetViewTests/#{testcase}") if testcase
t.add_build_option('-enableCodeCoverage', 'YES')
t.build_dir = 'build'
t.after_action do
build_coverage_reports()
end
end
end
def build_coverage_reports()
project_name = 'SpreadsheetView'
profdata = Dir.glob(File.join('build', '/**/Coverage.profdata')).first
Dir.glob(File.join('build', "/**/#{project_name}")) do |target|
output = `xcrun llvm-cov report -instr-profile "#{profdata}" "#{target}" -arch=x86_64`
if $?.success?
puts output
`xcrun llvm-cov show -instr-profile "#{profdata}" "#{target}" -arch=x86_64 -use-color=0 > coverage.txt`
break
end
end
end