Project

General

Profile

Actions

Bug #13269

closed

test/readline/test_readline.rb and mingw

Added by MSP-Greg (Greg L) about 7 years ago. Updated 7 months ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-03-02 trunk 57755) [x64-mingw32]
[ruby-core:79877]
Tags:

Description

When running test-all on a mingw build, test_readline.rb generates failures and errors. Several of the errors are due to the with_temp_stdio method in test_readline.rb. It also leaves several undeleted files in the temp dir.

Current link is: TestReadline#with_temp_stdio

The current code is:

def with_temp_stdio
  Tempfile.create("test_readline_stdin") {|stdin|
    Tempfile.create("test_readline_stdout") {|stdout|
      yield stdin, stdout
    }
  }
end

Replacing it with the following solved the problems.

  def with_temp_stdio
    stdin =  Tempfile.new("test_readline_stdin")
    stdout = Tempfile.new("test_readline_stdout")
    yield stdin, stdout
    if stdout
      stdout.closed? ? stdout.unlink : stdout.close!
    end
    if stdin
      stdin.closed?  ? stdin.unlink  : stdin.close!
    end
  end

I can only test on Windows, but I assume the changed code would work on other os's. If someone could test it, I'd submit a PR. Maybe the code in Tempfile::Remover is really where the change should occur, but I haven't looked at that.

After this update, I only had one failure and three errors. Text below.

Odd thing for two errors it that they report NoMethodError: undefined method assert_separately, but the highlighted line is return if assert_under_utf8. I didn't do an exhaustive search, but I can't find a reference to that function. But, I'm pulling the test files out of ruby and running separately...

Failure: test_input_metachar(TestReadline)
D:/r_test/Readline/test_readline.rb:420:in `test_input_metachar'
     417:       wo = w.dup
     418:       wo.write("\C-re\ef\n")
     419:     end
  => 420:     assert_equal("hello", line, bug6601)
     421:   ensure
     422:     wo.close
     423:     Readline.delete_text
[ruby-core:45682]
<"hello">(UTF-8) expected but was
<"hfello">(IBM437)

diff:
? hfello

? Encoding: UTF-8
?           IBM437
====================================================================================================================================================
Error: test_input_metachar_multibyte(TestReadline):
  NoMethodError: undefined method `assert_separately' for #<TestReadline:0x00000003bcfef0>
  Did you mean?  assert_empty
D:/r_test/Readline/test_readline.rb:618:in `assert_under_utf8'
D:/r_test/Readline/test_readline.rb:429:in `test_input_metachar_multibyte'
     426:
     427:   def test_input_metachar_multibyte
     428:     unless Encoding.find("locale") == Encoding::UTF_8
  => 429:       return if assert_under_utf8
     430:       skip 'this test needs UTF-8 locale'
     431:     end
     432:     bug6602 = '[ruby-core:45683]'
====================================================================================================================================================
Error: test_refresh_line(TestReadline):
  NoMethodError: undefined method `assert_ruby_status' for #<TestReadline:0x00000003bcf6f8>
  Did you mean?  assert_raises
D:/r_test/Readline/test_readline.rb:459:in `block (2 levels) in test_refresh_line'
     456:     bug6232 = '[ruby-core:43957] [Bug #6232] refresh_line after set_screen_size'
     457:     with_temp_stdio do |stdin, stdout|
     458:       replace_stdio(stdin.path, stdout.path) do
  => 459:         assert_ruby_status(%w[-rreadline -], <<-'end;', bug6232)
     460:           Readline.set_screen_size(40, 80)
     461:           Readline.refresh_line
     462:         end;
D:/r_test/Readline/test_readline.rb:567:in `block (2 levels) in replace_stdio'
D:/r_test/Readline/test_readline.rb:557:in `open'
D:/r_test/Readline/test_readline.rb:557:in `block in replace_stdio'
D:/r_test/Readline/test_readline.rb:556:in `open'
D:/r_test/Readline/test_readline.rb:556:in `replace_stdio'
D:/r_test/Readline/test_readline.rb:458:in `block in test_refresh_line'
D:/r_test/Readline/test_readline.rb:583:in `with_temp_stdio'
D:/r_test/Readline/test_readline.rb:457:in `test_refresh_line'
====================================================================================================================================================
Error: test_using_quoting_detection_proc_with_multibyte_input(TestReadline):
  NoMethodError: undefined method `assert_separately' for #<TestReadline:0x00000003bcf2c0>
  Did you mean?  assert_empty
D:/r_test/Readline/test_readline.rb:618:in `assert_under_utf8'
D:/r_test/Readline/test_readline.rb:517:in `test_using_quoting_detection_proc_with_multibyte_input'
     514:     saved_completer_word_break_characters = Readline.completer_word_break_characters
     515:     return unless Readline.respond_to?(:quoting_detection_proc=)
     516:     unless Encoding.find("locale") == Encoding::UTF_8
  => 517:       return if assert_under_utf8
     518:       skip 'this test needs UTF-8 locale'
     519:     end
     520:

Updated by MSP-Greg (Greg L) about 7 years ago

  • ruby -v set to ruby 2.5.0dev (2017-03-02 trunk 57775) [x64-mingw32]

Updated by MSP-Greg (Greg L) about 7 years ago

  • ruby -v changed from ruby 2.5.0dev (2017-03-02 trunk 57775) [x64-mingw32] to ruby 2.5.0dev (2017-03-02 trunk 57755) [x64-mingw32]

Updated by shyouhei (Shyouhei Urabe) about 7 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Updated by jeremyevans0 (Jeremy Evans) 7 months ago

  • Status changed from Assigned to Closed

The readline extension was removed in 59fd67fc3d405e529e038172e769ff20a8fb5535. If this is still an issue, please file it upstream: https://github.com/ruby/readline-ext

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0