Skip to content
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

testing/fstest: Glob generation fails on minus in directory name #44474

Open
cugu opened this issue Feb 21, 2021 · 1 comment
Open

testing/fstest: Glob generation fails on minus in directory name #44474

cugu opened this issue Feb 21, 2021 · 1 comment
Labels
Milestone

Comments

@cugu
Copy link

@cugu cugu commented Feb 21, 2021

fstest.TestFS generates a glob pattern (testfs.go#L294), but generates an incorrect one when the directory contains a minus.

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

$ go version
go version go1.16 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

func TestFS(t *testing.T) {
	fsys := fstest.MapFS{
		"a-b/a": &fstest.MapFile{},
	}
	if err := fstest.TestFS(fsys, "a-b/a"); err != nil {
		t.Error(err)
	}
}
go test ./...

What did you expect to see?

ok  	github.com/foo/bar	4.953s

What did you see instead?

go test ./...
--- FAIL: TestFS (0.00s)
    fs_test.go:16: TestFS found errors:
        a-b: Glob(`a[-][b-b]/*a*`): syntax error in pattern
FAIL
FAIL	github.com/foo/bar	4.052s
FAIL

CC @rsc

@ianlancetaylor ianlancetaylor added this to the Go1.17 milestone Feb 21, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Feb 21, 2021

Change https://golang.org/cl/294869 mentions this issue: testing/fstest: treat dash specially when building glob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants