kgoess has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing unit tests on some code that deals with the filesystem, and I'd like to demonstrate the code path works when close $fh or die $! fails. Any suggestions on how to trigger a failure in close()?
The first idea that occurs to me is to create a tiny loopback filesystem and write too many bytes to it and try to close it, but I'm wondering if there's an easier way.
I was hoping I could do local *other::package::close = sub { return 0 } in my test, but that doesn't take at all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to make close() fail
by toolic (Bishop) on Sep 29, 2012 at 01:11 UTC | |
|
Re: how to make close() fail
by ikegami (Patriarch) on Sep 29, 2012 at 01:18 UTC | |
|
Re: how to make close() fail
by BrowserUk (Patriarch) on Sep 29, 2012 at 01:17 UTC | |
by dave_the_m (Monsignor) on Sep 29, 2012 at 09:22 UTC | |
by BrowserUk (Patriarch) on Sep 29, 2012 at 09:41 UTC | |
|
Re: how to make close() fail
by tobyink (Canon) on Sep 29, 2012 at 15:13 UTC | |
|
Re: how to make close() fail
by Anonymous Monk on Sep 29, 2012 at 01:05 UTC | |
|
Re: how to make close() fail
by pvaldes (Chaplain) on Sep 29, 2012 at 11:25 UTC |