mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 07:48:55 +00:00
cli: flush coverage report in defer function
Do not flush it atexit(), where the test report file might be already closed and it causes go test failure like: PASS testing: can't write /tmp/go-build146132196/b001/testlog.txt: close /tmp/go-build146132196/b001/testlog.txt: file already closed FAIL github.com/kata-containers/runtime/cli 4.256s Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
f56d70ccd6
commit
3deb24e5de
@ -160,7 +160,9 @@ func TestMain(m *testing.M) {
|
|||||||
|
|
||||||
// Make sure we have the opportunity to flush the coverage report to disk when
|
// Make sure we have the opportunity to flush the coverage report to disk when
|
||||||
// terminating the process.
|
// terminating the process.
|
||||||
atexit(cover.FlushProfiles)
|
defer func() {
|
||||||
|
cover.FlushProfiles()
|
||||||
|
}()
|
||||||
|
|
||||||
// If the test binary name is kata-runtime.coverage, we've are being asked to
|
// If the test binary name is kata-runtime.coverage, we've are being asked to
|
||||||
// run the coverage-instrumented kata-runtime.
|
// run the coverage-instrumented kata-runtime.
|
||||||
|
Loading…
Reference in New Issue
Block a user