/
Rakefile
242 lines (202 loc) · 7.5 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
141
142
143
144
145
146
147
148
149
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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# frozen_string_literal: true
require_relative "spec/support/rubygems_ext"
desc "Run specs"
task :spec do
sh("bin/rspec")
end
namespace :dev do
desc "Ensure dev dependencies are installed"
task :deps do
Spec::Rubygems.dev_setup
end
end
namespace :spec do
desc "Ensure spec dependencies are installed"
task :deps => "dev:deps" do
Spec::Rubygems.install_test_deps
end
desc "Ensure spec dependencies for running in parallel are installed"
task :parallel_deps => "dev:deps" do
Spec::Rubygems.install_parallel_test_deps
end
desc "Run all specs"
task :all => %w[spec:regular spec:realworld spec:sudo]
desc "Run the regular spec suite"
task :regular do
sh("bin/parallel_rspec")
end
desc "Run the real-world spec suite"
task :realworld do
sh("BUNDLER_SPEC_PRE_RECORDED=1 bin/rspec --tag realworld")
end
namespace :realworld do
desc "Re-record cassettes for the realworld specs"
task :record do
sh("rm -rf spec/support/artifice/vcr_cassettes && bin/rspec --tag realworld")
end
end
desc "Run the spec suite with the sudo tests"
task :sudo do
require "open3"
output, status = Open3.capture2e("sudo", "cp", "/etc/sudoers", "tmp/old_sudoers")
raise "Couldn't read sudoers file: #{output}" unless status.success?
begin
output, status = Open3.capture2e("sudo sed -i '/secure_path/d' /etc/sudoers")
raise "Couldn't configure sudo to preserve path: #{output}" unless status.success?
raise "Couldn't configure sudo correctly to preserve path" unless `ruby -v` == `sudo -E ruby -v`
sh("sudo -E --preserve-env=RUBYOPT bin/rspec --tag sudo")
ensure
system("sudo", "cp", "tmp/old_sudoers", "/etc/sudoers")
system("sudo", "chown", "-R", ENV["USER"], "tmp")
end
end
end
desc "Check RVM integration"
task :check_rvm_integration do
# The rubygems-bundler gem is installed by RVM by default and it could easily
# break when we change bundler. Make sure that binstubs still run with it
# installed.
sh("gem install rubygems-bundler rake && RUBYOPT=-Ilib rake -T")
end
namespace :man do
if RUBY_ENGINE == "jruby"
task(:build) {}
else
directory "man"
index = Dir["man/*.ronn"].map do |source|
ronn = "man/#{File.basename(source)}"
roff = "man/#{File.basename(source, ".ronn")}"
file roff => ["man", ronn] do
date = ENV["MAN_PAGES_DATE"] || Time.now.strftime("%Y-%m-%d")
sh "bin/ronn --warnings --roff --pipe --date #{date} #{ronn} > #{roff}"
end
task :build_all_pages => roff
[ronn, File.basename(roff)]
end
file "index.txt" do
index.map! do |(ronn, roff)|
[File.read(ronn).split(" ").first, roff]
end
index = index.sort_by(&:first)
justification = index.map {|(n, _f)| n.length }.max + 4
File.open("man/index.txt", "w") do |f|
index.each do |name, filename|
f << name.ljust(justification) << filename << "\n"
end
end
end
task :build_all_pages => "index.txt"
desc "Make sure ronn is installed"
task :check_ronn do
begin
Spec::Rubygems.gem_require("ronn")
rescue Gem::LoadError => e
abort("We couldn't activate ronn (#{e.requirement}). Try `gem install ronn:'#{e.requirement}'` to be able to build the help pages")
end
end
desc "Remove all built man pages"
task :clean do
leftovers = Dir["man/*"].reject do |f|
File.extname(f) == ".ronn"
end
rm leftovers if leftovers.any?
end
desc "Build the man pages"
task :build => [:check_ronn, :clean, :build_all_pages]
desc "Sets target date for building man pages to the one currently present"
task :set_current_date do
require "date"
ENV["MAN_PAGES_DATE"] = Date.parse(File.readlines("man/bundle-add.1")[3].split('"')[5]).strftime("%Y-%m-%d")
end
desc "Verify man pages are in sync"
task :check => [:check_ronn, :set_current_date, :build] do
require "open3"
output, status = Open3.capture2e("git status --porcelain")
if status.success? && output.empty?
puts
puts "Man pages are in sync"
puts
else
sh("git status --porcelain")
puts
puts "Man pages are out of sync. Above you can see the list of files that got modified or generated from rebuilding them. Please review and commit the results."
puts
exit(1)
end
end
end
end
load "task/automatiek.rake"
desc "Vendor a specific version of molinillo"
Automatiek::RakeTask.new("molinillo") do |lib|
lib.download = { :github => "https://github.com/CocoaPods/Molinillo" }
lib.namespace = "Molinillo"
lib.prefix = "Bundler"
lib.vendor_lib = "lib/bundler/vendor/molinillo"
end
desc "Vendor a specific version of thor"
Automatiek::RakeTask.new("thor") do |lib|
lib.version = "v1.0.1"
lib.download = { :github => "https://github.com/erikhuda/thor" }
lib.namespace = "Thor"
lib.prefix = "Bundler"
lib.vendor_lib = "lib/bundler/vendor/thor"
end
# We currently include the official version as of
# https://github.com/ruby/tmpdir/tree/a3e06bd49829dc49c346aa10f8b91116fd7e17ad,
# with the following changes on top:
# * require fileutils relatively to use our vendored version.
# * Inherit from `Dir` so that code assuming we're inside the
# `Dir` class still works. Also change the `systmpdir` class variable to an
# instance variable since otherwise inheriting from dir doesn't work.
# * Remove a "block variable shadowing outer variable" warning on older rubies
# that was breaking some specs.
desc "Vendor a specific version of tmpdir"
Automatiek::RakeTask.new("tmpdir") do |lib|
lib.version = "master"
lib.download = { :github => "https://github.com/ruby/tmpdir" }
lib.namespace = "Dir"
lib.prefix = "Bundler"
lib.vendor_lib = "lib/bundler/vendor/tmpdir"
lib.dependency("fileutils") do |sublib|
sublib.version = "v1.4.1"
sublib.download = { :github => "https://github.com/ruby/fileutils" }
sublib.namespace = "FileUtils"
sublib.prefix = "Bundler"
sublib.vendor_lib = "lib/bundler/vendor/fileutils"
end
end
# We currently include the following changes over the official version:
# * Avoid requiring the optional `net-http-pipeline` dependency, so that its version can be selected by end users.
# * We also include changes to require the vendored dependencies `uri` and `connection_pool` relatively.
desc "Vendor a specific version of net-http-persistent"
Automatiek::RakeTask.new("net-http-persistent") do |lib|
lib.version = "v4.0.0"
lib.download = { :github => "https://github.com/drbrain/net-http-persistent" }
lib.namespace = "Net::HTTP::Persistent"
lib.prefix = "Bundler::Persistent"
lib.vendor_lib = "lib/bundler/vendor/net-http-persistent"
lib.dependency("connection_pool") do |sublib|
sublib.version = "v2.2.2"
sublib.download = { :github => "https://github.com/mperham/connection_pool" }
sublib.namespace = "ConnectionPool"
sublib.prefix = "Bundler"
sublib.vendor_lib = "lib/bundler/vendor/connection_pool"
end
# We currently include changes over the official version to require internal paths
# relatively.
lib.dependency("uri") do |sublib|
sublib.version = "v0.10.0"
sublib.download = { :github => "https://github.com/ruby/uri" }
sublib.namespace = "URI"
sublib.prefix = "Bundler"
sublib.vendor_lib = "lib/bundler/vendor/uri"
end
end
task :override_version do
next unless version = ENV["BUNDLER_SPEC_SUB_VERSION"]
Spec::Path.replace_version_file(version)
end
task :default => :spec
load "task/bundler_3.rake"
load "task/release.rake"