diff options
author | Eric Wong <bofh@yhbt.net> | 2023-06-06 11:02:29 +0000 |
---|---|---|
committer | EW <bofh@yhbt.net> | 2023-06-20 10:38:47 +0000 |
commit | 76e1a91ec9c5b62bc65628c3e19a77a175f30f5c (patch) | |
tree | 05edb0b9ac73caa05d02bd3aeedd640adcf62690 /test/unit/test_tee_input.rb | |
parent | bd8289c824905d57316e9d9eb469267bc406b0ed (diff) | |
download | unicorn-76e1a91ec9c5b62bc65628c3e19a77a175f30f5c.tar.gz |
...by testing less. `env["rack.input"].gets' users are out-of-luck if they want anything other than "\n" or `nil', I suppose... `$/' is non-thread-local and thus non-thread-safe, which doesn't affect unicorn itself, but Ruby deprecates it for single-threaded code, too, unfortunately. Rack::Lint doesn't allow separator arguments for #gets, either, so we can't support that, either...
Diffstat (limited to 'test/unit/test_tee_input.rb')
-rw-r--r-- | test/unit/test_tee_input.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/test/unit/test_tee_input.rb b/test/unit/test_tee_input.rb index 4647e66..6f5bc8a 100644 --- a/test/unit/test_tee_input.rb +++ b/test/unit/test_tee_input.rb @@ -9,17 +9,16 @@ class TeeInput < Unicorn::TeeInput end class TestTeeInput < Test::Unit::TestCase - def setup - @rs = $/ @rd, @wr = Kgio::UNIXSocket.pair @rd.sync = @wr.sync = true @start_pid = $$ + @rs = "\n" + $/ == "\n" or abort %q{test broken if \$/ != "\\n"} end def teardown return if $$ != @start_pid - $/ = @rs @rd.close rescue nil @wr.close rescue nil begin @@ -37,38 +36,38 @@ class TestTeeInput < Test::Unit::TestCase end def test_gets_long - r = init_request("hello", 5 + (4096 * 4 * 3) + "#$/foo#$/".size) + r = init_request("hello", 5 + (4096 * 4 * 3) + "#{@rs}foo#{@rs}".size) ti = TeeInput.new(@rd, r) status = line = nil pid = fork { @rd.close 3.times { @wr.write("ffff" * 4096) } - @wr.write "#$/foo#$/" + @wr.write "#{@rs}foo#{@rs}" @wr.close } @wr.close line = ti.gets assert_equal(4096 * 4 * 3 + 5 + $/.size, line.size) - assert_equal("hello" << ("ffff" * 4096 * 3) << "#$/", line) + assert_equal("hello" << ("ffff" * 4096 * 3) << "#{@rs}", line) line = ti.gets - assert_equal "foo#$/", line + assert_equal "foo#{@rs}", line assert_nil ti.gets pid, status = Process.waitpid2(pid) assert status.success? end def test_gets_short - r = init_request("hello", 5 + "#$/foo".size) + r = init_request("hello", 5 + "#{@rs}foo".size) ti = TeeInput.new(@rd, r) status = line = nil pid = fork { @rd.close - @wr.write "#$/foo" + @wr.write "#{@rs}foo" @wr.close } @wr.close line = ti.gets - assert_equal("hello#$/", line) + assert_equal("hello#{@rs}", line) line = ti.gets assert_equal "foo", line assert_nil ti.gets |