I have a test function TestJobqueue()
in https://github.com/VertebrateResequencing/wr/blob/develop/jobqueue/jobqueue_test.go that I can call in isolation: go test -tags netgo ./jobqueue -v -run 'TestJobqueue$'
.
I recently started getting test failures related to boltdb (one of my dependencies) bombing out with signal SIGBUS: bus error code
panics, or just normally failing tests because the database couldn't be opened. But only when working off an NFS mounted directory. Fair enough, I or boltdb have some kind of NFS-related bug.
But the thing I can't wrap my head around is that I only get these errors when an entirely different test function exists.
As per the comments in TestREST()
in https://github.com/VertebrateResequencing/wr/blob/92fb61ccd7819c8f1edfa8cce8468c4250d40ea7/jobqueue/rest_test.go, if I call Serve(serverConfig)
(a function in the package being tested, a function call which is made many times in TestJobqueue()
and other test functions) in that test function, TestJobqueue()
fails. If I don't, it doesn't.
In short, the failure of tests in one test function can be controlled by the value of a boolean in a test function that I'm not running.
How is this possible?
Edit: to address some points brought up by the first answer, TestJobqueue()
is being run in isolation. No other test runs before or after it. If the database file already exists, Serve()
results in those files being deleted first, then a new one created to run the new set of tests. The odd thing that I'm seeking an answer for is how an unexecuted function can have this side effect. I can demonstrate it is really unexecuted by beginning or ending TestREST()
with a panic
call: the output of that panic is never seen, but TestJobqueue()
failure can still be controlled by the boolean in TestREST()
(if the panic comes at the end).
Edit2: this turns out to be caused by an unusual thing I do in TestJobqueue()
, which is to call go test
on itself. Needless to say, if you do this, strange things can happen...