]> sipb.mit.edu Git - ikiwiki.git/commitdiff
added a test case for this bug
authorJoey Hess <joey@kitenet.net>
Thu, 22 Apr 2010 03:08:54 +0000 (23:08 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 22 Apr 2010 03:08:54 +0000 (23:08 -0400)
Further analysis suggests fixing this might not be as dreadful as I first
thought!

doc/bugs/depends_simple_mixup.mdwn
t/pagespec_match_list.t

index e7b48f802082e59e9e1d335c70ad426ebb12924a..79bfa8bdc9a1f538b961894c67004fc7de2b7346 100644 (file)
@@ -44,9 +44,11 @@ is modified to add the link, the regular dependency calculation code
 didn't notice, since the pagespec no longer matched.
 
 In this case, `depends_simple` needs to contain all pages
 didn't notice, since the pagespec no longer matched.
 
 In this case, `depends_simple` needs to contain all pages
-that do *not* match `link_done)`, but before my change, it contained
+that do *not* match `link(done)`, but before my change, it contained
 all pages that *do* match. After my change, it contained all pages.
 
 all pages that *do* match. After my change, it contained all pages.
 
+----
+
 So, seems what is needed is a way for influence info to be manipulated by
 the boolean operations that are applied. One way would be to have two
 sets of influences be returned, one for successful matches, and one for
 So, seems what is needed is a way for influence info to be manipulated by
 the boolean operations that are applied. One way would be to have two
 sets of influences be returned, one for successful matches, and one for
@@ -58,7 +60,25 @@ Then, when NOTting a `*Reason`, swap the two sets of influences.
 When ANDing/ORing, combine the individual sets. Querying the object for
 influences should return only the successful influences.
 
 When ANDing/ORing, combine the individual sets. Querying the object for
 influences should return only the successful influences.
 
-In light of this, commit f2b3d1341447cbf29189ab490daae418fbe5d02d seems
+----
+
+Would it be possible to avoid the complication of maintianing two sets of
+influence info? 
+
+Well, notice that the influence of `pagespec_match($page, "link(done)")`
+is $page. Iff the match succeeds.
+
+Also, the influence of `pagespec_match($page, "!link(done)")` is
+$page. Iff the (overall) match succeeds.
+
+Does that hold for all cases? If so, the code that populates
+`depends_simple` could just test if the pagespec was successful, and
+if not, avoid adding $page influences, while still adding any other, 
+non-$page influences.
+
+----
+
+Hmm, commit f2b3d1341447cbf29189ab490daae418fbe5d02d seems
 thuroughly wrong. So, what about influence info for other matches
 like `!author(foo)` etc? Currently, none is returned, but it should
 be a content influence. (Backlink influence data is ok.)
 thuroughly wrong. So, what about influence info for other matches
 like `!author(foo)` etc? Currently, none is returned, but it should
 be a content influence. (Backlink influence data is ok.)
index ee5d60f88d69a80d1f96ab9c513f677990ab1c2e..27546e6ca40c4c79b6d220b6ab19a7227e1a6f68 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 107;
+use Test::More tests => 115;
 
 BEGIN { use_ok("IkiWiki"); }
 
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -27,6 +27,8 @@ IkiWiki::checkconfig();
 $IkiWiki::pagectime{foo} = 2;
 $IkiWiki::pagectime{foo2} = 2;
 $IkiWiki::pagectime{foo3} = 1;
 $IkiWiki::pagectime{foo} = 2;
 $IkiWiki::pagectime{foo2} = 2;
 $IkiWiki::pagectime{foo3} = 1;
+$IkiWiki::pagectime{foo4} = 1;
+$IkiWiki::pagectime{foo5} = 1;
 $IkiWiki::pagectime{bar} = 3;
 $IkiWiki::pagectime{"post/1"} = 6;
 $IkiWiki::pagectime{"post/2"} = 6;
 $IkiWiki::pagectime{bar} = 3;
 $IkiWiki::pagectime{"post/1"} = 6;
 $IkiWiki::pagectime{"post/2"} = 6;
@@ -69,12 +71,28 @@ foreach my $spec ("* and link(bar)", "* or link(bar)") {
        ok($IkiWiki::depends{foo2}{$spec} & $IkiWiki::DEPEND_PRESENCE);
        ok(! ($IkiWiki::depends{foo2}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_LINKS)));
        ok($IkiWiki::depends_simple{foo2}{foo2} == $IkiWiki::DEPEND_LINKS);
        ok($IkiWiki::depends{foo2}{$spec} & $IkiWiki::DEPEND_PRESENCE);
        ok(! ($IkiWiki::depends{foo2}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_LINKS)));
        ok($IkiWiki::depends_simple{foo2}{foo2} == $IkiWiki::DEPEND_LINKS);
+       ok($IkiWiki::depends_simple{foo2}{foo} != $IkiWiki::DEPEND_LINKS);
        %IkiWiki::depends_simple=();
        %IkiWiki::depends=();
        pagespec_match_list("foo3", $spec, deptype => deptype("links"));
        ok($IkiWiki::depends{foo3}{$spec} & $IkiWiki::DEPEND_LINKS);
        ok(! ($IkiWiki::depends{foo3}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_PRESENCE)));
        ok($IkiWiki::depends_simple{foo3}{foo3} == $IkiWiki::DEPEND_LINKS);
        %IkiWiki::depends_simple=();
        %IkiWiki::depends=();
        pagespec_match_list("foo3", $spec, deptype => deptype("links"));
        ok($IkiWiki::depends{foo3}{$spec} & $IkiWiki::DEPEND_LINKS);
        ok(! ($IkiWiki::depends{foo3}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_PRESENCE)));
        ok($IkiWiki::depends_simple{foo3}{foo3} == $IkiWiki::DEPEND_LINKS);
+       ok($IkiWiki::depends_simple{foo3}{foo} != $IkiWiki::DEPEND_LINKS);
+       %IkiWiki::depends_simple=();
+       %IkiWiki::depends=();
+}
+# Above we tested that a link pagespec is influenced
+# by the pages that currently contain the link.
+
+# Oppositely, a pagespec that tests for pages that do not have a link
+# is not influenced by pages that currently contain the link, but
+# is instead influenced by pages that currently do not (but that
+# could be changed to have it).
+foreach my $spec ("* and !link(bar)", "* and !(!(!link(bar)))") {
+       pagespec_match_list("foo2", $spec);
+       ok($IkiWiki::depends_simple{foo2}{foo2} != $IkiWiki::DEPEND_LINKS);
+       ok($IkiWiki::depends_simple{foo2}{foo} == $IkiWiki::DEPEND_LINKS);
        %IkiWiki::depends_simple=();
        %IkiWiki::depends=();
 }
        %IkiWiki::depends_simple=();
        %IkiWiki::depends=();
 }