ConnorAtherton / rb-readline

Pure-Ruby Readline Implementation
BSD 3-Clause "New" or "Revised" License
248 stars 54 forks source link

Implement HISTORY.clear (Ruby trunk) #41

Open luislavena opened 13 years ago

luislavena commented 13 years ago

Right now testing against Ruby-trunk fails:

C:/Users/Luis/Projects/oss/ruby/test/readline/test_readline_history.rb:323:in `': undefined method `clear' for HISTORY:Class (NoMethodError)
        from C:/Users/Luis/Projects/oss/ruby/lib/rubygems/custom_require.rb:42:in `require'
        from C:/Users/Luis/Projects/oss/ruby/lib/rubygems/custom_require.rb:42:in `require'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:215:in `block in non_options'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:209:in `each'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:209:in `non_options'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:52:in `process_args'
        from C:/Users/Luis/Projects/oss/ruby/lib/minitest/unit.rb:767:in `run'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:21:in `run'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:585:in `run'
        from C:/Users/Luis/Projects/oss/ruby/lib/test/unit.rb:589:in `run'
        from ../../../../ruby/test/runner.rb:13:in `
'

Either implement it or raise NotImplementedError.

rocky commented 13 years ago

The problem isn't as simple as adding HISTORY.clear which is easily done by calling Rbreadline.clear_history or raising NotImplementedError. On 1.9 there are encoding issues and the test wants HISTORY a module, rather than a class.

See https://gist.github.com/963330

luislavena commented 13 years ago

Thank you @rocky !

I put this after giving a whirl to latest ruby-head and RubyInstaller with rb-readline. I knew it will have bigger implications that the current codebase do not provide or support.

Since is a new feature, perhaps we should discuss about it?

rocky commented 13 years ago

On Mon, May 9, 2011 at 4:47 PM, luislavena < reply@reply.github.com>wrote:

Thank you @rocky !

I put this after giving a whirl to latest ruby-head and RubyInstaller with rb-readline. I knew it will have bigger implications that the current codebase do not provide or support.

Since is a new feature, perhaps we should discuss about it?

Discussing is good. Suggest something.

Reply to this email directly or view it on GitHub: https://github.com/luislavena/rb-readline/issues/41#comment_1126178

Spakman commented 13 years ago

Cool - I didn't realise those tests were even there!

It would be nice to include them in the rb-readline repository (perhaps once we make them pass). Of course, this would introduces a slight headache to keep them up-to-date, but I think the benefits would outweigh that. What do you think?

luislavena commented 13 years ago

Well, test_readline.rb and test_readline_history.rb will not work directly with rb-readline because is expecting that readline works with redirected STDIN, something that rb-readline do not support, at least on Windows.

But, is worth the shot.

@rocky, as for the suggestion, I had discussed in the past having readline tests for rb-readline, but due the above issue was not possible.

Need to think a bit more on this but I'm leaving the door open for you guys to propose ideas :-)

rocky commented 13 years ago

Well, test_readline.rb and test_readline_history.rb will not work directly with rb-readline because is expecting that readline works with redirected STDIN, something that rb-readline do not support, at least on Windows.

Although something may not work everywhere, that is no reason not to use if it is useful somewhere. And as we have seen, the tests do not work even on platforms where STDIN is not a problem. So a suggestion is to use the tests when they can be run to help make better compatibility. Later, hopefully we will figure out either how to improve the code or the tests (or both) so they work on more platforms.

In my own projects I often have to take this approach: the solution I come up with is far from perfect or general. But it it is better than what was there or no solution. Later releases invariably hide the glaring flakiness or flaws in reasoning and glaring omissions. That is one reason I dislike looking at early releases of my code: they reflect how little I understood the problem and how poorly I coded the solution.

But in this way progress is made. Too often I have seen projects get stalled with no progress because one can not come up with a universal solution initially.

rdp commented 13 years ago

@luislavena you can force windows rbreadline to read from stdin...see my other comments...