Fossil Forum

Failing test cases for wiki & stash
Login

Failing test cases for wiki & stash

(1) By anonymous on 2021-09-28 10:38:11 [source]

Wiki test

The wiki tests currently fail in wiki-10. This is due to change 88e5336007.

Solution 1

Adding a !fTechnote makes the test pass again, but still references a non-existant column in that query (where wrid is assigned).

Index: src/wiki.c
==================================================================
--- src/wiki.c
+++ src/wiki.c
@@ -2439,11 +2439,11 @@
       );
     }
     while( db_step(&q)==SQLITE_ROW ){
       const char *zName = db_column_text(&q, 0);
       const int wrid = db_column_int(&q, 2);
-      if(!showAll && !wrid){
+      if(!showAll && !wrid && !fTechnote){
         continue;
       }
       if( showIds ){
         const char *zUuid = db_column_text(&q, 1);
         fossil_print("%s ",zUuid);

Solution 2

Another option would be to add an additional column to the query in the fTechnote!=1 case which is always 1.

Index: src/wiki.c
==================================================================
--- src/wiki.c
+++ src/wiki.c
@@ -2428,11 +2428,11 @@
     verify_all_options();
     if (fTechnote==0){
       db_prepare(&q, listAllWikiPages/*works-like:""*/);
     }else{
       db_prepare(&q,
-        "SELECT datetime(e.mtime), substr(t.tagname,7)"
+        "SELECT datetime(e.mtime), substr(t.tagname,7), 1"
          " FROM event e, tag t"
         " WHERE e.type='e'"
           " AND e.tagid IS NOT NULL"
           " AND t.tagid=e.tagid"
         " ORDER BY e.mtime DESC /*sort*/"

Stash test

The other failing test is in stash-1-show. This is due to change ed06585f41ee2ace. The reason is that the SELECTs in stash_apply and stash_pop match the hash column to blob.uuid, but hash is NULL in the case of added files. A possible solution is this:

Index: src/stash.c
==================================================================
--- src/stash.c
+++ src/stash.c
@@ -308,12 +308,14 @@
 static void stash_apply(int stashid, int nConflict){
   int vid;
   Stmt q;
   db_prepare(&q,
      "SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
-     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
-     stashid
+     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash"
+     " UNION ALL SELECT 0, isRemoved, isExec, isLink, origname, newname, delta"
+     "  FROM stashfile WHERE stashid=%d AND stashfile.hash IS NULL",
+     stashid, stashid
   );
   vid = db_lget_int("checkout",0);
   db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
                 filename_collation());
   while( db_step(&q)==SQLITE_ROW ){
@@ -412,12 +414,14 @@
   int bWebpage = (pCfg->diffFlags & (DIFF_WEBPAGE|DIFF_JSON|DIFF_TCL))!=0;
   blob_zero(&empty);
   diff_begin(pCfg);
   db_prepare(&q,
      "SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
-     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
-     stashid
+     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash"
+     " UNION ALL SELECT 0, isRemoved, isExec, isLink, origname, newname, delta"
+     "  FROM stashfile WHERE stashid=%d AND stashfile.hash IS NULL",
+     stashid, stashid
   );
   while( db_step(&q)==SQLITE_ROW ){
     int rid = db_column_int(&q, 0);
     int isRemoved = db_column_int(&q, 1);
     int isLink = db_column_int(&q, 3);

(2) By Stephan Beal (stephan) on 2021-09-28 12:07:26 in reply to 1 [link] [source]

The wiki tests currently fail in wiki-10. This is due to change 88e5336007.

Thank you! Here's an alternative fix:

Index: src/wiki.c
==================================================================
--- src/wiki.c
+++ src/wiki.c
@@ -2428,11 +2428,11 @@
     verify_all_options();
     if (fTechnote==0){
       db_prepare(&q, listAllWikiPages/*works-like:""*/);
     }else{
       db_prepare(&q,
-        "SELECT datetime(e.mtime), substr(t.tagname,7)"
+        "SELECT datetime(e.mtime), substr(t.tagname,7), e.objid"
          " FROM event e, tag t"
         " WHERE e.type='e'"
           " AND e.tagid IS NOT NULL"
           " AND t.tagid=e.tagid"
         " ORDER BY e.mtime DESC /*sort*/"

Because that query sorts newest first, e.objid (blob.rid of the technote) will give the equivalent result as that column gets for the wiki page query case.

i'll have that checked in momentarily.

Thank you for the report!

(3) By anonymous on 2021-10-04 12:19:18 in reply to 2 [link] [source]

Thanks!

What about the stash test?

(4) By anonymous on 2021-10-11 08:16:58 in reply to 1 [link] [source]

Stash test are still failing with the newest version 1dc5e1ce6d. This still makes them pass again.

Index: src/stash.c
==================================================================
--- src/stash.c
+++ src/stash.c
@@ -308,12 +308,14 @@
 static void stash_apply(int stashid, int nConflict){
   int vid;
   Stmt q;
   db_prepare(&q,
      "SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
-     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
-     stashid
+     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash"
+     " UNION ALL SELECT 0, isRemoved, isExec, isLink, origname, newname, delta"
+     "  FROM stashfile WHERE stashid=%d AND stashfile.hash IS NULL",
+     stashid, stashid
   );
   vid = db_lget_int("checkout",0);
   db_multi_exec("CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)",
                 filename_collation());
   while( db_step(&q)==SQLITE_ROW ){
@@ -412,12 +414,14 @@
   int bWebpage = (pCfg->diffFlags & (DIFF_WEBPAGE|DIFF_JSON|DIFF_TCL))!=0;
   blob_zero(&empty);
   diff_begin(pCfg);
   db_prepare(&q,
      "SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
-     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
-     stashid
+     "  FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash"
+     " UNION ALL SELECT 0, isRemoved, isExec, isLink, origname, newname, delta"
+     "  FROM stashfile WHERE stashid=%d AND stashfile.hash IS NULL",
+     stashid, stashid
   );
   while( db_step(&q)==SQLITE_ROW ){
     int rid = db_column_int(&q, 0);
     int isRemoved = db_column_int(&q, 1);
     int isLink = db_column_int(&q, 3);

(5) By anonymous on 2021-10-18 14:10:37 in reply to 4 [link] [source]

This fix has been tested on Alpine Linux and OpenBSD.

(6) By Stephan Beal (stephan) on 2021-10-19 04:12:16 in reply to 5 [link] [source]

This fix has been tested on Alpine Linux and OpenBSD.

Being completely unfamiliar with the stash internals, i'm extremely hesitant to go modify them based on an anonymous passer-by's word (no offense intended).

Can you explain (to someone who isn't well-versed in the stash internals) and/or justify why the stash code needs to be changed instead of the failing tests?