kana / vim-vspec

Vim plugin: Testing framework for Vim script
http://www.vim.org/scripts/script.php?script_id=3012
222 stars 13 forks source link

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

Open glts opened 10 years ago

glts commented 10 years ago

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.

kana commented 10 years ago

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

By the way, I use prove

kana commented 10 years ago

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.

glts commented 10 years ago

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

glts commented 10 years ago

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:

kana commented 10 years ago

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.