in reply to Re: Keeping SKIP Test Blocks Under Control
in thread Keeping SKIP Test Blocks Under Control

ok( $mech->is_html, "Returns HTML" ) or skip "Didn't return HTML", 3;

That makes me want to write Test::Skip that wraps ok(), is(), like() and so on to avoid having to duplicate the test name. It'd be:

ok_or_skip( $mech->is_html, 'Returns HTML', 3 );

Replies are listed 'Best First'.
Re^3: Keeping SKIP Test Blocks Under Control
by adrianh (Chancellor) on Apr 12, 2004 at 18:44 UTC
    That makes me want to write Test::Skip that wraps ok(), is(), like() and so on to avoid having to duplicate the test name.

    Hmmm. Interesting thought. I think you could just get away with something like this:

    sub skip_unless (&$$) { my ($test, $name, $tests_to_skip) = @_; local $Test::Builder::Level = $Test::Builder::Level+1; my $passed; my $ok = \&Test::Builder::ok; { no warnings; local *Test::Builder::ok = sub { $_[2] = $name unless defined $_[2]; $ok->(@_); }; use warnings; $passed = $test->(); }; skip "failed: $name", $tests_to_skip unless $passed; return $passed; };

    allowing you to do things like:

    skip_unless { ok $mech->is_html } 'Returns HTML', 3; .... skip_unless { is $foo, $bar } 'foo == bar', 3; ...

    So you wouldn't have to have N different *_or_skip routines. Not sure whether this would deserve a module all of its own though...