forked from alexrothenberg/motion-addressbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
63 lines (53 loc) · 1.71 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
require "bundler/gem_tasks"
$:.unshift("/Library/RubyMotion/lib")
if ENV['osx']
require 'motion/project/template/osx'
else
require 'motion/project/template/ios'
end
Bundler.setup
Bundler.require
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'AddressBook'
app.info_plist['NSContactsUsageDescription'] = 'AddressBook will be used for test'
if ENV['osx']
app.specs_dir = "./spec/osx"
app.info_plist['LSUIElement'] = true
else
app.specs_dir = "./spec/ios"
end
end
# The test suite may interfere with contacts already created in the
# simulator. In order to avoid disrupting anything the existing
# simulator environment, run the test suite in its own blank simulator
# and clean up afterwards.
namespace :spec do
task :isolate do
system "launchctl list | grep simulator | cut -f3 | xargs -L 1 launchctl remove"
@_protected = []
Dir.glob("#{ENV['HOME']}/Library/Application Support/iPhone Simulator/[0-9]*").each do |dir|
if Dir.exists?("#{dir}.backup")
warn "*" * 70
warn "PREVIOUS TEST RUN FAILED. RESTORING SIMULATOR BACKUP AND ABORTING."
warn "*" * 70
system "rm -rf \"#{dir}\""
File.rename("#{dir}.backup", dir)
exit 1
else
warn "PROTECTING EXISTING SIMULATOR IN #{dir}"
File.rename(dir, "#{dir}.backup")
@_protected << dir
end
end
at_exit do
system "launchctl list | grep simulator | cut -f3 | head -1 | xargs launchctl remove"
@_protected.each do |dir|
warn "RESTORING SIMULATOR IN #{dir}"
system "rm -rf \"#{dir}\""
File.rename("#{dir}.backup", dir)
end
end
end
task :simulator => :isolate
end