Skip to content

Commit

Permalink
[rubygems/rubygems] Clean up generated and copied files
Browse files Browse the repository at this point in the history
> leaving the files after gem rebuild was intentional, for local
> inspection, but the test suite should be made to clean up after
> itself independently of that.
rubygems/rubygems#4913 (comment)

rubygems/rubygems@185a2091fb
  • Loading branch information
nobu authored and matzbot committed May 16, 2024
1 parent 2aed14d commit 9d69619
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/rubygems/test_gem_commands_rebuild_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def util_test_rebuild_gem(gem, args, original_gem_file, gemspec_file, timestamp)
assert_equal old_spec.name, new_spec.name
assert_equal old_spec.summary, new_spec.summary

reproduced
[reproduced, original]
end

def test_build_is_reproducible
Expand Down Expand Up @@ -134,12 +134,21 @@ def test_build_is_reproducible
# also testing that `gem rebuild` overrides the value.
ENV["SOURCE_DATE_EPOCH"] = Time.new(2007, 8, 9, 10, 11, 12).to_s

rebuild_gem_file = util_test_rebuild_gem(@gem, [@gem_name, @gem_version], original_gem_file, gemspec_file, timestamp)
rebuild_gem_file, saved_gem_file =
util_test_rebuild_gem(@gem, [@gem_name, @gem_version], original_gem_file, gemspec_file, timestamp)

rebuild_contents = File.read(rebuild_gem_file)

assert_equal build_contents, rebuild_contents
ensure
ENV["SOURCE_DATE_EPOCH"] = epoch
if rebuild_gem_file
File.unlink(rebuild_gem_file)
dir = File.dirname(rebuild_gem_file)
Dir.rmdir(dir)
File.unlink(saved_gem_file)
Dir.rmdir(File.dirname(saved_gem_file))
Dir.rmdir(File.dirname(dir))
end
end
end

0 comments on commit 9d69619

Please sign in to comment.