vim-vspec icon indicating copy to clipboard operation
vim-vspec copied to clipboard

Make bin/vspec output unbuffered in order to make it possible to create shell wrappers

Open glts opened this issue 12 years ago • 5 comments

In the solution for #15 a final filter sed 's/\r$//' was added in bin/vspec.

Unfortunately, by default sed buffers its output, so it is no longer possible to add another filter and see the output live.

vspec . t/test.vim | grep '# TODO'
# have to wait until whole test is finished!

Making sed output unbuffered (sed -u) or line-buffered (sed -l) fixes the problem. Unfortunately there are many different sed flavours and not all of them have these flags.

The reason this is a problem for me is that I use a small benchmark wrapper around vspec, and the benchmark tests I run with it can take quite long. For one benchmark, for example, I have to wait 20 seconds until the whole thing is finished and I can see the benchmark results.

glts avatar Feb 08 '14 18:02 glts

Thank you for the report. I've confirmed the problem.

By the way, I use prove

kana avatar Feb 09 '14 11:02 kana

Oops, I accidentally posted halfway.

By the way, I use prove to run a bunch of test script. I think it does the same job as your vbench, because both are wrappers around bin/vspec. But prove gives me filtered output from bin/vspec at realtime, while bin/vspec ... | grep foo doesn't behave so. Therefore, there might be a workaround or a proper method to resolve this problem at the side of wrappers.

kana avatar Feb 09 '14 11:02 kana

This looks very promising. I will look inside Test::Harness when I get the chance.

glts avatar Feb 09 '14 13:02 glts

Today I tried prove, but I do not see any real-time output. It's the same as with any command-line filter. How did you do it? I did it like this:

prove -v -e 'vspec path/to/vspec path/to/myplugin' t/bench.vim

I searched around a bit for a solution. The answers I found all say that it isn't easily possible to unbuffer existing programs. The only way is to make the wrapper pretend to be a terminal.

I'm not sure if this problem is the responsibility of vspec or of the wrapper.

Interesting resources:

  • http://unix.stackexchange.com/q/25372
  • http://linux.die.net/man/1/unbuffer
  • http://linux.die.net/man/1/stdbuf
  • http://www.pixelbeat.org/programming/stdio_buffering/

glts avatar Mar 27 '14 13:03 glts

Ah... I'm sorry. I compared results of wrong commands. I ran

prove --exec 'vspec ...' -ext '.vim' | grep foo

rather than

prove --exec 'vspec ...' t/foo.vim | grep foo

to compare with vspec ... | grep foo. The former filters result from test scripts in t/, while the latter filters result from a single test script. So I misunderstood that prove gave me a real-time output. But prove does not output in real time for each test script, as you wrote.

kana avatar Apr 03 '14 12:04 kana