forked from AFNetworking/AFNetworking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
50 lines (38 loc) · 1.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
include FileUtils::Verbose
namespace :test do
task :prepare do
mkdir_p "Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes"
cp Dir.glob('Tests/Schemes/*.xcscheme'), "Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/"
end
desc "Run the AFNetworking Tests for iOS"
task :ios => :prepare do
run_tests('iOS Tests', 'iphonesimulator')
tests_failed('iOS') unless $?.success?
end
desc "Run the AFNetworking Tests for Mac OS X"
task :osx => :prepare do
run_tests('OS X Tests', 'macosx')
tests_failed('OSX') unless $?.success?
end
end
desc "Run the AFNetworking Tests for iOS & Mac OS X"
task :test do
Rake::Task['test:ios'].invoke
Rake::Task['test:osx'].invoke if is_mavericks_or_above
end
task :default => 'test'
private
def run_tests(scheme, sdk)
sh("xcodebuild -workspace AFNetworking.xcworkspace -scheme '#{scheme}' -sdk '#{sdk}' -configuration Release 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 tests_failed(platform)
puts red("#{platform} unit tests failed")
exit $?.exitstatus
end
def red(string)
"\033[0;31m! #{string}"
end