Michael,

Thanks for your comments.

Michael G Schwern wrote:
[re-ordered slightly]
There's no example code in the SYNOPSIS.
>
Your example code which uses Test::Symlink should show how to set up the
plan.  Namely: use Test::Symlink tests => 2;
>
> It would be nice to see an example of the generated test name.
>
> Its not clear from the docs what the arguments being checked for
> sanity means.

Fixed those four in 0.02 which will be on CPAN shortly.

> I think you're using export_to_level() wrong.  $self should really be
> $class for starters.  And the way you're using it symlink_ok() always
> gets exported even if the user says "use Test::Symlink ()".  You
> should be passing it:
>
>    $class->export_to_level(1, $class, @_);
>
> except all the test stuff has to be stripped from @_ first like
> Test::More does.  Reason #9892 why I should get around to providing a
> canned import function in Test::Builder.

Hmm. The import() in Test::Symlink is exactly the same (mod s/ok/symlink_ok/) as the recommended import() from the Test::Builder SYNOPSIS (in Test::Simple 0.60).

Do you mean that the SYNOPSIS in Test::Builder is also wrong?

I think not verifying that the destination exists is a mistake as probably
the biggest issue with symlinks is the "dangling symlink" problem where you have set up a symlink to nowhere. I'd say for every case that you want a
dangling symlink there's 100 where you do not.  Make symlink_ok() do the
mostest thing (check that $dst exists) and have a dangling_symlink_ok()
function for that one special case you've dug up.  Makes the special case
nice and explicit.

I thought about that, but Test::File::file_exists_ok() handles that case (or just C< ok(-e $dst, "$dst exists"); >. Conceptually that seems to be the right way to do things, as these are two different tests:

  1.  Does $dst exist
  2.  Does $src symlink to it

There is an argument to be made about making the common operations as easy as possible, but I suspect that most uses of symlink_ok() are going to be after the tester has already conducted their own tests on $dst (does it exist, does it have the right permissions, is it owned by the correct user, and so on), so making carrying out these tests in symlink_ok() is superfluous.

"Small, sharp tools" and all that :-)

N

Reply via email to