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

archive/zip: possibly useless test #28700

ainar-g opened this issue Nov 9, 2018 · 3 comments


None yet
7 participants
Copy link

commented Nov 9, 2018

While playing around with the new vet and its nilness check, I have found an interesting bug. In src/archive/zip/reader_test.go:985 we have a test for #10956, but the test doesn't actually check anything:

_, err := NewReader(bytes.NewReader(data), int64(len(data)))
if err == nil && !strings.Contains(err.Error(), want) {
	t.Errorf("error = %v; want %q", err, want)

It should obviously be if err != nil && … here. But when I changed it, the test failed, because it returned ErrFormat instead of the custom Errorf'd error that was expected. I ran all of the package zip's tests with -cover and the coverage profile shows that the branch in (*Reader).init is never taken.


This comment has been minimized.

Copy link

commented May 31, 2019

It seems that fix applied for #10956 (that I reviewed and approved) wasn't actually a fix; maybe in theory, but it was never tested in practice.

As you say, the example that @dvykov provided doesn't seem to get past the readDirectoryEnd function, so the additional check added to the init method is never reached. I sent a change.


This comment has been minimized.

Copy link

commented May 31, 2019

Change mentions this issue: archive/zip: remove unused special case


This comment has been minimized.

Copy link

commented Jun 9, 2019

Thank you @ainar-g for the report and @adg for jumping on this and sending the fixing CL!
As per the wait-release tag added to the CL, it seems like this is punted to Go1.14. I shall update here accordingly and add the Early-In-Cycle tag too.

@odeke-em odeke-em modified the milestones: Go1.13, Go1.14 Jun 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.