-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
Ginkgo "corrupts" some global state when testing "package main" #305
Comments
Fastinating... I'll try to take a look soon. |
If you clone your repo and run:
then all subsequent invocations of Weird. I recommend opening an issue on go itself For now, I'm removing the |
Thank you @onsi On Sun, Oct 16, 2016 at 1:59 PM, Onsi Fakhouri [email protected]
Nikhil |
hey @nikhilm bad news. removing |
Thanks @onsi. Related, the Golang bug is also going to change this behavior in go 1.8 to not allow such imports. We will change our tests. |
I have a project that has certain functions in
package main
that I want to test. The tests are located in another directory. I am aware that this is bad style, and I should move the exported functions to another package and so on... but the fact is, it is something that works, until running ginkgo makes it not work.I have a reduced test case at https://github.com/nikhilm/ginkgo-broken that intentionally does not use any gomega specifics, to demonstrate the problem is in the
ginkgo
executable. Reproducing the README here.Reproduced on
Environment:
What is the problem?
When a
package main
exports some fields/functions that the test packageimports to test, ginkgo works fine on the first run, but fails on subsequent
runs. No global state seems to be modified, nor are new files created, so
I cannot figure out what is the cause. After the command is run,
go test
starts failing too.
Steps to Reproduce
These commands output:
Let's continue:
This works too:
But it has broken something, because from this point on:
leads to:
Expected output: tests should always pass
Once the ginkgo command is run, this directory is broken "forever". I have not
yet been able to isolate what leads to the go runtime considering it "fixed".
Things I've found that work as a "fix":
project/main.go
.Things I've found that do not work as a "fix":
test/project_test.go
The text was updated successfully, but these errors were encountered: