summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYusuke Nakamura <yusuke1994525@gmail.com>2025-05-03 23:59:41 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-05-08 18:03:04 +0900
commit819ecd115d663e5d0c7e1f14902f5bfde0a7414a (patch)
tree9f305345e33828e8cfadd4dd8a55c27704201731 /test
parent8685a81e6a0bdf7b766af930ee0e05a28e07d69b (diff)
[rubygems/rubygems] Add mtime to Gem::Package::TarWriter#add_file argument
Since 9e21dd9, Gem::Package::TarWriter#add_file adds the file to the tar with Gem.source_date_epoch for its mtime. This behavior breaks the code depending on the previous add_file behavior. Therefore, add_file accepts mtime as an argument, and uses Gem.source_date_epoch if not specified. https://github.com/rubygems/rubygems/commit/7020ea98a0
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_package_tar_writer.rb b/test/rubygems/test_gem_package_tar_writer.rb
index 67a9d0db43..7efe9cbc9f 100644
--- a/test/rubygems/test_gem_package_tar_writer.rb
+++ b/test/rubygems/test_gem_package_tar_writer.rb
@@ -50,6 +50,17 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
end
end
+ def test_add_file_with_mtime
+ Time.stub :now, Time.at(1_458_518_157) do
+ @tar_writer.add_file "x", 0o644, Time.now do |f|
+ f.write "a" * 10
+ end
+
+ assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
+ @io.string[0, 512])
+ end
+ end
+
def test_add_symlink
Time.stub :now, Time.at(1_458_518_157) do
@tar_writer.add_symlink "x", "y", 0o644