Skip to content

Commit 51958ba

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Prefer FileUtils.rm_r to FileUtils.rm_rf for specs
Because it does not swallow errors if it fails to remove the given folders, making issues easier to debug. ruby/rubygems@0db12d7afc
1 parent f656d34 commit 51958ba

25 files changed

+61
-61
lines changed

spec/bundler/cache/gems_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
path: cached_myrack.parent,
313313
rubygems_version: "1.3.2"
314314

315-
FileUtils.rm_rf default_bundle_path
315+
FileUtils.rm_r default_bundle_path
316316
system_gems :bundler
317317

318318
FileUtils.rm bundled_app_lock
@@ -345,7 +345,7 @@
345345
c.checksum gem_repo1, "myrack", "1.0.0"
346346
end
347347

348-
FileUtils.rm_rf default_bundle_path
348+
FileUtils.rm_r default_bundle_path
349349
system_gems :bundler
350350

351351
lockfile <<-L

spec/bundler/cache/git_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
2929
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
3030

31-
FileUtils.rm_rf lib_path("foo-1.0")
31+
FileUtils.rm_r lib_path("foo-1.0")
3232
expect(the_bundle).to include_gems "foo 1.0"
3333
end
3434

@@ -49,7 +49,7 @@
4949
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
5050
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
5151

52-
FileUtils.rm_rf lib_path("foo-1.0")
52+
FileUtils.rm_r lib_path("foo-1.0")
5353
expect(the_bundle).to include_gems "foo 1.0"
5454
end
5555

@@ -66,7 +66,7 @@
6666
bundle :cache
6767

6868
expect(out).to include "Updating files in vendor/cache"
69-
FileUtils.rm_rf lib_path("foo-1.0")
69+
FileUtils.rm_r lib_path("foo-1.0")
7070
expect(the_bundle).to include_gems "foo 1.0"
7171
end
7272

@@ -95,7 +95,7 @@
9595
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
9696
expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
9797

98-
FileUtils.rm_rf lib_path("foo-1.0")
98+
FileUtils.rm_r lib_path("foo-1.0")
9999
run "require 'foo'"
100100
expect(out).to eq("CACHE")
101101
end
@@ -124,7 +124,7 @@
124124
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
125125
expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
126126

127-
FileUtils.rm_rf lib_path("foo-1.0")
127+
FileUtils.rm_r lib_path("foo-1.0")
128128
run "require 'foo'"
129129
expect(out).to eq("CACHE")
130130
end
@@ -249,7 +249,7 @@
249249
# Simulate old cache by copying the real cache folder to vendor/cache
250250
FileUtils.mkdir_p bundled_app("vendor/cache")
251251
FileUtils.cp_r "#{Dir.glob(vendored_gems("cache/bundler/git/foo-1.0-*")).first}/.", cache_dir
252-
FileUtils.rm_rf bundled_app("vendor/bundle")
252+
FileUtils.rm_r bundled_app("vendor/bundle")
253253

254254
bundle "install --local --verbose"
255255
expect(err).to include("Installing from cache in old \"bare repository\" format for compatibility")
@@ -281,7 +281,7 @@
281281
# Simulate old cache by copying the real cache folder to vendor/cache
282282
FileUtils.mkdir_p bundled_app("vendor/cache")
283283
FileUtils.cp_r "#{Dir.glob(vendored_gems("cache/bundler/git/foo-1.0-*")).first}/.", cache_dir
284-
FileUtils.rm_rf bundled_app("vendor/bundle")
284+
FileUtils.rm_r bundled_app("vendor/bundle")
285285

286286
bundle "install --verbose"
287287
expect(out).to include("Fetching")
@@ -423,7 +423,7 @@
423423
# Simulate an old incorrect situation where vendor/cache would be the install location of git gems
424424
FileUtils.mkdir_p bundled_app("vendor/cache")
425425
FileUtils.cp_r git_path, bundled_app("vendor/cache/foo-1.0-#{path_revision}")
426-
FileUtils.rm_rf bundled_app("vendor/cache/foo-1.0-#{path_revision}/.git")
426+
FileUtils.rm_r bundled_app("vendor/cache/foo-1.0-#{path_revision}/.git")
427427

428428
bundle :install, env: { "BUNDLE_DEPLOYMENT" => "true", "BUNDLE_CACHE_ALL" => "true" }
429429
end

spec/bundler/commands/cache_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@
357357

358358
bundle :cache
359359
pristine_system_gems :bundler
360-
FileUtils.rm_rf gem_repo2
360+
FileUtils.rm_r gem_repo2
361361

362362
bundle "install --local"
363363
expect(the_bundle).to include_gems "myrack 1.0.0"
@@ -372,7 +372,7 @@
372372

373373
bundle :cache
374374
pristine_system_gems :bundler
375-
FileUtils.rm_rf gem_repo2
375+
FileUtils.rm_r gem_repo2
376376

377377
bundle "config set --local deployment true"
378378
bundle "config set --local path vendor/bundle"
@@ -389,7 +389,7 @@
389389

390390
bundle :cache
391391
pristine_system_gems :bundler
392-
FileUtils.rm_rf gem_repo2
392+
FileUtils.rm_r gem_repo2
393393

394394
bundle "config set --local cache_all_platforms true"
395395
bundle "config set --local path vendor/bundle"
@@ -449,7 +449,7 @@
449449
empty_repo4
450450

451451
# delete compact index cache
452-
FileUtils.rm_rf home(".bundle/cache/compact_index")
452+
FileUtils.rm_r home(".bundle/cache/compact_index")
453453

454454
bundle "install", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
455455

spec/bundler/commands/check_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
gem "foo", git: "#{lib_path("foo")}"
9696
G
9797

98-
FileUtils.rm_rf bundled_app("vendor/bundle")
98+
FileUtils.rm_r bundled_app("vendor/bundle")
9999
bundle :check, raise_on_error: false
100100
expect(exitstatus).to eq 1
101101
expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
@@ -281,7 +281,7 @@
281281
G
282282
bundle "install --path vendor/bundle"
283283

284-
FileUtils.rm_rf(bundled_app(".bundle"))
284+
FileUtils.rm_r(bundled_app(".bundle"))
285285
end
286286

287287
it "returns success" do
@@ -328,7 +328,7 @@
328328
end
329329

330330
it "shows what is missing with the current Gemfile if it is not satisfied" do
331-
FileUtils.rm_rf default_bundle_path
331+
FileUtils.rm_r default_bundle_path
332332
system_gems :bundler
333333
bundle :check, raise_on_error: false
334334
expect(err).to match(/The following gems are missing/)

spec/bundler/commands/clean_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ def should_not_have_gems(*gems)
352352
bundle "install"
353353

354354
FileUtils.rm(vendored_gems("bin/myrackup"))
355-
FileUtils.rm_rf(vendored_gems("gems/thin-1.0"))
356-
FileUtils.rm_rf(vendored_gems("gems/myrack-1.0.0"))
355+
FileUtils.rm_r(vendored_gems("gems/thin-1.0"))
356+
FileUtils.rm_r(vendored_gems("gems/myrack-1.0.0"))
357357

358358
bundle :clean
359359

spec/bundler/commands/exec_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def require(path)
12641264
end
12651265

12661266
it "allows calling bundle install after removing gem.build_complete" do
1267-
FileUtils.rm_rf Dir[bundled_app(".bundle/**/gem.build_complete")]
1267+
FileUtils.rm_r Dir[bundled_app(".bundle/**/gem.build_complete")]
12681268
bundle "exec #{Gem.ruby} -S bundle install"
12691269
end
12701270
end

spec/bundler/commands/info_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
end
7171

7272
it "warns if path does not exist on disk, but specification is there" do
73-
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
73+
FileUtils.rm_r(default_bundle_path("gems", "rails-2.3.2"))
7474

7575
bundle "info rails --path"
7676

spec/bundler/commands/install_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
gem 'myrack'
101101
G
102102

103-
FileUtils.rm_rf(default_bundle_path("gems/myrack-1.0.0"))
103+
FileUtils.rm_r(default_bundle_path("gems/myrack-1.0.0"))
104104

105105
bundle "install --verbose"
106106

@@ -337,13 +337,13 @@
337337
it "allows running bundle install --system without deleting foo", bundler: "< 3" do
338338
bundle "install --path vendor"
339339
bundle "install --system"
340-
FileUtils.rm_rf(bundled_app("vendor"))
340+
FileUtils.rm_r(bundled_app("vendor"))
341341
expect(the_bundle).to include_gems "myrack 1.0"
342342
end
343343

344344
it "allows running bundle install --system after deleting foo", bundler: "< 3" do
345345
bundle "install --path vendor"
346-
FileUtils.rm_rf(bundled_app("vendor"))
346+
FileUtils.rm_r(bundled_app("vendor"))
347347
bundle "install --system"
348348
expect(the_bundle).to include_gems "myrack 1.0"
349349
end

spec/bundler/commands/outdated_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def test_group_option(group)
417417
end
418418

419419
it "doesn't hit repo2" do
420-
FileUtils.rm_rf(gem_repo2)
420+
FileUtils.rm_r(gem_repo2)
421421

422422
bundle "outdated --local"
423423
expect(out).not_to match(/Fetching (gem|version|dependency) metadata from/)

spec/bundler/commands/show_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
end
3737

3838
it "warns if specification is installed, but path does not exist on disk" do
39-
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
39+
FileUtils.rm_r(default_bundle_path("gems", "rails-2.3.2"))
4040

4141
bundle "show rails"
4242

0 commit comments

Comments
 (0)