-
Notifications
You must be signed in to change notification settings - Fork 1
Avoid mutating global STDOUT & STDERR (#1837) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr_051_before
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ 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 | ||
|
|
@@ -19,8 +18,17 @@ def test_strings | |
| def test_stdio | ||
| events = Puma::Events.stdio | ||
|
|
||
| assert_equal STDOUT, events.stdout | ||
| assert_equal STDERR, events.stderr | ||
| # 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test does not restore STDOUT.sync global stateLow Severity The new |
||
| end | ||
|
|
||
| def test_register_callback_with_block | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test compares inspect strings that have different formats
Medium Severity
The
test_stdiotest comparesSTDOUT.inspectwithevents.stdout.inspect, butevents.stdoutis a dup of$stdout. In Ruby,STDOUT.inspecttypically returns#<IO:<STDOUT>>whileSTDOUT.dup.inspectreturns#<IO:fd 1>- different string formats that won't be equal. The test's approach of comparing inspect strings is unreliable for verifying the same file handle; comparingfilenovalues would be more robust.