Skip to content

Commit

Permalink
fix: open /dev/null with read write permissions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hacdias committed Aug 22, 2023
1 parent 971a665 commit 9517bad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/ipfs/runmain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 9517bad

Please sign in to comment.