|
7 | 7 | let(:source) { "http://localgemserver.test" } |
8 | 8 | let(:source2) { "http://gemserver.example.org" } |
9 | 9 |
|
| 10 | + def cache_base |
| 11 | + home(".bundle", "cache", "gems") |
| 12 | + end |
| 13 | + |
10 | 14 | def source_global_cache(*segments) |
11 | | - home(".bundle", "cache", "gems", "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", *segments) |
| 15 | + cache_base.join("localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", *segments) |
12 | 16 | end |
13 | 17 |
|
14 | 18 | def source2_global_cache(*segments) |
15 | | - home(".bundle", "cache", "gems", "gemserver.example.org.80.1ae1663619ffe0a3c9d97712f44c705b", *segments) |
| 19 | + cache_base.join("gemserver.example.org.80.1ae1663619ffe0a3c9d97712f44c705b", *segments) |
16 | 20 | end |
17 | 21 |
|
18 | 22 | it "caches gems into the global cache on download" do |
@@ -49,6 +53,39 @@ def source2_global_cache(*segments) |
49 | 53 | expect(err).to include("Gem::Package::FormatError: package metadata is missing in #{source_global_cache("myrack-1.0.0.gem")}") |
50 | 54 | end |
51 | 55 |
|
| 56 | + it "uses a shorter path for the cache to not hit filesystem limits" do |
| 57 | + install_gemfile <<-G, artifice: "compact_index", verbose: true |
| 58 | + source "http://#{"a" * 255}.test" |
| 59 | + gem "myrack" |
| 60 | + G |
| 61 | + |
| 62 | + expect(the_bundle).to include_gems "myrack 1.0.0" |
| 63 | + source_segment = "a" * 222 + ".a3cb26de2edfce9f509a65c611d99c4b" |
| 64 | + source_cache = cache_base.join(source_segment) |
| 65 | + cached_gem = source_cache.join("myrack-1.0.0.gem") |
| 66 | + expect(cached_gem).to exist |
| 67 | + ensure |
| 68 | + # We cleanup dummy files created by this spec manually because due to a |
| 69 | + # Ruby on Windows bug, `FileUtils.rm_rf` (run in our global after hook) |
| 70 | + # cannot traverse directories with such long names. So we delete |
| 71 | + # everything explicitly to workaround the bug. An alternative workaround |
| 72 | + # would be to shell out to `rm -rf`. That also works fine, but I went with |
| 73 | + # the more verbose and explicit approach. This whole ensure block can be |
| 74 | + # removed once/if https://bugs.ruby-lang.org/issues/21177 is fixed, and |
| 75 | + # once the fix propagates to all supported rubies. |
| 76 | + File.delete cached_gem |
| 77 | + Dir.rmdir source_cache |
| 78 | + |
| 79 | + File.delete compact_index_cache_path.join(source_segment, "info", "myrack") |
| 80 | + Dir.rmdir compact_index_cache_path.join(source_segment, "info") |
| 81 | + File.delete compact_index_cache_path.join(source_segment, "info-etags", "myrack-92f3313ce5721296f14445c3a6b9c073") |
| 82 | + Dir.rmdir compact_index_cache_path.join(source_segment, "info-etags") |
| 83 | + Dir.rmdir compact_index_cache_path.join(source_segment, "info-special-characters") |
| 84 | + File.delete compact_index_cache_path.join(source_segment, "versions") |
| 85 | + File.delete compact_index_cache_path.join(source_segment, "versions.etag") |
| 86 | + Dir.rmdir compact_index_cache_path.join(source_segment) |
| 87 | + end |
| 88 | + |
52 | 89 | describe "when the same gem from different sources is installed" do |
53 | 90 | it "should use the appropriate one from the global cache" do |
54 | 91 | bundle "config path.system true" |
|
0 commit comments