Re: [MacPerl-Porters] Re: portability.pm (was Re: 1 while unlink "file")
[email protected] (Peter Prymmer)
| Newsgroups | perl.perl5.porters,perl.macperl.porters,perl.vmsperl |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 13 Sep 2001, Michael G Schwern wrote:
> The concern here is not that "unlink($file)" is less to type than "1
> while unlink($file)". The concern here is that I have to *know* that
> I have to use "1 while unlink($file)". This and dozens of other
> little tricks you need to know when writing test programs that are
> supposed to work on OS's you've probably never touched in your life.
> Not only that I have to know, but that everyone who writes tests has
> to know this.
>
> I'm trying to lower the barrier to writing core tests so we can get
> more people working on it. I'm also trying to clean them up. Right
> now, there's a lot of "do_weird_thing if $^O eq ..." scattered all
> over the tests. This frightens people.
>
> If we can encapsulate the bulk of this wonky logic, it makes for
> cleaner tests and it's less for people to need to learn, which means
> more people writing tests.
>
> Perhaps I should have suggested it not be called something as generic
> as portable.pm.
Yours is a fine and noble goal.
In all honesty I would recommend that you write:
unlink($file);
and thereby lower the barrier to writing more tests. In the unusual
cases (e.g. a file open()ed for write or append more than once) where the
C<1 while> VMS-ism would be needed in order to keep the VMS `mms test`
result a bit tidier than it ordinarily would have been (e.g. to
C<unlink("${file};1");>) then that could be added later by a vmsperler.
If it was not added then the worst case scenario has a few more temp files
lying about in the subdirectory know to VMSers as [.T]. That is not a big
deal. In most cases where you want to unlink() a temp file for testing
you can get away without the C<1 while> prependage.
Peter Prymmer