Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 317 lines (261 sloc) 9.594 kb
60c031d @sferik Use the new `bundle gem` defaults
sferik authored
1 # -*- encoding: utf-8 -*-
67859e4 Moving in thor
Carlhuda authored
2 $:.unshift File.expand_path("../lib", __FILE__)
40d01cf @rohit require shellwords in Rakefile to get specs running on Rubinius
rohit authored
3 require 'shellwords'
f711a47 @indirect benchmark all the tasks. because we can.
indirect authored
4 require 'benchmark'
88d49f2 @indirect simplify the certs manager
indirect authored
5
8c2b02a @indirect certificate manager namespacing and path expansion
indirect authored
6 RUBYGEMS_REPO = File.expand_path("tmp/rubygems")
d05497a @indirect check rspec version while running specs
indirect authored
7 BUNDLER_SPEC = Gem::Specification.load("bundler.gemspec")
f711a47 @indirect benchmark all the tasks. because we can.
indirect authored
8
ef47173 @indirect create task to test against rubygems 2 rc1
indirect authored
9 def safe_task(&block)
10 yield
11 true
12 rescue
13 false
14 end
15
f711a47 @indirect benchmark all the tasks. because we can.
indirect authored
16 # Benchmark task execution
17 module Rake
18 class Task
19 alias_method :real_invoke, :invoke
20
21 def invoke(*args)
22 time = Benchmark.measure(@name) do
23 real_invoke(*args)
24 end
25 puts "#{@name} ran for #{time}"
26 end
27 end
28 end
67859e4 Moving in thor
Carlhuda authored
29
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
30 def clean_files(files, regex, replacement = '')
31 files.each do |file|
32 contents = File.read(file)
33 contents.gsub!(regex, replacement)
34 File.open(file, 'w') { |f| f << contents }
35 end
36 end
37
a43c560 @segiddins [Resolver] Start migration to Molinillo
segiddins authored
38 namespace :molinillo do
39 task :namespace do
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
40 files = Dir.glob('lib/bundler/vendor/molinillo*/**/*.rb')
41 clean_files(files, 'Molinillo', 'Bundler::Molinillo')
42 clean_files(files, /require (["'])molinillo/, 'require \1bundler/vendor/molinillo/lib/molinillo')
a43c560 @segiddins [Resolver] Start migration to Molinillo
segiddins authored
43 end
44
45 task :clean do
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
46 files = Dir.glob('lib/bundler/vendor/molinillo*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last }
47 rm_r files
a43c560 @segiddins [Resolver] Start migration to Molinillo
segiddins authored
48 end
49
50 task :update, [:tag] => [] do |t, args|
51 tag = args[:tag]
52 Dir.chdir 'lib/bundler/vendor' do
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
53 rm_rf 'molinillo'
54 sh "curl -L https://github.com/CocoaPods/molinillo/archive/#{tag}.tar.gz | tar -xz"
55 sh "mv Molinillo-* molinillo"
a43c560 @segiddins [Resolver] Start migration to Molinillo
segiddins authored
56 end
57 Rake::Task['molinillo:namespace'].invoke
58 Rake::Task['molinillo:clean'].invoke
59 end
60 end
61
6b2affe @segiddins [Thor] Namespaced the vendored version of Thor and update to the v0.19.1...
segiddins authored
62 namespace :thor do
63 task :namespace do
9adb543 @segiddins [Thor] downcase vendored thor directory
segiddins authored
64 files = Dir.glob('lib/bundler/vendor/thor*/**/*.rb')
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
65 clean_files(files, 'Thor', 'Bundler::Thor')
66 clean_files(files, /require (["'])thor/, 'require \1bundler/vendor/thor/lib/thor')
67 clean_files(files, /(autoload\s+[:\w]+,\s+["'])(thor[\w\/]+["'])/, '\1bundler/vendor/thor/lib/\2')
6b2affe @segiddins [Thor] Namespaced the vendored version of Thor and update to the v0.19.1...
segiddins authored
68 end
69
70 task :clean do
9adb543 @segiddins [Thor] downcase vendored thor directory
segiddins authored
71 files = Dir.glob('lib/bundler/vendor/thor*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last }
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
72 rm_r files
6b2affe @segiddins [Thor] Namespaced the vendored version of Thor and update to the v0.19.1...
segiddins authored
73 end
74
75 task :update, [:tag] => [] do |t, args|
76 tag = args[:tag]
77 Dir.chdir 'lib/bundler/vendor' do
aef35ac @segiddins [Vendor] Dont change the load path to require vendored gems
segiddins authored
78 rm_rf 'thor'
79 sh "curl -L https://github.com/erikhuda/thor/archive/#{tag}.tar.gz | tar -xz"
80 sh "mv thor-* thor"
6b2affe @segiddins [Thor] Namespaced the vendored version of Thor and update to the v0.19.1...
segiddins authored
81 end
82 Rake::Task['thor:namespace'].invoke
83 Rake::Task['thor:clean'].invoke
84 end
85 end
86
1ce02b4 @indirect always have the spec:deps task available
indirect authored
87 namespace :spec do
88 desc "Ensure spec dependencies are installed"
89 task :deps do
d05497a @indirect check rspec version while running specs
indirect authored
90 deps = Hash[BUNDLER_SPEC.development_dependencies.map do |d|
bd7e5a7 @indirect move the dev deps list into the gemspec
indirect authored
91 [d.name, d.requirement.to_s]
a7c960e @indirect sort deps by name before installing them
indirect authored
92 end]
2e2be72 @indirect Ruby 1.8 is still a thing
indirect authored
93
94 # JRuby can't build ronn or rdiscount, so we skip that
95 if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
96 deps.delete("ronn")
97 deps.delete("rdiscount")
98 end
bc9c7b5 @headius Avoid installing C exts on JRuby to allow running specs.
headius authored
99
a7c960e @indirect sort deps by name before installing them
indirect authored
100 deps.sort_by{|name, _| name }.each do |name, version|
0ede196 @marutosi fix "rake spec:deps" fails on MinGW Ruby 2.0
marutosi authored
101 sh %{#{Gem.ruby} -S gem list -i "^#{name}$" -v "#{version}" || } +
102 %{#{Gem.ruby} -S gem install #{name} -v "#{version}" --no-ri --no-rdoc}
2868f49 @indirect rdiscount 2.0 doesn't compile on 1.9.2
indirect authored
103 end
264ada4 @indirect install those gems inside spec:deps, yup yup
indirect authored
104
105 # Download and install gems used inside tests
106 $LOAD_PATH.unshift("./spec")
107 require 'support/rubygems_ext'
108 Spec::Rubygems.setup
1ce02b4 @indirect always have the spec:deps task available
indirect authored
109 end
b6b5f80 @indirect move the travis deps task above the rspec load
indirect authored
110
111 namespace :travis do
112 task :deps do
113 # Give the travis user a name so that git won't fatally error
22a1acc @indirect oops, need older rubygems to work
indirect authored
114 system "sudo sed -i 's/1000::/1000:Travis:/g' /etc/passwd"
b6b5f80 @indirect move the travis deps task above the rspec load
indirect authored
115 # Strip secure_path so that RVM paths transmit through sudo -E
22a1acc @indirect oops, need older rubygems to work
indirect authored
116 system "sudo sed -i '/secure_path/d' /etc/sudoers"
b6b5f80 @indirect move the travis deps task above the rspec load
indirect authored
117 # Install groff for the ronn gem
22a1acc @indirect oops, need older rubygems to work
indirect authored
118 sh "sudo apt-get install groff -y"
0671915 @indirect downgrade rubygems on 1.8
indirect authored
119 if RUBY_VERSION < '1.9'
22a1acc @indirect oops, need older rubygems to work
indirect authored
120 # Downgrade Rubygems on 1.8 so Ronn can be required
121 # https://github.com/rubygems/rubygems/issues/784
4d62410 @indirect :grimacing: lets try a real version of rubygems
indirect authored
122 sh "gem update --system 2.1.11"
22a1acc @indirect oops, need older rubygems to work
indirect authored
123 else
769eabc @JuanitoFatas [ci skip] Fix a typo in Rakefile.
JuanitoFatas authored
124 # Downgrade Rubygems so RSpec 3 can be installed
22a1acc @indirect oops, need older rubygems to work
indirect authored
125 # https://github.com/rubygems/rubygems/issues/813
126 sh "gem update --system 2.2.0"
0671915 @indirect downgrade rubygems on 1.8
indirect authored
127 end
b6b5f80 @indirect move the travis deps task above the rspec load
indirect authored
128 # Install the other gem deps, etc.
129 Rake::Task["spec:deps"].invoke
130 end
131 end
1ce02b4 @indirect always have the spec:deps task available
indirect authored
132 end
133
67859e4 Moving in thor
Carlhuda authored
134 begin
d05497a @indirect check rspec version while running specs
indirect authored
135 rspec = BUNDLER_SPEC.development_dependencies.find{|d| d.name == "rspec" }
136 gem 'rspec', rspec.requirement.to_s
870ad85 @wycats Get Bundler tests running on RSpec 2
wycats authored
137 require 'rspec/core/rake_task'
6cc134c Add a task that runs the specs including sudo specs
Carl Lerche authored
138
67859e4 Moving in thor
Carlhuda authored
139 desc "Run specs"
6485b24 @indirect move spec task options into options file
indirect authored
140 RSpec::Core::RakeTask.new
2c82b5e @indirect Better names for manpage tasks
indirect authored
141 task :spec => "man:build"
6cc134c Add a task that runs the specs including sudo specs
Carl Lerche authored
142
143 namespace :spec do
805259c @indirect clean up sudo tmp files after any sudo tests run
indirect authored
144 task :clean do
145 rm_rf 'tmp'
146 end
147
4ef90b2 @sferik Fix typo in rake task description
sferik authored
148 desc "Run the real-world spec suite (requires internet)"
ba80464 @indirect real-world spec for index search cache bug
indirect authored
149 task :realworld => ["set_realworld", "spec"]
150
151 task :set_realworld do
152 ENV['BUNDLER_REALWORLD_TESTS'] = '1'
153 end
154
74ee162 @indirect Minor rakefile organization
indirect authored
155 desc "Run the spec suite with the sudo tests"
805259c @indirect clean up sudo tmp files after any sudo tests run
indirect authored
156 task :sudo => ["set_sudo", "spec", "clean_sudo"]
74ee162 @indirect Minor rakefile organization
indirect authored
157
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
158 task :set_sudo do
6cc134c Add a task that runs the specs including sudo specs
Carl Lerche authored
159 ENV['BUNDLER_SUDO_TESTS'] = '1'
160 end
161
805259c @indirect clean up sudo tmp files after any sudo tests run
indirect authored
162 task :clean_sudo do
163 puts "Cleaning up sudo test files..."
164 system "sudo rm -rf #{File.expand_path('../tmp/sudo_gem_home', __FILE__)}"
6cc134c Add a task that runs the specs including sudo specs
Carl Lerche authored
165 end
166
a32b020 @indirect fix travis and tasks to match
indirect authored
167 # Rubygems specs by version
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
168 namespace :rubygems do
169 rubyopt = ENV["RUBYOPT"]
a32b020 @indirect fix travis and tasks to match
indirect authored
170 # When editing this list, also edit .travis.yml!
516d548 @indirect and we need the rake tasks for travis, too
indirect authored
171 branches = %w(master)
172 releases = %w(v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.29 v2.0.14 v2.1.11 v2.2.3 v2.4.6)
4846d9e @indirect update rubygems versions being tested
indirect authored
173 (branches + releases).each do |rg|
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
174 desc "Run specs with Rubygems #{rg}"
175 RSpec::Core::RakeTask.new(rg) do |t|
b2ef0e4 @kiela Use documentation rspec formater
kiela authored
176 t.rspec_opts = %w(--format documentation --color)
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
177 t.ruby_opts = %w(-w)
178 end
179
e8e5244 @indirect add sudo spec tasks for each rubygems version
indirect authored
180 # Create tasks like spec:rubygems:v1.8.3:sudo to run the sudo specs
181 namespace rg do
805259c @indirect clean up sudo tmp files after any sudo tests run
indirect authored
182 task :sudo => ["set_sudo", rg, "clean_sudo"]
8a66d1f @indirect run realworld specs on travis
indirect authored
183 task :realworld => ["set_realworld", rg]
e8e5244 @indirect add sudo spec tasks for each rubygems version
indirect authored
184 end
185
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
186 task "clone_rubygems_#{rg}" do
62c9267 @indirect use RUBYGEMS_REPO everywhere
indirect authored
187 unless File.directory?(RUBYGEMS_REPO)
0ccb61c @indirect clone rubygems via https
indirect authored
188 system("git clone https://github.com/rubygems/rubygems.git tmp/rubygems")
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
189 end
f7f74f3 Report the git SHA1 to double check which rubygems was used
Evan Phoenix authored
190 hash = nil
191
88d49f2 @indirect simplify the certs manager
indirect authored
192 Dir.chdir(RUBYGEMS_REPO) do
6f49167 @indirect In further git genius, update tags before checking them out
indirect authored
193 system("git remote update")
82173b6 @indirect awesome. I broke the matrix build, too.
indirect authored
194 if rg == "master"
195 system("git checkout origin/master")
196 else
2bc1277 @indirect raise when Rubygems version doesn't exist
indirect authored
197 system("git checkout #{rg}") || raise("Unknown Rubygems ref #{rg}")
82173b6 @indirect awesome. I broke the matrix build, too.
indirect authored
198 end
f2c4c35 @indirect add 2.0.0-preview2 to the build for now for clarity
indirect authored
199 hash = `git rev-parse HEAD`.chomp
91e89f6 @indirect In a total noob move, I pulled bundler master instead of rubygems master
indirect authored
200 end
f7f74f3 Report the git SHA1 to double check which rubygems was used
Evan Phoenix authored
201
f711a47 @indirect benchmark all the tasks. because we can.
indirect authored
202 puts "Checked out rubygems '#{rg}' at #{hash}"
3d724d6 @indirect Update Rubygems test versions
indirect authored
203 ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems/lib")} #{rubyopt}"
90890c2 @indirect show the rubyopt we use to run specs
indirect authored
204 puts "RUBYOPT=#{ENV['RUBYOPT']}"
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
205 end
206
7024b3b @indirect run ronn before setting RUBYOPT for rg checkout
indirect authored
207 task rg => ["man:build", "clone_rubygems_#{rg}"]
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
208 task "rubygems:all" => rg
bd4dc9b Allow the Rake file to load and run when rspec is not installed
Carl Lerche authored
209 end
5f4a8f3 Phase 1 of rubygems/bundler reintegration
Evan Phoenix authored
210
211 desc "Run specs under a Rubygems checkout (set RG=path)"
212 RSpec::Core::RakeTask.new("co") do |t|
b2ef0e4 @kiela Use documentation rspec formater
kiela authored
213 t.rspec_opts = %w(--format documentation --color)
5f4a8f3 Phase 1 of rubygems/bundler reintegration
Evan Phoenix authored
214 t.ruby_opts = %w(-w)
215 end
216
217 task "setup_co" do
c397a53 @indirect print path to rubygems checkout
indirect authored
218 rg = File.expand_path ENV['RG']
219 puts "Running specs against Rubygems in #{rg}..."
220 ENV["RUBYOPT"] = "-I#{rg} #{rubyopt}"
5f4a8f3 Phase 1 of rubygems/bundler reintegration
Evan Phoenix authored
221 end
222
223 task "co" => "setup_co"
224 task "rubygems:all" => "co"
715f150 Make bundler work with RG 1.3.5, 1.3.6 and trunk and create a spec task ...
Carlhuda authored
225 end
bd4dc9b Allow the Rake file to load and run when rspec is not installed
Carl Lerche authored
226
992c2a4 @indirect argh how did that happen
indirect authored
227 desc "Run the tests on Travis CI against a rubygem version (using ENV['RGV'])"
8a66d1f @indirect run realworld specs on travis
indirect authored
228 task :travis do
8c2b02a @indirect certificate manager namespacing and path expansion
indirect authored
229 rg = ENV['RGV'] || raise("Rubygems version is required on Travis!")
68bcd1e @joshk If you want to run a Rake task twice using invoke, you need to reenable ...
joshk authored
230
bcea40f @joshk We need to capturing rake errors and return false, and then fail the tas...
joshk authored
231 puts "\n\e[1;33m[Travis CI] Running bundler specs against rubygems #{rg}\e[m\n\n"
232 specs = safe_task { Rake::Task["spec:rubygems:#{rg}"].invoke }
68bcd1e @joshk If you want to run a Rake task twice using invoke, you need to reenable ...
joshk authored
233
f8fdf6d @joshk we need to reenable more than one rake task
joshk authored
234 Rake::Task["spec:rubygems:#{rg}"].reenable
68bcd1e @joshk If you want to run a Rake task twice using invoke, you need to reenable ...
joshk authored
235
bcea40f @joshk We need to capturing rake errors and return false, and then fail the tas...
joshk authored
236 puts "\n\e[1;33m[Travis CI] Running bundler sudo specs against rubygems #{rg}\e[m\n\n"
256f071 @indirect allow PATH through sudo on rails travis workers
indirect authored
237 sudos = system("sudo -E rake spec:rubygems:#{rg}:sudo")
238 # clean up by chowning the newly root-owned tmp directory back to the travis user
239 system("sudo chown -R #{ENV['USER']} #{File.join(File.dirname(__FILE__), 'tmp')}")
68bcd1e @joshk If you want to run a Rake task twice using invoke, you need to reenable ...
joshk authored
240
8a66d1f @indirect run realworld specs on travis
indirect authored
241 Rake::Task["spec:rubygems:#{rg}"].reenable
242
243 puts "\n\e[1;33m[Travis CI] Running bundler real world specs against rubygems #{rg}\e[m\n\n"
244 realworld = safe_task { Rake::Task["spec:rubygems:#{rg}:realworld"].invoke }
245
88f7f56 @indirect print results from each suite
indirect authored
246 {"specs" => specs, "sudo" => sudos, "realworld" => realworld}.each do |name, passed|
247 if passed
248 puts "\e[0;32m[Travis CI] #{name} passed\e[m"
249 else
250 puts "\e[0;31m[Travis CI] #{name} failed\e[m"
251 end
252 end
253
8a66d1f @indirect run realworld specs on travis
indirect authored
254 unless specs && sudos && realworld
88f7f56 @indirect print results from each suite
indirect authored
255 fail "Spec run failed, please review the log for more information"
bcea40f @joshk We need to capturing rake errors and return false, and then fail the tas...
joshk authored
256 end
f419c42 @indirect and the travis task should be inside the spec namespace
indirect authored
257 end
0898d4e @indirect Spec tasks to run on 1.8.6, 1.8.7, and 1.9.2
indirect authored
258 end
0dd7343 @indirect Clean up the retarded Rakefile, use the Bundler gem helpers
indirect authored
259
2af8c75 @indirect fail man tasks without ronn
indirect authored
260 rescue LoadError
261 task :spec do
262 abort "Run `rake spec:deps` to be able to run the specs"
263 end
264 end
265
266 begin
267 require 'ronn'
268
b88d8a9 @indirect allow rspec tasks even if ronn is missing
indirect authored
269 namespace :man do
270 directory "lib/bundler/man"
271
272 Dir["man/*.ronn"].each do |ronn|
273 basename = File.basename(ronn, ".ronn")
274 roff = "lib/bundler/man/#{basename}"
275
276 file roff => ["lib/bundler/man", ronn] do
8301888 @brixen Use the same ruby to run subprocesses as is running rake.
brixen authored
277 sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}"
b88d8a9 @indirect allow rspec tasks even if ronn is missing
indirect authored
278 end
279
280 file "#{roff}.txt" => roff do
281 sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt"
282 end
283
284 task :build_all_pages => "#{roff}.txt"
285 end
286
287 desc "Build the man pages"
288 task :build => "man:build_all_pages"
289
290 desc "Clean up from the built man pages"
291 task :clean do
292 rm_rf "lib/bundler/man"
293 end
a9b4aa6 @indirect guard against missing ronn during release
indirect authored
294
295 task(:require) { }
b88d8a9 @indirect allow rspec tasks even if ronn is missing
indirect authored
296 end
297
1ce02b4 @indirect always have the spec:deps task available
indirect authored
298 rescue LoadError
2af8c75 @indirect fail man tasks without ronn
indirect authored
299 namespace :man do
a9b4aa6 @indirect guard against missing ronn during release
indirect authored
300 task(:require) { abort "Install the ronn gem to be able to release!" }
301 task(:build) { warn "Install the ronn gem to build the help pages" }
302 task(:clean) { }
1ce02b4 @indirect always have the spec:deps task available
indirect authored
303 end
715f150 Make bundler work with RG 1.3.5, 1.3.6 and trunk and create a spec task ...
Carlhuda authored
304 end
305
88d49f2 @indirect simplify the certs manager
indirect authored
306 desc "Update vendored SSL certs to match the certs vendored by Rubygems"
307 task :update_certs => "spec:rubygems:clone_rubygems_master" do
308 require 'bundler/ssl_certs/certificate_manager'
8c2b02a @indirect certificate manager namespacing and path expansion
indirect authored
309 Bundler::SSLCerts::CertificateManager.update_from!(RUBYGEMS_REPO)
88d49f2 @indirect simplify the certs manager
indirect authored
310 end
311
67fb448 @indirect RSpec version conflicts on 1.8 :cold_sweat:
indirect authored
312 require 'bundler/gem_tasks'
2af8c75 @indirect fail man tasks without ronn
indirect authored
313 task :build => ["man:clean", "man:build"]
a9b4aa6 @indirect guard against missing ronn during release
indirect authored
314 task :release => ["man:require", "man:clean", "man:build"]
2af8c75 @indirect fail man tasks without ronn
indirect authored
315
e4adbf7 @carllerche Update Rakefile for rspec 2 beta22
carllerche authored
316 task :default => :spec
Something went wrong with that request. Please try again.