-
Notifications
You must be signed in to change notification settings - Fork 124
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
Passing tests reported as failures in summary #141
Comments
But I also don't see an incomplete test here. It seems like If you can add a Are you running Does |
I believe we only started using this recently, and I'm not sure if it's from Adding thanks for the quick response! |
@chizhg has added this to our CI, so 🤞 |
We seem to be using master. We install via
|
Perfect! Here's what I'm seeing:
For some reason, From what I can tell, this is a new |
@dnephin if I wanted to try and fix this, where might I start looking? This has really been flaring up in recent runs of a suite I've been trying to stomp out flakes in, and so I'd love to see this fixed 😅 . I'd be happy to do some legwork here, I am just not sure what/where I'd need to get started. thanks for any pointers 🙏 |
The bug is likely somewhere in here: https://github.com/golang/go/blob/master/src/cmd/internal/test2json/test2json.go If it is related to parallelism some things to try might be to remove the I took a quick look on the golang issue tracker, but I did not see any reports of this problem. If we can reproduce it with a smaller test case opening an issue at https://github.com/golang/go/issues/new would be great. |
Alright, I got a little
Time to start aimlessly poking at this until it works! |
So the problem section is this sequence here:
The summary split with a |
Ah yes, that sounds right. Nice find! Kind of related to golang/go#38063 |
Unfortunately, I think this happens even without
I haven't cracked the artifacts, but I'd guess we'd see something similar to the test from yesterday. |
I had the same issue
in my case it was the issue where the ---PASS did not appear in a separate line i fixed the message before that to be adding extra \n new line and it pass |
I experienced the same issue. In my case, the failure was intermittent and when I was able to track down and compare the success cases from the failure cases, it was because there was a race between the test runner writing the pass output and a logging library writing a log line in a background goroutine that was in the process of being shutdown. The There doesn't seem to be a very elegant way to resolve this issue for projects that have a global logger. The recommendation would probably be to use This might not be quite a bug with this runner specifically, but it is manifesting in developers not trusting the output of the test runner because the test run will pass and the runner will show a failure. Wanted to share in case others come across a similar issue. |
I've worked with some projects that have a similar problem with logs and output. If you aren't running tests in parallel you can set the global logger to write to a buffer, and only print logs from the buffer when a test ends (or when a test fails). Then reset the logger back to the default afterward. func TestSomething(t *testing.T) {
patchLogger(t)
....
}
func patchLogger(t *testing.T) {
orig := log.Writer()
buf := new(bytes.Buffer)
log.SetOutput(buf)
t.Cleanup(func() {
// optionally check t.Failed here if you only want to print logs on failure
t.Log(buf.String())
log.SetOutput(orig)
})
} Another options would be to always set the log output to It would be nice if the go toolchain changed how the test binaries write framing events. If they were sent to a file or pipe then stdout/stderr would not mess with the tests results. |
I got a similar issue, here is the info ╰─ cat main_test.go
package main
import (
"fmt"
"testing"
)
func TestSth(t *testing.T) {
fmt.Printf("%s", "OK")
} ╰─ go test -v ./
=== RUN TestSth
OK--- PASS: TestSth (0.00s)
PASS
ok github.com/fatih/vim-go-tutorial 0.548s ╰─ gotestsum -f testname --debug ./
exec: [go test -json ./]
go test pid: 63519
PASS . (cached)
=== RUN TestSth
OK--- PASS: TestSth (0.00s)
FAIL TestSth (-1.00s)
=== Failed
=== FAIL: . TestSth (unknown)
OK--- PASS: TestSth (0.00s)
DONE 1 tests, 1 failure in 0.170s
when change the ouput line in test case everything is fine so maybe gotestsum can handle this situation. |
There is a related issue on the go issue tracker for output with missing newlines: golang/go#38063 It sounds like the Go team considers this a problem with the test, and it may not be fixed. How do you see |
The t.Parallel here could possibly cause test output swallow --- PASS, which is basically what all go test result to json output relies on. Related: gotestyourself/gotestsum#141
In my case, I managed to fix the passing-tests-but-reported-as-failed issue after adding a newline to stdin buffer read:
as otherwise output was "corrupted". Before:
After:
|
We are using
gotestsum
to run our testing for Knative, and digging into some recent "failures", I can't really make sense of whygotestsum
is reporting them as failed.The failure log I have been digging through can be downloaded from here, the file you want is "build-log.txt" (it is large).
In this test run I see the following summary:
However, if I scan back through the test logs, I see that all of the flavors of
TestContainerExitingMsg
have passed, here's one cluster:I've been trying to make sense of the pieces of information here, but basically all I've managed so far is that
(unknown)
seems to tell us that the elapsed time is unknown, which seems to point to a TestCase terminated by theend()
method here.Any pointers would be appreciated. 🙏
The text was updated successfully, but these errors were encountered: