Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:GoCoverage does return SUCCESS if no test files exists #859

Closed
fatih opened this issue May 17, 2016 · 9 comments
Closed

:GoCoverage does return SUCCESS if no test files exists #859

fatih opened this issue May 17, 2016 · 9 comments
Labels

Comments

@fatih
Copy link
Owner

fatih commented May 17, 2016

It should either assume the coverage is 0 or we should echo an error that :GoCoverage can't be run because there is no test files.

@fatih fatih added the bug label May 26, 2016
@tsne
Copy link
Contributor

tsne commented May 26, 2016

Hi,

how about adding the -o flag to go test and check if a binary was created or not? If there are no test files, no binary will be created. In this case we can print a message in the go#cmd#Test function.
For the coverage it is basically the same. We could check if the profile file was written.

@fatih fatih closed this as completed in 8e0ea12 Jun 2, 2016
@fatih
Copy link
Owner Author

fatih commented Jun 2, 2016

My fix is wrong, reverting :)

@fatih fatih reopened this Jun 2, 2016
@fatih
Copy link
Owner Author

fatih commented Jun 2, 2016

@tsne that sounds like a good plan to tackle. Or we just can check if there is any _test.go and abort if there is any.

@fatih fatih closed this as completed in 99e06a0 Jun 2, 2016
@fatih
Copy link
Owner Author

fatih commented Jun 2, 2016

@tsne this is now fixed. We just check if there is any _test.go files and abort. Let me know if it doesn't work for you :)

@tsne
Copy link
Contributor

tsne commented Jun 3, 2016

Hi @fatih.

The fix works fine for me. Thank you.

@mrnugget
Copy link
Contributor

mrnugget commented Jun 6, 2016

I think this change breaks the expected behaviour when running :GoTest ./.... I often open Vim from the root directory of a project, in which several subdirectories are Go packages. Running go test ./... in the root runs every test in every subdirectory -- even if no test files exist in the root directory.

:GoTest with ./... as argument checks if there are test files in the current/root directory and doesn't run any tests if there are none. Running the subdirectory test files is impossible without a *_test.go file in the root directory.

@fatih
Copy link
Owner Author

fatih commented Jun 6, 2016

@mrnugget good point. I'll change the check so it only covers :GoCoverage

@fatih
Copy link
Owner Author

fatih commented Jun 6, 2016

@mrnugget This is now fixed in master. Thanks for the feedback.

@mrnugget
Copy link
Contributor

mrnugget commented Jun 7, 2016

@fatih Thanks so much, that was fast :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants