azawawi / raku-ncurses

Raku interface to NCurses library
MIT License
23 stars 9 forks source link

Breakage due to recent IO buffering change (missing .close?) #16

Closed AlexDaniel closed 7 years ago

AlexDaniel commented 7 years ago

One of the tests of this module is broken on HEAD. See https://gist.github.com/041296026d1624fbde86d17196ea8ec4.

Bisectable points to https://github.com/rakudo/rakudo/commit/4b02b8aadcb47072bc87fb8be8069177b74cd59d

Term::Choose, Term::Choose::Util, and Term::TablePrint depend on this module and therefore are shown as burnt in the toaster.

See also RT #132030.

Sister tickets:

AlexDaniel commented 7 years ago

Interestingly, it works if I remove endwin line. I don't really understand what's going on there.

geekosaur commented 7 years ago

What's going on there is that initscr() sets a flag for terminal init strings to be output on stdout, and endwin() outputs them followed by deinit sequences and a cursor move to the bottom left of the screen. This probably confuses prove, which is looking for test output.

This behavior will have been impacted by the changes to buffer noninteractive output, and the knock-on fix for buffers not being autoflushed when a handle is closed on going out of scope or the program ending.

For the purposes of a test, you either want to arrange for fd 1 to not be the pipe to prove, or you want to use newterm() to have curses write its init/deinit to some other file descriptor.

geekosaur commented 7 years ago

Note that, without the endwin call, the init/deinit sequences are not output at all. But on a real terminal, it's possible it would be left in an odd state. (Unlikely though; while curses/XTI compliant libraries are allowed to set things up however they want, in practice ncurses will generally obey crmode() and friends as written and leave the terminal in default mode otherwise.)

azawawi commented 7 years ago

Sorry for the delay on this one. Bug was fixed in rakudo latest by @AlexDaniel. Please reopen if you think otherwise 👍

AlexDaniel commented 7 years ago

Well, what changed is that we simply re-disabled output buffering in Test.pm6, this is why it works now. There wasn't really a bug in rakudo, or so it seems. But given that the test is passing I guess there's nothing to do here indeed. @azawawi++