forked from appium/ruby_lib_core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
140 lines (123 loc) · 4.34 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'yard'
require 'rubocop/rake_task'
desc('setup development environment')
task :setup do |_t, _args|
system %w(bundle install)
end
namespace :test do
namespace :func do
desc('Run all iOS related tests in test directory')
Rake::TestTask.new(:ios) do |t|
tmp_build = File.expand_path('tmp/Build/Products/')
puts "#{tmp_build} is used for tests. Make sure they are not older version" if File.exist?(tmp_build)
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList[ENV['TESTS'] ? ENV['TESTS'].split(',') : 'test/functional/ios/**/*_test.rb']
end
desc('Run all Android related tests in test directory')
Rake::TestTask.new(:android) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList[ENV['TESTS'] ? ENV['TESTS'].split(',') : 'test/functional/android/**/*_test.rb']
end
end
desc('Run all unit tests in test directory')
Rake::TestTask.new(:unit) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList[ENV['TESTS'] ? ENV['TESTS'].split(',') : 'test/unit/**/*_test.rb']
end
namespace :unit do
desc('Run all iOS related unit tests in test directory')
Rake::TestTask.new(:ios) do |t|
ENV['UNIT_TEST'] = '1'
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/unit/ios/**/*_test.rb']
end
desc('Run all Android related unit tests in test directory')
Rake::TestTask.new(:android) do |t|
ENV['UNIT_TEST'] = '1'
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/unit/android/**/*_test.rb']
end
desc('Run all common related unit tests in test directory')
Rake::TestTask.new(:common) do |t|
ENV['UNIT_TEST'] = '1'
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/unit/common/**/*_test.rb']
end
desc('Run all Windows related unit tests in test directory')
Rake::TestTask.new(:windows) do |t|
ENV['UNIT_TEST'] = '1'
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/unit/windows/**/*_test.rb']
end
end
end
namespace :android do
desc('uninstall all of test apks from a test device')
task :uninstall_test_apks do |_t, _args|
`adb uninstall io.appium.uiautomator2.server.test`
`adb uninstall io.appium.uiautomator2.server`
`adb uninstall io.appium.settings`
`adb uninstall io.appium.android.ime`
`adb uninstall io.appium.espressoserver.test`
end
desc('Generate and launch android emulators')
task :gen_device do |_t, _args|
SWARMER_VERSION = '0.2.4'.freeze
CPU_ARCHITECTURE = 'x86'.freeze
IMAGE = 'google_apis'.freeze
ANDROID_API = 27
system %W(
curl
--fail
--location https://jcenter.bintray.com/com/gojuno/swarmer/swarmer/#{SWARMER_VERSION}/swarmer-#{SWARMER_VERSION}.jar
--output /tmp/swarmer.jar
).join(' ')
cmds = (1..3).reduce([]) do |acc, number|
acc << %W(
--emulator-name test#{number}
--package "system-images;android-#{ANDROID_API};#{IMAGE};#{CPU_ARCHITECTURE}"
--android-abi #{IMAGE}/#{CPU_ARCHITECTURE}
--path-to-config-ini test/functional/android/emulator_config.ini
--emulator-start-options -netdelay none -netspeed full -screen touch -prop persist.sys.language=en -prop persist.sys.country=US
).join(' ')
end
system %w(java -jar /tmp/swarmer.jar start).concat(cmds).flatten.join(' ')
end
end
desc('Generate yardoc')
YARD::Rake::YardocTask.new do |t|
t.files = %w(lib/**/*.rb)
end
desc('Execute RuboCop static code analysis')
RuboCop::RakeTask.new(:rubocop) do |t|
t.patterns = %w(lib test script)
t.options = %w(-D)
t.fail_on_error = true
end
desc('print commands which Ruby client has not implemented them yet')
namespace :commands do
require './script/commands'
desc('Mobile JSON protocol')
task :mjsonwp do |_t, _args|
c = Script::CommandsChecker.new
c.get_mjsonwp_routes
c.get_all_command_path './mjsonwp_routes.js'
c.all_diff_commands_mjsonwp.each { |key, value| puts("command: #{key}, method: #{value}") }
end
desc('W3C protocol')
task :w3c do |_t, _args|
c = Script::CommandsChecker.new
c.get_mjsonwp_routes
c.get_all_command_path './mjsonwp_routes.js'
c.all_diff_commands_w3c.each { |key, value| puts("command: #{key}, method: #{value}") }
end
end