vendredi 22 septembre 2017

How can an uncalled test affect another in Go?

I have a test function TestJobqueue() in http://ift.tt/2xs367W 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 http://ift.tt/2wKXl1J, 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?

Aucun commentaire:

Enregistrer un commentaire