Skip to content

Commit

Permalink
Merge pull request #113 from ruby/support-bundled-gems
Browse files Browse the repository at this point in the history
Support to become bundled gems
  • Loading branch information
hsbt authored Jan 10, 2025
2 parents b2c481c + fba3ee3 commit 663a27f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
6 changes: 5 additions & 1 deletion logger.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/logger"
spec.licenses = ["Ruby", "BSD-2-Clause"]

spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec", "BSDL", "COPYING"]
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 2.5.0"
Expand Down
22 changes: 12 additions & 10 deletions test/logger/test_logdevice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def stat
end

def setup
@top_dir = File.expand_path('../../lib', __dir__)
@tempfile = Tempfile.new("logger")
@tempfile.close
@filename = @tempfile.path
Expand Down Expand Up @@ -456,7 +457,7 @@ def test_shifting_size_not_rotate_too_much

def test_shifting_midnight
Dir.mktmpdir do |tmpdir|
assert_in_out_err([*%W"--disable=gems -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([*%W"--disable=gems -I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -498,7 +499,7 @@ class << Time

def test_shifting_weekly
Dir.mktmpdir do |tmpdir|
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -543,7 +544,7 @@ class << Time

def test_shifting_monthly
Dir.mktmpdir do |tmpdir|
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -588,7 +589,7 @@ class << Time

def test_shifting_dst_change
Dir.mktmpdir do |tmpdir|
assert_in_out_err([{"TZ"=>"Europe/London"}, *%W"--disable=gems -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([{"TZ"=>"Europe/London"}, *%W"--disable=gems -I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -627,7 +628,7 @@ class << Time

def test_shifting_weekly_dst_change
Dir.mktmpdir do |tmpdir|
assert_separately([{"TZ"=>"Europe/London"}, *%W"-rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_separately([{"TZ"=>"Europe/London"}, *%W"-I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -658,7 +659,7 @@ class << Time

def test_shifting_monthly_dst_change
Dir.mktmpdir do |tmpdir|
assert_separately([{"TZ"=>"Europe/London"}, *%W"-rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_separately([{"TZ"=>"Europe/London"}, *%W"-I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -707,7 +708,7 @@ class << Time

def test_shifting_midnight_exist_file
Dir.mktmpdir do |tmpdir|
assert_in_out_err([*%W"--disable=gems -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([*%W"--disable=gems -I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -751,7 +752,7 @@ class << Time

def test_shifting_weekly_exist_file
Dir.mktmpdir do |tmpdir|
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -798,7 +799,7 @@ class << Time

def test_shifting_monthly_exist_file
Dir.mktmpdir do |tmpdir|
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
assert_in_out_err([{"TZ"=>"UTC"}, *%W"-I#{@top_dir} -rlogger -C#{tmpdir} -"], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
begin
module FakeTime
Expand Down Expand Up @@ -848,7 +849,8 @@ class << Time
def run_children(n, args, src)
r, w = IO.pipe
[w, *(1..n).map do
f = IO.popen([EnvUtil.rubybin, *%w[--disable=gems -rlogger -], *args], "w", err: w)
f = IO.popen([EnvUtil.rubybin, *%w[--disable=gems -], *args], "w", err: w)
src = "$LOAD_PATH.unshift('#{@top_dir}'); require 'logger';#{src}"
f.puts(src)
f
end].each(&:close)
Expand Down

0 comments on commit 663a27f

Please sign in to comment.