From dd459d233967c5741bb4168e303b0ddfa8b29444 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 15 Aug 2023 15:57:42 +0200 Subject: [PATCH] fix: open /dev/null with read write permissions The way we create the kubo binary for coverage is very hacky. It uses the testing tool. In order to simulate a Kubo binary, we need to supress all the output that would otherwise be printed by 'go test'. So far, we were setting os.Stdout and os.Stderr as a read-only /dev/null file descriptor. This is causing issues with the new versions of Go: error generating coverage report: write /dev/null: bad file descriptor exit status 2 Updating it to a Read-Write file descriptor solves the problem. I did not try looking into what is causing this issue now. There have been some updates to the 'go test' tool in Go 1.20 and it is likely that some error is now being checked for that hasn't been checked before. Writing to a read-only file descriptor always failed. But the error was just supressed somehow. --- cmd/ipfs/runmain_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ipfs/runmain_test.go b/cmd/ipfs/runmain_test.go index 4d73cfd4366..c9f3f01982e 100644 --- a/cmd/ipfs/runmain_test.go +++ b/cmd/ipfs/runmain_test.go @@ -24,7 +24,7 @@ func TestRunMain(t *testing.T) { } // close outputs so go testing doesn't print anything - null, _ := os.Open(os.DevNull) + null, _ := os.OpenFile(os.DevNull, os.O_RDWR, 0755) os.Stderr = null os.Stdout = null }