]> sipb.mit.edu Git - ikiwiki.git/commitdiff
use_pagespec: do not fail with error when unable to match, unless it fails
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 8 Oct 2009 22:47:48 +0000 (18:47 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 8 Oct 2009 22:47:48 +0000 (18:47 -0400)
with an ErrorReason

IkiWiki.pm
t/use_pagespec.t

index c787612e12e622174797609fe5337ff57586bf8a..c735b26c80e2800955e79730260d4e4cd1ce0b13 100644 (file)
@@ -1876,7 +1876,9 @@ sub use_pagespec ($$;@) {
                foreach my $i (keys %i) {
                        $depends_simple{$page}{lc $i} |= $i{$i};
                }
                foreach my $i (keys %i) {
                        $depends_simple{$page}{lc $i} |= $i{$i};
                }
-               error(sprintf(gettext("cannot match pages: %s"), $firstfail));
+
+               error(sprintf(gettext("cannot match pages: %s"), $firstfail))
+                       if $firstfail->isa("IkiWiki::ErrorReason");
        }
 
        return @ret;
        }
 
        return @ret;
index 7b904075ed477b58258f3318a19ab3273dfaf22f..92d7977cfd94ee0e7c672b5a1d1ce784d2bff6c6 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 64;
+use Test::More tests => 10;
 
 BEGIN { use_ok("IkiWiki"); }
 
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -24,7 +24,8 @@ is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 50)],
 is_deeply([use_pagespec("foo", "post/*", sort => "title",
                          limit => sub { $_[0] !~ /3/}) ],
        ["post/1", "post/2"]);
 is_deeply([use_pagespec("foo", "post/*", sort => "title",
                          limit => sub { $_[0] !~ /3/}) ],
        ["post/1", "post/2"]);
-eval { use_pagespec("foo", "beep") };
-ok($@, "fails with error when unable to match anything");
+my $r=eval { use_pagespec("foo", "beep") };
+ok(eval { use_pagespec("foo", "beep") } == 0);
+ok(! $@, "does not fail with error when unable to match anything");
 eval { use_pagespec("foo", "this is not a legal pagespec!") };
 ok($@, "fails with error when pagespec bad");
 eval { use_pagespec("foo", "this is not a legal pagespec!") };
 ok($@, "fails with error when pagespec bad");