Skip to content

Conversation

@fany
Copy link
Contributor

@fany fany commented Mar 13, 2025

Hi,

when my disk was full yesterday, I got a Can't locate object method "_throw" via package "self" (perhaps you forgot to load "self"?) at /usr/share/perl5/Path/Tiny.pm line … error. ☺︎

Kind regards,
Martin

@ap
Copy link
Contributor

ap commented Mar 13, 2025

Of course the real point is these slipped through because of the lack of tests that exercise them…

@fany
Copy link
Contributor Author

fany commented Mar 13, 2025

Actually I though about if I could write tests for that, but I don't have a good idea how one could do that, because this is e.g. the exception handling for the writing of data within the spew method, so unless you want to refactor the code in some fancy way I'm afraid you'd have to come up with a test where the open-ing of the file works but then the print fails, and I can only imagine that happening with a full disk.

@xdg xdg merged commit 6a3e486 into dagolden:master Mar 17, 2025
16 checks passed
@xdg
Copy link
Contributor

xdg commented Mar 17, 2025

Thanks!

@ap
Copy link
Contributor

ap commented Mar 17, 2025

I'm afraid you'd have to come up with a test where the open-ing of the file works but then the print fails, and I can only imagine that happening with a full disk.

Well, it depends. Some of the I/O operations are already written using some method call on a file handle. If the prints and closes etc. were also written that way then all that would be necessary to exercise those branches would be for the filehandle method to return an object with corresponding methods that return the appropriate errors. Or I think you could do it without touching the code by having filehandle return a tied handle that isn’t backed by an actual file handle, though that is slightly fiddlier.

@xdg Any interest in any of that?

@xdg
Copy link
Contributor

xdg commented Mar 17, 2025

No, I think that sort of error path testing is more effort than it's worth.

@fany fany deleted the fix_exception_handling branch March 17, 2025 14:23
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.

3 participants