summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-08 18:47:48 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-08 18:47:48 -0400
commitd5f014449511460d4da22591379b30bd5de86145 (patch)
treeaf91c90893c8487e2342e92d9ad7ff49a03a891b
parent1abbc6a4041e752fbec9b947a9d453b3b126c120 (diff)
use_pagespec: do not fail with error when unable to match, unless it fails
with an ErrorReason
-rw-r--r--IkiWiki.pm4
-rwxr-xr-xt/use_pagespec.t7
2 files changed, 7 insertions, 4 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index c787612e1..c735b26c8 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1876,7 +1876,9 @@ sub use_pagespec ($$;@) {
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;
diff --git a/t/use_pagespec.t b/t/use_pagespec.t
index 7b904075e..92d7977cf 100755
--- a/t/use_pagespec.t
+++ b/t/use_pagespec.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 64;
+use Test::More tests => 10;
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"]);
-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");