test_runner 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE-2.0.txt +202 -0
- data/Rakefile +151 -0
- data/lib/test_runner/helper.rb +274 -0
- data/lib/test_runner/version.rb +5 -0
- data/lib/test_runner.rb +2 -0
- data/readme.md +1 -0
- data/test_runner.gemspec +35 -0
- metadata +166 -0
data/LICENSE-2.0.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
# Defines gem name.
|
7
|
+
def repo_name; 'test_runner' end # rubygems.org name
|
8
|
+
def gh_name; 'bootstraponline/test_runner' end # the name as used on github.com
|
9
|
+
def version_file; "lib/#{repo_name}/version.rb" end
|
10
|
+
def version_rgx; /VERSION = '([^']+)'/m end
|
11
|
+
|
12
|
+
def version
|
13
|
+
@version = @version || File.read(version_file).match(version_rgx)[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def bump
|
17
|
+
data = File.read version_file
|
18
|
+
|
19
|
+
v_line = data.match version_rgx
|
20
|
+
d_line = data.match /DATE = '([^']+)'/m
|
21
|
+
|
22
|
+
old_v = v_line[0]
|
23
|
+
old_d = d_line[0]
|
24
|
+
|
25
|
+
old_num = v_line[1]
|
26
|
+
new_num = old_num.split('.')
|
27
|
+
new_num[-1] = new_num[-1].to_i + 1
|
28
|
+
new_num = new_num.join '.'
|
29
|
+
|
30
|
+
new_v = old_v.sub old_num, new_num
|
31
|
+
puts "#{old_num} -> #{new_num}"
|
32
|
+
|
33
|
+
old_date = d_line[1]
|
34
|
+
new_date = Date.today.to_s
|
35
|
+
new_d = old_d.sub old_date, new_date
|
36
|
+
puts "#{old_date} -> #{new_date}" unless old_date == new_date
|
37
|
+
|
38
|
+
data.sub! old_v, new_v
|
39
|
+
data.sub! old_d, new_d
|
40
|
+
|
41
|
+
File.write version_file, data
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Bump the version number and update the date.'
|
45
|
+
task :bump do
|
46
|
+
bump
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Install gems required for release task'
|
50
|
+
task :dev do
|
51
|
+
sh 'gem install --no-rdoc --no-ri yard'
|
52
|
+
sh 'gem install --no-rdoc --no-ri redcarpet'
|
53
|
+
end
|
54
|
+
|
55
|
+
# Inspired by Gollum's Rakefile
|
56
|
+
desc 'Build and release a new gem to rubygems.org'
|
57
|
+
task :release => :gem do
|
58
|
+
unless `git branch`.include? '* master'
|
59
|
+
puts 'Master branch required to release.'
|
60
|
+
exit!
|
61
|
+
end
|
62
|
+
|
63
|
+
# Commit then pull before pushing.
|
64
|
+
sh "git commit --allow-empty -am 'Release #{version}'"
|
65
|
+
sh 'git pull'
|
66
|
+
sh "git tag v#{version}"
|
67
|
+
# update notes now that there's a new tag
|
68
|
+
Rake::Task['notes'].execute
|
69
|
+
sh "git commit --allow-empty -am 'Update release notes'"
|
70
|
+
sh 'git push origin master'
|
71
|
+
sh "git push origin v#{version}"
|
72
|
+
sh "gem push #{repo_name}-#{version}.gem"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'Build and release a new gem to rubygems.org (same as release)'
|
76
|
+
task :publish => :release do
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'Build a new gem'
|
80
|
+
task :gem do
|
81
|
+
`chmod 0600 ~/.gem/credentials`
|
82
|
+
sh "gem build #{repo_name}.gemspec"
|
83
|
+
end
|
84
|
+
|
85
|
+
desc 'Build a new gem (same as gem task)'
|
86
|
+
task :build => :gem do
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'Uninstall gem'
|
90
|
+
task :uninstall do
|
91
|
+
cmd = "gem uninstall -aIx #{repo_name}"
|
92
|
+
puts cmd
|
93
|
+
# rescue on gem not installed error.
|
94
|
+
begin; `cmd`; rescue; end
|
95
|
+
end
|
96
|
+
|
97
|
+
desc 'Install gem'
|
98
|
+
task :install => [ :gem, :uninstall ] do
|
99
|
+
sh "gem install --no-rdoc --no-ri --local #{repo_name}-#{version}.gem"
|
100
|
+
end
|
101
|
+
|
102
|
+
desc 'Update release notes'
|
103
|
+
task :notes do
|
104
|
+
tag_sort = ->(tag1,tag2) do
|
105
|
+
tag1_numbers = tag1.match(/\.?v(\d+\.\d+\.\d+)$/)[1].split('.').map! { |n| n.to_i }
|
106
|
+
tag2_numbers = tag2.match(/\.?v(\d+\.\d+\.\d+)$/)[1].split('.').map! { |n| n.to_i }
|
107
|
+
tag1_numbers <=> tag2_numbers
|
108
|
+
end
|
109
|
+
|
110
|
+
tags = `git tag`.split "\n"
|
111
|
+
tags.sort! &tag_sort
|
112
|
+
pairs = []
|
113
|
+
tags.each_index { |a| pairs.push tags[a] + '...' + tags[a+1] unless tags[a+1].nil? }
|
114
|
+
|
115
|
+
notes = ''
|
116
|
+
|
117
|
+
dates = `git log --tags --simplify-by-decoration --pretty="format:%d %ad" --date=short`.split "\n"
|
118
|
+
|
119
|
+
pairs.sort! &tag_sort
|
120
|
+
pairs.reverse! # pairs are in reverse order.
|
121
|
+
|
122
|
+
tag_date = []
|
123
|
+
pairs.each do |pair|
|
124
|
+
tag = pair.split('...').last
|
125
|
+
dates.each do |line|
|
126
|
+
# regular tag, or tag on master.
|
127
|
+
if line.include?('(' + tag + ')') || line.include?(tag + ',')
|
128
|
+
tag_date.push tag + ' ' + line.match(/\d{4}-\d{2}-\d{2}/)[0]
|
129
|
+
break
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
pairs.each_index do |a|
|
135
|
+
data =`git log --pretty=oneline #{pairs[a]}`
|
136
|
+
new_data = ''
|
137
|
+
data.split("\n").each do |line|
|
138
|
+
hex = line.match(/[a-zA-Z0-9]+/)[0]
|
139
|
+
# use first 7 chars to match GitHub
|
140
|
+
comment = line.gsub(hex, '').strip
|
141
|
+
next if comment == 'Update release notes'
|
142
|
+
new_data += "- [#{hex[0...7]}](https://github.com/#{gh_name}/commit/#{hex}) #{comment}\n"
|
143
|
+
end
|
144
|
+
data = new_data + "\n"
|
145
|
+
|
146
|
+
# last pair is the released version.
|
147
|
+
notes += "#### #{tag_date[a]}\n\n" + data + "\n"
|
148
|
+
end
|
149
|
+
|
150
|
+
File.open('release_notes.md', 'w') { |f| f.write notes.to_s.strip }
|
151
|
+
end
|
@@ -0,0 +1,274 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'appium_lib'
|
4
|
+
require 'chronic_duration'
|
5
|
+
require 'minitest/autorun' # requires minitest-4.7.4
|
6
|
+
require 'minitest/reporters' # Format the report
|
7
|
+
|
8
|
+
# for Sauce Labs reporting
|
9
|
+
require 'rest_client' # https://github.com/archiloque/rest-client
|
10
|
+
require 'json' # for .to_json
|
11
|
+
|
12
|
+
# https://github.com/banister/method_source
|
13
|
+
# gem install method_source
|
14
|
+
require 'method_source' # for .source
|
15
|
+
|
16
|
+
$passed = true
|
17
|
+
|
18
|
+
# Report passed status to Sauce and quit the driver.
|
19
|
+
def update_sauce opts
|
20
|
+
# must use selenium-webdriver (2.32.1) or better for .session_id
|
21
|
+
id = session_id
|
22
|
+
driver_quit
|
23
|
+
|
24
|
+
if !sauce_username.nil? && !sauce_access_key.nil?
|
25
|
+
url = "https://#{sauce_username}:#{sauce_access_key}@saucelabs.com/rest/v1/#{sauce_username}/jobs/#{id}"
|
26
|
+
puts "Posting passed result #{$passed} to Sauce"
|
27
|
+
json = { 'passed' => opts[:passed] }.to_json
|
28
|
+
# Keep trying until passed is set correctly. Give up after 30 seconds.
|
29
|
+
wait do
|
30
|
+
response = RestClient.put url, json, :content_type => :json, :accept => :json
|
31
|
+
response = JSON.parse(response)
|
32
|
+
puts "Response #{response}"
|
33
|
+
|
34
|
+
# Check that the server responded with the right value.
|
35
|
+
response['passed'] == $passed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Run tests in order
|
41
|
+
class MiniTest::Unit::TestCase
|
42
|
+
def self.test_order; :alpha end
|
43
|
+
end
|
44
|
+
|
45
|
+
class MiniTest::Reporters::ProgressReporter::Progress
|
46
|
+
def show *args; end
|
47
|
+
def close; end
|
48
|
+
def wipe; end
|
49
|
+
def scope; end
|
50
|
+
end
|
51
|
+
|
52
|
+
class MiniTest::Reporters::ProgressReporter
|
53
|
+
# no power bar
|
54
|
+
def initialize(options = {})
|
55
|
+
@detailed_skip = options.fetch(:detailed_skip, true)
|
56
|
+
@progress = Progress.new
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# rename test, change end message.
|
61
|
+
# https://github.com/CapnKernul/minitest-reporters/blob/master/lib/minitest/reporters/progress_reporter.rb
|
62
|
+
class MiniTest::Reporters::ProgressReporter
|
63
|
+
def failure(suite, test, test_runner)
|
64
|
+
wipe
|
65
|
+
print(red { 'FAIL' })
|
66
|
+
print_test_with_time(suite, test)
|
67
|
+
puts
|
68
|
+
print_info(test_runner.exception, false)
|
69
|
+
puts
|
70
|
+
$passed = false # set global passed
|
71
|
+
exit 1 # exit at first fail
|
72
|
+
end
|
73
|
+
def error(suite, test, test_runner)
|
74
|
+
test = test.to_s.sub(/test_\d+_/, '').to_sym
|
75
|
+
wipe
|
76
|
+
print(red { 'ERROR' })
|
77
|
+
print_test_with_time(suite, test)
|
78
|
+
puts
|
79
|
+
print_info(test_runner.exception)
|
80
|
+
$passed = false # set global passed
|
81
|
+
exit 1 # exit at first fail
|
82
|
+
end
|
83
|
+
def after_suites(suites, type)
|
84
|
+
@progress.close if @progress
|
85
|
+
|
86
|
+
total_time = Time.now - runner.suites_start_time
|
87
|
+
# puts "Total time: #{total_time}"
|
88
|
+
wipe if @progress
|
89
|
+
puts
|
90
|
+
puts "Finished in #{ChronicDuration.output(total_time.round) || '0s'}"
|
91
|
+
tests = runner.test_count
|
92
|
+
asserts = runner.assertion_count
|
93
|
+
fails = runner.failures
|
94
|
+
errors = runner.errors
|
95
|
+
skips = runner.skips
|
96
|
+
# Store pass/fail result and send to Sauce Labs
|
97
|
+
$passed = false if fails > 0 || errors > 0
|
98
|
+
out = ''
|
99
|
+
out += ("%d test#{tests == 1 ? '' : 's'}#{(asserts == fails && fails == errors && errors == skips && skips == 0) ? '' : ', '}" % [tests])
|
100
|
+
out += ('%d assertions, ' % [runner.assertion_count]) unless asserts == 0
|
101
|
+
out += (red { '%d failures, ' } % [runner.failures]) unless fails == 0
|
102
|
+
out += (red { "%d error#{runner.errors == 1 ? '' : 's'}#{skips ? '' : ', '}" } % [errors]) unless errors == 0
|
103
|
+
out += (yellow { '%d skips' } % runner.skips) unless skips == 0
|
104
|
+
out = out.strip.gsub(/,\w*$/, '')
|
105
|
+
puts out
|
106
|
+
puts
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
MiniTest::Reporters.use! MiniTest::Reporters::ProgressReporter.new
|
111
|
+
|
112
|
+
# Alter '# Run options:' from minitest-reports
|
113
|
+
# https://github.com/CapnKernul/minitest-reporters/blob/master/lib/minitest/reporter_runner.rb#L28
|
114
|
+
class MiniTest::ReporterRunner < MiniTest::Unit
|
115
|
+
def _run_suites(suites, type)
|
116
|
+
# test_order = @help.match /\-\-seed (\d+)/
|
117
|
+
# '# Run options: --seed 10181' => 'test order: 10181'
|
118
|
+
# $stdout.puts "test order: #{test_order[1]}" if test_order
|
119
|
+
@suites_start_time = Time.now
|
120
|
+
count_tests!(suites, type)
|
121
|
+
trigger_callback(:before_suites, suites, type)
|
122
|
+
super(suites, type)
|
123
|
+
ensure
|
124
|
+
trigger_callback(:after_suites, suites, type)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Silence run options
|
128
|
+
def _run args = []
|
129
|
+
args = process_args args
|
130
|
+
self.options.merge! args
|
131
|
+
|
132
|
+
self.class.plugins.each do |plugin|
|
133
|
+
send plugin
|
134
|
+
break unless report.empty?
|
135
|
+
end
|
136
|
+
|
137
|
+
return failures + errors if self.test_count > 0 # or return nil...
|
138
|
+
rescue Interrupt
|
139
|
+
abort 'Interrupted'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# prevent undefined method
|
144
|
+
class MiniTest::Spec
|
145
|
+
def after_last_method; end
|
146
|
+
def before_first_method; end
|
147
|
+
end
|
148
|
+
|
149
|
+
class MiniTest::Spec < MiniTest::Unit::TestCase
|
150
|
+
module DSL
|
151
|
+
# DSL accepts a block which defines a method.
|
152
|
+
# The method is called later.
|
153
|
+
# after_last DSL defines the after_last_method
|
154
|
+
# which is invoked on a test case.
|
155
|
+
def after_last &block
|
156
|
+
define_method 'after_last_method' do
|
157
|
+
self.instance_eval &block
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def before_first &block
|
162
|
+
define_method 'before_first_method' do
|
163
|
+
self.instance_eval &block
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class MiniTest::Unit
|
170
|
+
def _run_suites suites, type
|
171
|
+
suites.map do |suite|
|
172
|
+
puts
|
173
|
+
puts "Running #{suite}"
|
174
|
+
puts
|
175
|
+
suite.test_methods.each do |test_name|
|
176
|
+
test_method = suite.instance_method(test_name)
|
177
|
+
if test_method.respond_to? :source
|
178
|
+
src = test_method.source
|
179
|
+
else
|
180
|
+
next
|
181
|
+
end
|
182
|
+
|
183
|
+
next unless src.kind_of? String
|
184
|
+
|
185
|
+
ary = src.split "\n"
|
186
|
+
# this may break code that spans more than one line
|
187
|
+
carry_over = ''
|
188
|
+
carry_over_puts = ''
|
189
|
+
center = ary[1..-2].map do |line|
|
190
|
+
printed_line = line.strip
|
191
|
+
# transform \n into \\n so it's printed properly by puts
|
192
|
+
printed_line = printed_line.gsub /\\/, '\\' * 4
|
193
|
+
result = "puts %(#{printed_line})\n#{line}"
|
194
|
+
|
195
|
+
begin
|
196
|
+
# chop off anything after '#'
|
197
|
+
# puts "Line: #{line}" if !carry_over.empty?
|
198
|
+
# check syntax will be nil if the line is just a comment
|
199
|
+
check_syntax = line.split('#').first
|
200
|
+
eval 'lambda {' + check_syntax + '}' if check_syntax
|
201
|
+
# syntax is ok. prepend carry over
|
202
|
+
result = carry_over_puts + carry_over + "\n" + result
|
203
|
+
carry_over = ''
|
204
|
+
carry_over_puts = ''
|
205
|
+
rescue SyntaxError
|
206
|
+
# invalid syntax, carry over next line
|
207
|
+
# puts "-- Adding to carry over before: #{carry_over}"
|
208
|
+
carry_over += "\n" + line
|
209
|
+
carry_over_puts += "\n" + "puts %(#{printed_line})"
|
210
|
+
# puts "-- Adding to carry over after: #{carry_over}"
|
211
|
+
result = ''
|
212
|
+
end
|
213
|
+
# puts "Result is: #{result}" if result.include? 'password'
|
214
|
+
result#.gsub!('puts %()', '') # remove empty puts
|
215
|
+
end
|
216
|
+
# must use define method for test names with spaces.
|
217
|
+
rewrite = ["define_method(%Q(#{test_name})) do\n", center.join("\n"), ary.last].join "\n"
|
218
|
+
# $stdout.puts ' --- rewriting'
|
219
|
+
# $stdout.puts rewrite
|
220
|
+
# $stdout.puts ' --- rewrite complete'
|
221
|
+
# undefine the existing test name
|
222
|
+
# public_instance_methods
|
223
|
+
#$stdout.puts 'suite.class_eval { undef ' + test_name + ' }'
|
224
|
+
# undef old test before defining new test
|
225
|
+
# $stdout.puts "undef: #{test_name}"
|
226
|
+
eval 'suite.class_eval { undef :"' + test_name + '" }'
|
227
|
+
# adjust spec count
|
228
|
+
suite.instance_variable_set(:@specs, suite.instance_variable_get(:@specs) - 1)
|
229
|
+
# define new method
|
230
|
+
# $stdout.puts "def: #{rewrite.split("\n").first}"
|
231
|
+
suite.instance_eval( rewrite )
|
232
|
+
end
|
233
|
+
method_instance = suite.new(suite.test_methods.first)
|
234
|
+
method_instance.before_first_method
|
235
|
+
result = _run_suite suite, type
|
236
|
+
# suite isn't an instance that contains 'after_last_method'
|
237
|
+
# create test instance and invoke after_last_method
|
238
|
+
method_instance.after_last_method
|
239
|
+
result
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
# alias t to it
|
245
|
+
class MiniTest::Spec < MiniTest::Unit::TestCase
|
246
|
+
module DSL
|
247
|
+
alias_method :t, :it
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
module MiniTest::Reporter
|
252
|
+
def verbose?; true end
|
253
|
+
end
|
254
|
+
|
255
|
+
module MiniTest::Reporter
|
256
|
+
def before_test(suite, test)
|
257
|
+
puts
|
258
|
+
# 'test_0002_::Appium::DATE' => ::Appium::DATE | version.rb | 2
|
259
|
+
test_number = test.match(/test_(\d+)_/)[1].to_i
|
260
|
+
test_str = test.split(/_\d+_/).last
|
261
|
+
puts ANSI.cyan { "#{test_str} | #{suite.to_s.gsub('::', ' ')} | #{test_number}" }
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
=begin
|
266
|
+
#
|
267
|
+
# Add after to each test case
|
268
|
+
#
|
269
|
+
class MiniTest::Unit::TestCase
|
270
|
+
def before_teardown
|
271
|
+
mobile :reset
|
272
|
+
end
|
273
|
+
end
|
274
|
+
=end
|
data/lib/test_runner.rb
ADDED
data/readme.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
A test runner for use with the appium_lib gem and minitest.
|
data/test_runner.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
def self.add_to_path path
|
3
|
+
path = File.expand_path "../#{path}/", __FILE__
|
4
|
+
|
5
|
+
$:.unshift path unless $:.include? path
|
6
|
+
end
|
7
|
+
|
8
|
+
add_to_path 'lib'
|
9
|
+
|
10
|
+
require 'test_runner/version'
|
11
|
+
|
12
|
+
Gem::Specification.new do |s|
|
13
|
+
# 1.8.x is not supported
|
14
|
+
s.required_ruby_version = '>= 1.9.3'
|
15
|
+
|
16
|
+
s.name = 'test_runner'
|
17
|
+
s.version = TestRunner::VERSION
|
18
|
+
s.date = TestRunner::DATE
|
19
|
+
s.license = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
20
|
+
s.description = s.summary = 'TestRunner'
|
21
|
+
s.description += '.' # avoid identical warning
|
22
|
+
s.authors = s.email = [ 'code@bootstraponline.com' ]
|
23
|
+
s.homepage = 'https://github.com/bootstraponline/TestRunner' # published as appium_console
|
24
|
+
s.require_paths = [ 'lib' ]
|
25
|
+
|
26
|
+
s.add_runtime_dependency 'minitest', '= 4.7.4'
|
27
|
+
s.add_runtime_dependency 'minitest-reporters', '= 0.14.18'
|
28
|
+
s.add_runtime_dependency 'chronic_duration', '~> 0.10.2'
|
29
|
+
s.add_runtime_dependency 'appium_lib', '= 0.5.10'
|
30
|
+
s.add_runtime_dependency 'rest-client', '~> 1.6.7'
|
31
|
+
s.add_runtime_dependency 'method_source', '~> 0.8.1'
|
32
|
+
s.add_runtime_dependency 'rake', '~> 10.0.4'
|
33
|
+
|
34
|
+
s.files = `git ls-files`.split "\n"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test_runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- code@bootstraponline.com
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitest
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 4.7.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.7.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: minitest-reporters
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.14.18
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.14.18
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: chronic_duration
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.10.2
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.2
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: appium_lib
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.5.10
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.5.10
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rest-client
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.6.7
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.6.7
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: method_source
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.8.1
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.8.1
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 10.0.4
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 10.0.4
|
126
|
+
description: TestRunner.
|
127
|
+
email:
|
128
|
+
- code@bootstraponline.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- LICENSE-2.0.txt
|
134
|
+
- Rakefile
|
135
|
+
- lib/test_runner.rb
|
136
|
+
- lib/test_runner/helper.rb
|
137
|
+
- lib/test_runner/version.rb
|
138
|
+
- readme.md
|
139
|
+
- test_runner.gemspec
|
140
|
+
homepage: https://github.com/bootstraponline/TestRunner
|
141
|
+
licenses:
|
142
|
+
- http://www.apache.org/licenses/LICENSE-2.0.txt
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.9.3
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 1.8.25
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: TestRunner
|
165
|
+
test_files: []
|
166
|
+
has_rdoc:
|