diff options
author | Ellen Marie Dash <the@smallest.dog> | 2019-08-17 04:45:09 +0000 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-09-26 17:48:00 +0900 |
commit | 508afe2c26737e0be60a72faa9d6740a06b0914c (patch) | |
tree | b912da8888b6d1b476b8fdc67562cbf9b3b9cdef /test/rubygems/test_gem_package.rb | |
parent | 8436b2717c458a554dd81456a8e6e030e2c3e038 (diff) |
[rubygems/rubygems] Set SOURCE_DATE_EPOCH env var if not provided.
Fixes #2290.
1. `Gem::Specification.date` returns SOURCE_DATE_EPOCH when defined,
2. this commit makes RubyGems set it _persistently_ when not provided.
This combination means that you can build a gem, check the build time,
and use that value to generate a new build -- and then verify they're
the same.
https://github.com/rubygems/rubygems/commit/d830d53f59
Diffstat (limited to 'test/rubygems/test_gem_package.rb')
-rw-r--r-- | test/rubygems/test_gem_package.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index f2f712ebe0..a282e0cc5f 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -2,6 +2,7 @@ # frozen_string_literal: true require 'rubygems/package/tar_test_case' +require 'digest' class TestGemPackage < Gem::Package::TarTestCase @@ -123,6 +124,32 @@ class TestGemPackage < Gem::Package::TarTestCase ENV["SOURCE_DATE_EPOCH"] = epoch end + def test_build_time_source_date_epoch_automatically_set + epoch = ENV["SOURCE_DATE_EPOCH"] + ENV["SOURCE_DATE_EPOCH"] = nil + + start_time = Time.now.utc.to_i + + spec = Gem::Specification.new 'build', '1' + spec.summary = 'build' + spec.authors = 'build' + spec.files = ['lib/code.rb'] + spec.rubygems_version = Gem::Version.new '0' + + package = Gem::Package.new spec.file_name + + end_time = Time.now.utc.to_i + + assert package.build_time.is_a?(Time) + + build_time = package.build_time.to_i + + assert(start_time <= build_time) + assert(build_time <= end_time) + ensure + ENV["SOURCE_DATE_EPOCH"] = epoch + end + def test_add_files spec = Gem::Specification.new spec.files = %w[lib/code.rb lib/empty] |