aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-03-14 13:27:52 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-17 18:50:55 +0900
commit37c2e903e89b9e2d7f1dc771da4143d9f041ef8f (patch)
treec8a3f4a6f88bbbe79b693ef0b0c7304cbb946ac2 /test
parent8371c0eac4432069ad16da081d36970b07ab7b09 (diff)
downloadruby-37c2e903e89b9e2d7f1dc771da4143d9f041ef8f.tar.gz
[rubygems/rubygems] Show error when `rake check_manifest` fails for unknown reason
https://github.com/rubygems/rubygems/commit/98de85c11e
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_project_sanity.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/rubygems/test_project_sanity.rb b/test/rubygems/test_project_sanity.rb
index aff7c66413..c0ef7f7056 100644
--- a/test/rubygems/test_project_sanity.rb
+++ b/test/rubygems/test_project_sanity.rb
@@ -5,11 +5,28 @@ require "open3"
class TestProjectSanity < Gem::TestCase
def test_manifest_is_up_to_date
- pend unless File.exist?(File.expand_path("../../Rakefile", __dir__))
+ pend unless File.exist?("#{root}/Rakefile")
_, status = Open3.capture2e("rake check_manifest")
- assert status.success?, "Expected Manifest.txt to be up to date, but it's not. Run `rake update_manifest` to sync it."
+ unless status.success?
+ original_contents = File.read("#{root}/Manifest.txt")
+
+ # Update the manifest to see if it fixes the problem
+ Open3.capture2e("rake update_manifest")
+
+ out, status = Open3.capture2e("rake check_manifest")
+
+ # If `rake update_manifest` fixed the problem, that was the original
+ # issue, otherwise it was an unknown error, so print the error output
+ if status.success?
+ File.write("#{root}/Manifest.txt", original_contents)
+
+ raise "Expected Manifest.txt to be up to date, but it's not. Run `rake update_manifest` to sync it."
+ else
+ raise "There was an error running `rake check_manifest`: #{out}"
+ end
+ end
end
def test_require_rubygems_package
@@ -17,4 +34,10 @@ class TestProjectSanity < Gem::TestCase
assert status.success?, err
end
+
+ private
+
+ def root
+ File.expand_path("../..", __dir__)
+ end
end