Bug #17128
closedtest_io_console.rb fails on actual console
Description
When running "make test-all TESTS=io/console/test_io_console" on the current Ruby source, the following error is generated if the test is run on the server console:
Run options:
--seed=37271
"--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems"
--excludes-dir=./test/excludes
--name=!/memory_leak/
Running tests:¶
- Error:
TestIO_Console#test_set_winsize_console:
Errno::EINVAL: Invalid argument - /dev/tty
/usr/local/src/ruby/test/io/console/test_io_console.rb:446:inwinsize=' /usr/local/src/ruby/test/io/console/test_io_console.rb:446:in
test_set_winsize_console'
Finished tests in 2.715363s, 9.2069 tests/s, 63.7116 assertions/s.
25 tests, 173 assertions, 0 failures, 1 errors, 0 skips
ruby -v: ruby 2.8.0dev (2020-08-21T07:01:46Z master 3eb76e747e) [x86_64-linux]
make: *** [yes-test-all] Error 1
The failing test is:¶
441 def test_set_winsize_console
442 set_winsize_setup
443 s = IO.console.winsize
444 assert_nothing_raised(TypeError) {IO.console.winsize = s}
445 bug = '[ruby-core:82741] [Bug #13888]'
446 IO.console.winsize = [s[0], s[1]+1]
447 assert_equal([s[0], s[1]+1], IO.console.winsize, bug)
448 IO.console.winsize = s
449 assert_equal(s, IO.console.winsize, bug)
450 ensure
451 set_winsize_teardown
452 end
Similar to lines 282-296, a possible fix might be:¶
441 def test_set_winsize_console
442 set_winsize_setup
443 s = IO.console.winsize
444 assert_nothing_raised(TypeError) {IO.console.winsize = s}
445 bug = '[ruby-core:82741] [Bug #13888]'
446 begin
447 IO.console.winsize = [s[0], s[1]+1]
448 assert_equal([s[0], s[1]+1], IO.console.winsize, bug)
449 rescue Errno::EINVAL # Error if run on an actual console.
450 else
451 IO.console.winsize = s
452 assert_equal(s, IO.console.winsize, bug)
453 end
454 ensure
455 set_winsize_teardown
456 end