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

test.vim: more efficient compiling of test files #1317

Merged
merged 1 commit into from
Jun 2, 2017
Merged

Conversation

fatih
Copy link
Owner

@fatih fatih commented Jun 2, 2017

This change improves the way we compile a Go test. Previously we would
build a test binary to catch any build errors. A callback was then
responsible to delete the test binary after showing build errors (if
there were any).

This could be racy though, because if the tests lasts long and we quit
early, the callback to clean the binary file would never run. So we
would end up with artifacts in our working directory.

To fix the issue we're going to tell to the go tool to run a specific,
unique function. We're passing a unique identifier as a function name
(which is a randomly generated), i.e:

go test -run "F97CC94D-4414-41CF-A185-A077F645DF24"
testing: warning: no tests to run
PASS
ok  	demo	0.006s

This will cause the go tool to build
the test file and then try to run the test function. Because there is no
such test function, it'll silently quit with zero exit status. As a side
effect it'll compile the test file, so we're able to catch any build
errors (if any)

fixes #907

This change improves the way we compile a Go test. Previously we would
build a test binary to catch any build errors. A callback was then
responsible to delete the test binary after showing build errors (if
there were any).

This could be racy though, because if the tests lasts long and we quit
early, the callback to clean the binary file would never run. So we
would end up with artifacts in our working directory.

To fix the issue we're going to tell to the `go` tool to run a specific,
unique function. We're passing a unique identifier as a function name
(which is a randomly generated), i.e:

```
go test -run "F97CC94D-4414-41CF-A185-A077F645DF24"
testing: warning: no tests to run
PASS
ok  	demo	0.006s
```

This will cause the go tool to build
the test file and then try to run the test function. Because there is no
such test function, it'll silently quit with zero exit status. As a side
effect it'll compile the test file, so we're able to catch any build
errors (if any)

fixes #907
@fatih fatih merged commit 196792d into master Jun 2, 2017
@fatih fatih deleted the test-compile branch June 2, 2017 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GoTestCompile not always deleting created test-binary with Neovim
1 participant