rake_tasks 2.0.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/Gemfile +5 -3
- data/lib/base/util.rb +39 -0
- data/lib/rake_tasks.rb +12 -25
- data/lib/rake_tasks/doc.rb +69 -21
- data/lib/rake_tasks/gem.rb +71 -37
- data/lib/rake_tasks/{lib/parser.rb → parser.rb} +17 -18
- data/lib/rake_tasks/tasks/cane.rb +27 -0
- data/lib/rake_tasks/tasks/checksum.rb +19 -0
- data/lib/rake_tasks/tasks/doc.rb +59 -0
- data/lib/rake_tasks/{lib/doc.rb → tasks/gem.rb} +77 -110
- data/lib/rake_tasks/{rdoc.rb → tasks/rdoc.rb} +9 -4
- data/lib/rake_tasks/{test.rb → tasks/test.rb} +7 -3
- data/lib/rake_tasks/{lib/tests.rb → tests.rb} +314 -246
- data/license/gplv3.md +0 -0
- data/license/lgplv3.md +0 -0
- data/license/lgplv3.png +0 -0
- data/rake_tasks.gemspec +10 -4
- data/rakefile +29 -1
- data/readme.markdown +131 -0
- data/test/integration/doc_integration_test.rb +81 -77
- data/test/integration/gem_integration_test.rb +2 -11
- data/test/integration/tests_integration_test.rb +22 -7
- data/test/require.rb +1 -2
- data/test/support/rake_tasks_shared.rb +0 -0
- data/test/support/tunit_test_case.rb +0 -0
- data/test/unit/doc_unit_test.rb +119 -119
- data/test/unit/gem_test.rb +5 -79
- data/test/unit/parser_test.rb +15 -10
- data/todo.md +4 -0
- metadata +99 -57
- metadata.gz.sig +0 -0
- data/README.md +0 -106
- data/lib/rake_tasks/lib/bundle_install.sh +0 -17
- data/lib/rake_tasks/lib/gem.rb +0 -95
- data/lib/rake_tasks/lib/rubies.sh +0 -18
- data/test/unit/tests_unit_test.rb +0 -284
@@ -0,0 +1,59 @@
|
|
1
|
+
#--
|
2
|
+
################################################################################
|
3
|
+
# Copyright (C) 2011 Travis Herrick #
|
4
|
+
################################################################################
|
5
|
+
# #
|
6
|
+
# \v^V,^!v\^/ #
|
7
|
+
# ~% %~ #
|
8
|
+
# { _ _ } #
|
9
|
+
# ( * - ) #
|
10
|
+
# | / | #
|
11
|
+
# \ _, / #
|
12
|
+
# \__.__/ #
|
13
|
+
# #
|
14
|
+
################################################################################
|
15
|
+
# This program is free software: you can redistribute it #
|
16
|
+
# and/or modify it under the terms of the GNU Lesser General Public License #
|
17
|
+
# as published by the Free Software Foundation, #
|
18
|
+
# either version 3 of the License, or (at your option) any later version. #
|
19
|
+
################################################################################
|
20
|
+
# This program is distributed in the hope that it will be useful, #
|
21
|
+
# but WITHOUT ANY WARRANTY; #
|
22
|
+
# without even the implied warranty of MERCHANTABILITY #
|
23
|
+
# or FITNESS FOR A PARTICULAR PURPOSE. #
|
24
|
+
# See the GNU Lesser General Public License for more details. #
|
25
|
+
# #
|
26
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
27
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
28
|
+
################################################################################
|
29
|
+
#++
|
30
|
+
|
31
|
+
if RakeTasks::Gem.gemspec_file?
|
32
|
+
############################################################################
|
33
|
+
namespace :doc do
|
34
|
+
############################################################################
|
35
|
+
|
36
|
+
gem_spec_file = RakeTasks::Gem.gem_spec_file
|
37
|
+
|
38
|
+
readme = 'readme.md'
|
39
|
+
readme = 'readme_generated.md' if File.file?(readme)
|
40
|
+
|
41
|
+
file readme => gem_spec_file do |t|
|
42
|
+
doc_obj = RakeTasks::Doc.new
|
43
|
+
Util.write_file readme, doc_obj.readme_contents
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Generate a #{readme} file."
|
47
|
+
task :readme => readme
|
48
|
+
|
49
|
+
desc "Removes files associated with generating documentation."
|
50
|
+
task :clobber do |t|
|
51
|
+
rm_f readme
|
52
|
+
end
|
53
|
+
|
54
|
+
############################################################################
|
55
|
+
end # :doc
|
56
|
+
############################################################################
|
57
|
+
|
58
|
+
task :clobber => 'doc:clobber'
|
59
|
+
end
|
@@ -1,110 +1,77 @@
|
|
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
|
-
#{gem_spec.
|
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
|
-
$ rake rdoc:app
|
80
|
-
#{license_details}}.strip
|
81
|
-
|
82
|
-
return @contents
|
83
|
-
end
|
84
|
-
|
85
|
-
########################################################################
|
86
|
-
private
|
87
|
-
########################################################################
|
88
|
-
|
89
|
-
# Returns formatted headers.
|
90
|
-
def header(type, text = nil)
|
91
|
-
case type
|
92
|
-
when :h1
|
93
|
-
"#{text}\n#{'=' * text.length}"
|
94
|
-
when :h2
|
95
|
-
"#{text}\n#{'-' * text.length}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Compose the license details.
|
100
|
-
def license_details
|
101
|
-
return if @gem_spec.licenses.empty?
|
102
|
-
|
103
|
-
%Q{
|
104
|
-
#{header :h2, 'License'}
|
105
|
-
|
106
|
-
#{@gem_title} is released under the #{@gem_spec.licenses.first} license.
|
107
|
-
}
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
1
|
+
#--
|
2
|
+
################################################################################
|
3
|
+
# Copyright (C) 2011 Travis Herrick #
|
4
|
+
################################################################################
|
5
|
+
# #
|
6
|
+
# \v^V,^!v\^/ #
|
7
|
+
# ~% %~ #
|
8
|
+
# { _ _ } #
|
9
|
+
# ( * - ) #
|
10
|
+
# | / | #
|
11
|
+
# \ _, / #
|
12
|
+
# \__.__/ #
|
13
|
+
# #
|
14
|
+
################################################################################
|
15
|
+
# This program is free software: you can redistribute it #
|
16
|
+
# and/or modify it under the terms of the GNU Lesser General Public License #
|
17
|
+
# as published by the Free Software Foundation, #
|
18
|
+
# either version 3 of the License, or (at your option) any later version. #
|
19
|
+
################################################################################
|
20
|
+
# This program is distributed in the hope that it will be useful, #
|
21
|
+
# but WITHOUT ANY WARRANTY; #
|
22
|
+
# without even the implied warranty of MERCHANTABILITY #
|
23
|
+
# or FITNESS FOR A PARTICULAR PURPOSE. #
|
24
|
+
# See the GNU Lesser General Public License for more details. #
|
25
|
+
# #
|
26
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
27
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
28
|
+
################################################################################
|
29
|
+
#++
|
30
|
+
|
31
|
+
if RakeTasks::Gem.gemspec_file?
|
32
|
+
############################################################################
|
33
|
+
namespace :gem do
|
34
|
+
############################################################################
|
35
|
+
|
36
|
+
gem_spec = RakeTasks::Gem.gem_spec
|
37
|
+
gem_spec_file = RakeTasks::Gem.gem_spec_file
|
38
|
+
|
39
|
+
file gem_spec.file_name =>
|
40
|
+
[gem_spec_file, *Dir['lib/**/*.rb'], 'Gemfile', 'Gemfile.lock'] do |t|
|
41
|
+
puts `gem build #{gem_spec_file}`
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Build #{gem_spec.name} gem version #{gem_spec.version}."
|
45
|
+
task :build => gem_spec.file_name
|
46
|
+
|
47
|
+
desc "Install the #{gem_spec.name} gem."
|
48
|
+
task :install => [gem_spec.file_name] do |t|
|
49
|
+
puts `gem install #{gem_spec.file_name} --no-rdoc --no-ri`
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Removes files associated with building " +
|
53
|
+
"and installing #{gem_spec.name}."
|
54
|
+
task :clobber do |t|
|
55
|
+
rm_f gem_spec.file_name
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Removes the gem file, builds, and installs."
|
59
|
+
task :generate => ['gem:clobber', gem_spec.file_name, 'gem:install']
|
60
|
+
|
61
|
+
desc "Show/Set the version number."
|
62
|
+
task :version, [:number] do |t, args|
|
63
|
+
if args[:number].nil?
|
64
|
+
puts RakeTasks::Gem.version(gem_spec)
|
65
|
+
else
|
66
|
+
RakeTasks::Gem.version! args[:number], gem_spec
|
67
|
+
gem_spec = RakeTasks::Gem.gem_spec
|
68
|
+
puts RakeTasks::Gem.version(gem_spec)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
############################################################################
|
73
|
+
end # :gem
|
74
|
+
############################################################################
|
75
|
+
|
76
|
+
task :clobber => 'gem:clobber'
|
77
|
+
end
|
@@ -28,6 +28,8 @@
|
|
28
28
|
################################################################################
|
29
29
|
#++
|
30
30
|
|
31
|
+
require 'rdoc/task'
|
32
|
+
|
31
33
|
################################################################################
|
32
34
|
namespace :rdoc do
|
33
35
|
################################################################################
|
@@ -55,8 +57,8 @@ namespace :rdoc do
|
|
55
57
|
rdtask.title = ''
|
56
58
|
rdtask.rdoc_dir = File.join(base_path, rdoc_task.to_s)
|
57
59
|
rdtask.options << '--charset' << 'utf8'
|
58
|
-
rdtask.rdoc_files.include '
|
59
|
-
rdtask.main = '
|
60
|
+
rdtask.rdoc_files.include 'readme.md', rdoc_files[rdoc_task]
|
61
|
+
rdtask.main = 'readme.md'
|
60
62
|
end
|
61
63
|
|
62
64
|
Rake::Task[rdoc_task].comment =
|
@@ -64,9 +66,12 @@ namespace :rdoc do
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
|
69
|
+
desc 'Remove all generated rdoc files'
|
70
|
+
task :clobber do |t|
|
71
|
+
rm_f 'rdoc'
|
72
|
+
end
|
68
73
|
################################################################################
|
69
74
|
end # :rdoc
|
70
75
|
################################################################################
|
71
76
|
|
72
|
-
task :
|
77
|
+
task :clobber => 'rdoc:clobber'
|
@@ -28,6 +28,8 @@
|
|
28
28
|
################################################################################
|
29
29
|
#++
|
30
30
|
|
31
|
+
require 'rake/testtask'
|
32
|
+
|
31
33
|
if RakeTasks::Tests.exist?
|
32
34
|
############################################################################
|
33
35
|
namespace :test do
|
@@ -68,11 +70,13 @@ if RakeTasks::Tests.exist?
|
|
68
70
|
task :full do |t|
|
69
71
|
RakeTasks::Tests::run_ruby_tests
|
70
72
|
end
|
73
|
+
|
74
|
+
desc 'Generates a shell script that will run specs against all rubies'
|
75
|
+
task :script do |t|
|
76
|
+
RakeTasks::Tests::rubies_shell_script
|
77
|
+
end
|
71
78
|
end
|
72
79
|
############################################################################
|
73
80
|
end # :test
|
74
81
|
############################################################################
|
75
|
-
|
76
|
-
Rake::Task[:default].prerequisites.clear
|
77
|
-
task :default => 'test:all'
|
78
82
|
end
|
@@ -1,246 +1,314 @@
|
|
1
|
-
# This file contains the class that assists in setting up test tasks.
|
2
|
-
|
3
|
-
#--
|
4
|
-
################################################################################
|
5
|
-
# Copyright (C) 2011 Travis Herrick #
|
6
|
-
################################################################################
|
7
|
-
# #
|
8
|
-
# \v^V,^!v\^/ #
|
9
|
-
# ~% %~ #
|
10
|
-
# { _ _ } #
|
11
|
-
# ( * - ) #
|
12
|
-
# | / | #
|
13
|
-
# \ _, / #
|
14
|
-
# \__.__/ #
|
15
|
-
# #
|
16
|
-
################################################################################
|
17
|
-
# This program is free software: you can redistribute it #
|
18
|
-
# and/or modify it under the terms of the GNU Lesser General Public License #
|
19
|
-
# as published by the Free Software Foundation, #
|
20
|
-
# either version 3 of the License, or (at your option) any later version. #
|
21
|
-
################################################################################
|
22
|
-
# This program is distributed in the hope that it will be useful, #
|
23
|
-
# but WITHOUT ANY WARRANTY; #
|
24
|
-
# without even the implied warranty of MERCHANTABILITY #
|
25
|
-
# or FITNESS FOR A PARTICULAR PURPOSE. #
|
26
|
-
# See the GNU Lesser General Public License for more details. #
|
27
|
-
# #
|
28
|
-
# You should have received a copy of the GNU Lesser General Public License #
|
29
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
30
|
-
################################################################################
|
31
|
-
#++
|
32
|
-
|
33
|
-
# The main module for this gem.
|
34
|
-
module RakeTasks
|
35
|
-
# This class assists in setting up test tasks.
|
36
|
-
class Tests
|
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
|
-
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
puts '*' * 80
|
148
|
-
parser.summarize
|
149
|
-
end
|
150
|
-
|
151
|
-
#
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
config.
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
1
|
+
# This file contains the class that assists in setting up test tasks.
|
2
|
+
|
3
|
+
#--
|
4
|
+
################################################################################
|
5
|
+
# Copyright (C) 2011 Travis Herrick #
|
6
|
+
################################################################################
|
7
|
+
# #
|
8
|
+
# \v^V,^!v\^/ #
|
9
|
+
# ~% %~ #
|
10
|
+
# { _ _ } #
|
11
|
+
# ( * - ) #
|
12
|
+
# | / | #
|
13
|
+
# \ _, / #
|
14
|
+
# \__.__/ #
|
15
|
+
# #
|
16
|
+
################################################################################
|
17
|
+
# This program is free software: you can redistribute it #
|
18
|
+
# and/or modify it under the terms of the GNU Lesser General Public License #
|
19
|
+
# as published by the Free Software Foundation, #
|
20
|
+
# either version 3 of the License, or (at your option) any later version. #
|
21
|
+
################################################################################
|
22
|
+
# This program is distributed in the hope that it will be useful, #
|
23
|
+
# but WITHOUT ANY WARRANTY; #
|
24
|
+
# without even the implied warranty of MERCHANTABILITY #
|
25
|
+
# or FITNESS FOR A PARTICULAR PURPOSE. #
|
26
|
+
# See the GNU Lesser General Public License for more details. #
|
27
|
+
# #
|
28
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
29
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
30
|
+
################################################################################
|
31
|
+
#++
|
32
|
+
|
33
|
+
# The main module for this gem.
|
34
|
+
module RakeTasks
|
35
|
+
# This class assists in setting up test tasks.
|
36
|
+
class Tests
|
37
|
+
# Returns an array of potential root folder names.
|
38
|
+
ROOTS = [
|
39
|
+
'test',
|
40
|
+
'tests',
|
41
|
+
'spec',
|
42
|
+
]
|
43
|
+
|
44
|
+
# The patterns that indicate that a file contains tests.
|
45
|
+
PATTERNS = [
|
46
|
+
'*_test.rb',
|
47
|
+
'test_*.rb',
|
48
|
+
]
|
49
|
+
|
50
|
+
class << self
|
51
|
+
# Indicates that tests exist.
|
52
|
+
def exist?
|
53
|
+
!file_list.empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns an array of test files for the specified group.
|
57
|
+
def file_list(group = :all)
|
58
|
+
list = []
|
59
|
+
|
60
|
+
PATTERNS.each do |pattern|
|
61
|
+
paths(group).each do |path|
|
62
|
+
files = Util.dir_glob(File.join(path, pattern))
|
63
|
+
list << files
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
return list.flatten
|
68
|
+
end
|
69
|
+
|
70
|
+
# Convert a path to a file into an appropriate task name.
|
71
|
+
# This is done by removing the pattern that is used to indicate
|
72
|
+
# it is a test file.
|
73
|
+
def task_name(file_path)
|
74
|
+
file = File.basename(file_path, '.rb')
|
75
|
+
|
76
|
+
PATTERNS.each do |pattern|
|
77
|
+
pattern = pattern.sub(/\.rb$/, '').sub(/\*/, '.+?')
|
78
|
+
|
79
|
+
if file =~ /#{pattern}/
|
80
|
+
pattern = pattern.sub(/\.\+\?/, '')
|
81
|
+
return file_task(file, pattern)
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return an array containing the types of tests that are included.
|
88
|
+
def types
|
89
|
+
return [] unless root
|
90
|
+
|
91
|
+
types = []
|
92
|
+
|
93
|
+
Util.dir_glob(File.join(root, '**')).each do |path|
|
94
|
+
next unless Util.directory?(path)
|
95
|
+
types << get_types(path)
|
96
|
+
end
|
97
|
+
|
98
|
+
return types.flatten
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_types(path)
|
102
|
+
types = []
|
103
|
+
PATTERNS.each do |pattern|
|
104
|
+
next if types.include?(File.basename(path))
|
105
|
+
unless Util.dir_glob(File.join(path, pattern)).empty?
|
106
|
+
types << File.basename(path)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
types
|
110
|
+
end
|
111
|
+
|
112
|
+
# Indicates whether tests can be run against multiple rubies.
|
113
|
+
def run_rubies?
|
114
|
+
Util.file? rubies_yaml
|
115
|
+
end
|
116
|
+
|
117
|
+
# Runs tests against specified ruby/gemset/rake configurations.
|
118
|
+
def run_ruby_tests
|
119
|
+
parser = Parser.new
|
120
|
+
|
121
|
+
configs = test_configs
|
122
|
+
|
123
|
+
init_rubies configs
|
124
|
+
|
125
|
+
# Loop through the test configurations.
|
126
|
+
configs.each do |config|
|
127
|
+
puts '*' * 80
|
128
|
+
|
129
|
+
if config[:rake]
|
130
|
+
puts "#{config[:ruby]} - #{config[:rake]}"
|
131
|
+
end
|
132
|
+
|
133
|
+
cmd = ['bash', RakeTasks::SCRIPTS[:rubies], 'test:all']
|
134
|
+
cmd << config[:ruby]
|
135
|
+
cmd << config[:rake] if config[:rake]
|
136
|
+
|
137
|
+
# Run the tests.
|
138
|
+
pid = Process.spawn(*cmd, :out => 'out.log', :err => 'err.log')
|
139
|
+
Process.wait pid
|
140
|
+
|
141
|
+
parse_log parser
|
142
|
+
end
|
143
|
+
|
144
|
+
Util.rm 'out.log'
|
145
|
+
Util.rm 'err.log'
|
146
|
+
|
147
|
+
puts '*' * 80
|
148
|
+
parser.summarize
|
149
|
+
end
|
150
|
+
|
151
|
+
# Outputs commands to run all tests.
|
152
|
+
def rubies_shell_script
|
153
|
+
configs = test_configs
|
154
|
+
|
155
|
+
# Loop through the test configurations.
|
156
|
+
commands = setup_commands(configs)
|
157
|
+
|
158
|
+
run_commands(configs).each do |command|
|
159
|
+
commands << command
|
160
|
+
end
|
161
|
+
|
162
|
+
Util.write_file 'rubies.sh', commands.map { |c| c.join(' ') }
|
163
|
+
end
|
164
|
+
|
165
|
+
# Initialize gemsets for rubies.
|
166
|
+
def init_rubies(configs)
|
167
|
+
# Loop through the test configurations to initialize gemsets.
|
168
|
+
gem_rubies = []
|
169
|
+
configs.each do |config|
|
170
|
+
next if gem_rubies.include?(config[:ruby])
|
171
|
+
gem_rubies << config[:ruby]
|
172
|
+
|
173
|
+
cmd = ['bash', RakeTasks::SCRIPTS[:gemsets]]
|
174
|
+
cmd << config[:ruby].split('@')
|
175
|
+
|
176
|
+
pid = Process.spawn(*cmd.flatten)
|
177
|
+
Process.wait pid
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns an array of hashes containing all testable rubies/gemsets.
|
182
|
+
# ==== Output
|
183
|
+
# [Array] The configurations that will be tested.
|
184
|
+
def test_configs
|
185
|
+
configs = Util.load_yaml(rubies_yaml)
|
186
|
+
return [] unless configs.is_a?(Array)
|
187
|
+
|
188
|
+
configs.select! { |c| c['ruby'] || c['gemset'] }
|
189
|
+
|
190
|
+
set_configs configs
|
191
|
+
|
192
|
+
configs
|
193
|
+
end
|
194
|
+
|
195
|
+
# Paths to check for test files.
|
196
|
+
# Only paths for a specified type will be returned, if specified.
|
197
|
+
def paths(group = :all)
|
198
|
+
group = group.to_sym
|
199
|
+
paths = []
|
200
|
+
|
201
|
+
paths << root if group == :all && root
|
202
|
+
|
203
|
+
types.each do |type|
|
204
|
+
if group == type.to_sym || group == :all
|
205
|
+
paths << File.join(root, type)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
return paths
|
210
|
+
end
|
211
|
+
|
212
|
+
# The root test folder.
|
213
|
+
def root
|
214
|
+
ROOTS.each do |r|
|
215
|
+
return r if Util.directory?(r)
|
216
|
+
end
|
217
|
+
return
|
218
|
+
end
|
219
|
+
|
220
|
+
# Returns the location of the rubies yaml file.
|
221
|
+
def rubies_yaml
|
222
|
+
return unless root
|
223
|
+
File.join '.', root, 'rubies.yml'
|
224
|
+
end
|
225
|
+
|
226
|
+
#########################################################################
|
227
|
+
private
|
228
|
+
#########################################################################
|
229
|
+
|
230
|
+
def file_task(file, pattern)
|
231
|
+
if pattern.index('_') == 0
|
232
|
+
return file.sub(/#{pattern}$/, '')
|
233
|
+
else
|
234
|
+
return file.sub(/^#{pattern}/, '')
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def parse_log(parser)
|
239
|
+
Util.open_file('out.log', 'r') do |file|
|
240
|
+
while line = file.gets
|
241
|
+
parser.parse line
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def set_configs(configs)
|
247
|
+
for i in 0..configs.length - 1 do
|
248
|
+
config = configs[i]
|
249
|
+
|
250
|
+
config.keys.each do |key|
|
251
|
+
config[key.to_sym] = config[key]
|
252
|
+
config.delete key
|
253
|
+
end
|
254
|
+
|
255
|
+
if config[:gemset]
|
256
|
+
config[:ruby] = "#{config[:ruby]}@#{config[:gemset]}"
|
257
|
+
end
|
258
|
+
|
259
|
+
config.delete(:gemset)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def setup_commands(configs)
|
264
|
+
cmds = gemset_create_commands(configs)
|
265
|
+
cmds << ['rvm', rvm_rubies(configs), 'do', 'gem', 'install',
|
266
|
+
'bundler', '--no-rdoc', '--no-ri']
|
267
|
+
cmds << ['rvm', rvm_rubies(configs), 'do', 'bundle', 'install']
|
268
|
+
cmds << ['rvm', rvm_rubies(configs), 'do', 'bundle', 'clean', '--force']
|
269
|
+
configs.each do |config|
|
270
|
+
if config[:rake]
|
271
|
+
cmds << ['rvm', config[:ruby], 'do', 'gem', 'install',
|
272
|
+
'rake', '-v', config[:rake], '--no-rdoc', '--no-ri']
|
273
|
+
end
|
274
|
+
end
|
275
|
+
cmds
|
276
|
+
end
|
277
|
+
|
278
|
+
def run_commands(configs)
|
279
|
+
cmds = []
|
280
|
+
if configs.any? { |c| c[:rake] }
|
281
|
+
configs.each do |config|
|
282
|
+
if config[:rake]
|
283
|
+
cmds << ['echo',
|
284
|
+
"ruby: #{config[:ruby]} / rake: #{config[:rake]}"]
|
285
|
+
cmds << ['rvm', config[:ruby], 'do', 'rake', "_#{config[:rake]}_"]
|
286
|
+
else
|
287
|
+
cmds << ['rvm', config[:ruby], 'do', 'bundle', 'exec', 'rake']
|
288
|
+
end
|
289
|
+
end
|
290
|
+
else
|
291
|
+
cmds << ['rvm', rvm_rubies(configs), 'do', 'bundle', 'exec', 'rake']
|
292
|
+
end
|
293
|
+
cmds
|
294
|
+
end
|
295
|
+
|
296
|
+
def gemset_create_commands(configs)
|
297
|
+
cmds = []
|
298
|
+
cmds << ['set', '-e']
|
299
|
+
configs.uniq { |c| c[:ruby] }.each do |config|
|
300
|
+
ruby = config[:ruby].sub(/@.*/, '')
|
301
|
+
gemset = config[:ruby].sub(/.*@/, '')
|
302
|
+
cmds << ['rvm', ruby, 'do', 'rvm', 'gemset', 'create', gemset]
|
303
|
+
end
|
304
|
+
cmds
|
305
|
+
end
|
306
|
+
|
307
|
+
def rvm_rubies(configs)
|
308
|
+
configs.uniq { |c| c[:ruby] }.map do |config|
|
309
|
+
config[:ruby]
|
310
|
+
end.join(',')
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|