Skip to content

testing/fstest: TestFS should return an unwrappable error #63675

@dolmen

Description

@dolmen

testing/fstest.TestFS reports a single error which is the concatenation of all errors. This doesn't allow to analyze the errors by unwraping using errors.Is or errors.As or calling Unwrap() []error.

See TestFS code: https://github.com/golang/go/blob/master/src/testing/fstest/testfs.go#L107

Instead TestFS should use errors.Join or a custom error that implements the Unwrap() []error method like errors.Join.

What version of Go are you using (go version)?

$ go version
go version go1.21.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes, on master branch.

Check code of the fsTester.errorf method:
https://github.com/golang/go/blob/master/src/testing/fstest/testfs.go#L107

What did you do?

I'm testing a filesystem that enforces permissions: https://github.com/dolmen-go/sqlar

I applied TestFS to a filesystem that returns fs.ErrPermission for ReadDir on multiple directories.

What did you expect to see?

I would like to analyze the errors using errors.Is to ignore expected fs.ErrPermission errors.

What did you see instead?

I got a big string containing the error messages concatenated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions