Skip to content

Commit

Permalink
Revert "Avoid mutating global STDOUT & STDERR (#1837)" (#1946)
Browse files Browse the repository at this point in the history
This reverts commit 70b28bb.
  • Loading branch information
nateberkopec committed Sep 5, 2019
1 parent 2fb0f27 commit 677f6b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/puma/events.rb
Expand Up @@ -29,8 +29,8 @@ def call(str)
#
def initialize(stdout, stderr)
@formatter = DefaultFormatter.new
@stdout = stdout.dup
@stderr = stderr.dup
@stdout = stdout
@stderr = stderr

@stdout.sync = true
@stderr.sync = true
Expand Down
14 changes: 3 additions & 11 deletions test/test_events.rb
Expand Up @@ -6,6 +6,7 @@ def test_null

assert_instance_of Puma::NullIO, events.stdout
assert_instance_of Puma::NullIO, events.stderr
assert_equal events.stdout, events.stderr
end

def test_strings
Expand All @@ -18,17 +19,8 @@ def test_strings
def test_stdio
events = Puma::Events.stdio

# events.stdout is a dup, so same file handle, different ruby object, but inspect should show the same file handle
assert_equal STDOUT.inspect, events.stdout.inspect
assert_equal STDERR.inspect, events.stderr.inspect
end

def test_stdio_respects_sync
STDOUT.sync = false
events = Puma::Events.stdio

assert !STDOUT.sync
assert events.stdout.sync
assert_equal STDOUT, events.stdout
assert_equal STDERR, events.stderr
end

def test_register_callback_with_block
Expand Down
1 change: 0 additions & 1 deletion test/test_tcp_logger.rb
Expand Up @@ -18,7 +18,6 @@ def test_events
# in lib/puma/launcher.rb:85
# Puma::Events is default tcp_logger for cluster mode
logger = Puma::Events.new(STDOUT, STDERR)
logger.instance_variable_set(:@stdout, $stdout) # ensure capture_process_io has access to the loggers output
out, err = capture_subprocess_io do
Puma::TCPLogger.new(logger, @server.app).call({}, @socket)
end
Expand Down

0 comments on commit 677f6b8

Please sign in to comment.