-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
81 lines (65 loc) · 1.63 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
BUILD_DIR = "/tmp/Schedule"
APP_BUNDLE = "#{BUILD_DIR}/Schedule.app"
AUTOMATION_TEMPLATE = "automation/Template.tracetemplate"
RESULTS_PATH = "automation_results"
OUTPUT_TRACE_DOCUMENT = "#{RESULTS_PATH}/Trace"
# If the automation_results directory isn't there, Instruments balks.
mkdir_p RESULTS_PATH
desc "Remove the automation_results directory and start fresh"
task "clean_results" do
rm_rf RESULTS_PATH
end
desc "Run tests for iPhone Simulator"
task "default" do
build
FileList["automation/test_*.js"].each do |script|
automate script
end
close_sim
puts "\nWin condition acquired!"
end
desc "Run tests for connected device"
task "device" do
$is_testing_on_device = true
Rake::Task["default"].invoke
end
desc "Focused test run. Things in progress."
task "focus" do
build
automate "automation/test_session_details.js"
close_sim
puts "\nWin condition acquired!"
end
#
# Composable steps
#
def build
sh %{
xcodebuild \\
clean build \\
-project Schedule.xcodeproj \\
-configuration Release \\
-scheme ScheduleUITests \\
-sdk iphonesimulator \\
CONFIGURATION_BUILD_DIR="#{BUILD_DIR}"
}
end
def automate script
if $is_testing_on_device
device_uuid = `bin/device_uuid`.strip
device_arg = "-w #{device_uuid}"
end
sh %{
bin/unix_instruments \\
#{device_arg} \\
-t "#{AUTOMATION_TEMPLATE}" \\
-D "#{OUTPUT_TRACE_DOCUMENT}" \\
"#{APP_BUNDLE}" \\
-e UIARESULTSPATH "#{RESULTS_PATH}" \\
-e UI_TESTS 1 \\
-e UIASCRIPT "#{script}"
}
end
def close_sim
sh %{killall "iPhone Simulator" || true}
end