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

Fix for Issue #222: handle EOF and offset correctly on read #224

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

IMSoP
Copy link

@IMSoP IMSoP commented Feb 26, 2020

The EOF flag on native file streams is only set after reading past the end of the stream, never on open or seek. Similarly, fread will never push the file position past the current end of the stream.

I have changed various tests which I believe were asserting behaviour that doesn't match the native implementation.

IMSoP and others added 3 commits February 25, 2020 22:33
The EOF flag on native file streams is only set after reading *past*
the end of the buffer, never on open or seek.

I believe all the failing tests here are asserting behaviour that
doesn't match the native file handler.
Testing with normal files show that fread() does not progress the
pointer beyond the end of the file, and a read *beyond* the file size is
required before feof() returns true.
@IMSoP
Copy link
Author

IMSoP commented Feb 26, 2020

Alternative implementation that applies on top of #221: refactor/rename_and_restructure...IMSoP:issue-222-rebase

Oddly, a bunch of the tests that my change caused to fail don't seem to exist on that branch.

@mikey179
Copy link
Member

Thanks! I think we should merge this after #221 is finished, as it reduces the points where seek functionality exists back to one. The other question for me is whether to backport it to the v1.x branch and do a bugfix release.

@mikey179
Copy link
Member

Alternative implementation that applies on top of #221: refactor/rename_and_restructure...IMSoP:issue-222-rebase

Oddly, a bunch of the tests that my change caused to fail don't seem to exist on that branch.

That's correct, as some functionality was removed/moved somewhere else the according specific tests aren't needed any more and have been removed. This is especially true for the seek functionality in the FileContent implementations, as #221 removes it from there.

@IMSoP
Copy link
Author

IMSoP commented Feb 26, 2020

Yeah, that makes sense.

I think to backport to 1.x, we'd need to also backport #220 (otherwise the streams all have the same offset anyway), so it needs a call on the risk and effort of that. If you think it is, I can rebase this branch onto 1.x, and open a new one for the master fix once #221 lands.

Regarding tests, it seems like too many of them were testing internal details that changed when refactoring, rather than the desired behaviour of the wrapper itself. If I get time, I'll raise a separate PR with some more test cases for calls to fseek, feof, etc based on what a real file stream would do.

@mikey179
Copy link
Member

I think to backport to 1.x, we'd need to also backport #220 (otherwise the streams all have the same offset anyway), so it needs a call on the risk and effort of that. If you think it is, I can rebase this branch onto 1.x, and open a new one for the master fix once #221 lands.

Having thought about it I believe it's not worth the effort, it's probably better to concentrate on 2.0.

If I get time, I'll raise a separate PR with some more test cases for calls to fseek, feof, etc based on what a real file stream would do.

That would be highly appreciated!

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

Successfully merging this pull request may close these issues.

2 participants