kassio / neoterm

Wrapper of some vim/neovim's :terminal functions.
Other
1.32k stars 117 forks source link

go: can't test sub-packages #78

Closed mmlb closed 8 years ago

mmlb commented 8 years ago

having a file structure like:

foo/
  foo.go
  foo_test.go
  bar/
    bar.go
    bar_test.go

and $CWD == foo I would expect 'all' scope to rungo test ./... which will run tests for sub-packages, currently only go test is run which only runs tests in foo_test.go

But this also means that we can't test only foo as is currently done. Maybe there should be a new scope recursive? go can't possibly the only language that would have this problem...

kassio commented 8 years ago

Hello @mmlb! I know nothing of go lang, but I can tell you how it's configured in neoterm. :smile: It was introduced to neoterm to work only on the all and current scopes, it's not prepared to work with file scope. In allscope it just run go test on the current directory.

mmlb commented 8 years ago

Hey @kassio, so the problem here is that neoterm does not do the right thing. So in go you can define sub-packages within a repo. In the example I showed there are 2 packages, foo and bar. Running neoterm in all scope only the tests for the foo package are run. This is because go test is called vs go test ./... which a synonym for -r/--recursive in other tools.

But, now this shows another issue. What if I only want to run the test of the current package as is currently done...? Well that's the reason I mentioned a new scope, recursive, so that all means "all the tests in the current package", and recursive means "all tests in all packages".

kassio commented 8 years ago

As I said previously, I have no idea on how go test works. So I think is fair we ask @vhakulinen opinion, on this one, he was who introduced go lang support to neoterm. :smile:

vhakulinen commented 8 years ago

TIL: running go test ./<subpackage> runs tests on that package (but go test <subpackage> doesn't).

edit: I currently dont have time to implement these features (if there even is sane way to do it), but if you want you can check out vim-go which has commands for running test.

mmlb commented 8 years ago

Yeah vim-go is great, currently use it but neoterm looked like a nice way to run the tests. I don't have any VimL experience so can't implement myself. @kassio not sure if you want to keep this and #77 open in case some one else happens to come along...

kassio commented 8 years ago

I don't have problems in help with these people. I'd just like to know exactly how each scope should run. Given that I can update neoterm to run go tests as needed. :smile:

mmlb commented 8 years ago

So I think making file scope do go test ./$(dirname $file) (which I just learned about here, thanks @vhakulinen) would be great (I'd be happy to test). And now you could say that neoterm allows file scope for go programs (with a caveat being its actually package scope (one that I think most go users would actually expect)).

Which then means that all scope should actually call go test ./... which will recursively run all the tests.

vhakulinen commented 8 years ago

Further information: http://stackoverflow.com/questions/16935965/how-to-run-test-cases-in-a-specified-file

mmlb commented 8 years ago

hey @kassio cool fix, I guess I was thinking about how to implement just in vimscript. I'll give it a try soon. Thanks again.