Add sleep to PTY tests to stabilize flaky failures (#12691)

This commit is contained in:
Naoto Ono 2025-02-03 16:07:19 +09:00 committed by GitHub
parent 890020e392
commit 8cbff4fe45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-02-03 07:07:42 +00:00
Merged-By: ono-max <onoto1998@gmail.com>

View File

@ -12,7 +12,7 @@ class TestPTY < Test::Unit::TestCase
RUBY = EnvUtil.rubybin RUBY = EnvUtil.rubybin
def test_spawn_without_block def test_spawn_without_block
r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"') r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"; sleep 0.1')
rescue RuntimeError rescue RuntimeError
omit $! omit $!
else else
@ -24,7 +24,7 @@ class TestPTY < Test::Unit::TestCase
end end
def test_spawn_with_block def test_spawn_with_block
PTY.spawn(RUBY, '-e', 'puts "b"') {|r,w,pid| PTY.spawn(RUBY, '-e', 'puts "b"; sleep 0.1') {|r,w,pid|
begin begin
assert_equal("b\r\n", r.gets) assert_equal("b\r\n", r.gets)
ensure ensure
@ -38,7 +38,7 @@ class TestPTY < Test::Unit::TestCase
end end
def test_commandline def test_commandline
commandline = Shellwords.join([RUBY, '-e', 'puts "foo"']) commandline = Shellwords.join([RUBY, '-e', 'puts "foo"; sleep 0.1'])
PTY.spawn(commandline) {|r,w,pid| PTY.spawn(commandline) {|r,w,pid|
begin begin
assert_equal("foo\r\n", r.gets) assert_equal("foo\r\n", r.gets)
@ -53,7 +53,7 @@ class TestPTY < Test::Unit::TestCase
end end
def test_argv0 def test_argv0
PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"') {|r,w,pid| PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"; sleep 0.1') {|r,w,pid|
begin begin
assert_equal("bar\r\n", r.gets) assert_equal("bar\r\n", r.gets)
ensure ensure