]> git.neil.brown.name Git - edlib.git/commitdiff
tests: filter out duplicate "Display" lines.
authorNeilBrown <neil@brown.name>
Sun, 28 May 2023 06:59:54 +0000 (16:59 +1000)
committerNeilBrown <neil@brown.name>
Thu, 8 Jun 2023 10:38:57 +0000 (20:38 +1000)
The 02-grep often duplicates some Display lines, apparently at random.
I don't know why and it doesn't show a display bug.
So filter them out to avoid unnecessary test failure.

Signed-off-by: NeilBrown <neil@brown.name>
display-ncurses.c
tests.d/01-hex
tests.d/02-grep

index e0a39736fd51f000bdeb10222c5cba0d6c092213..7cd08082905dfbd7d8433c957659756d037a454b 100644 (file)
@@ -80,6 +80,10 @@ struct display_data {
        FILE                    *log;
        FILE                    *input;
        int                     input_sleeping;
+       /* Sometimes I get duplicate Display lines, but not consistently.
+        * To avoid these, record last, filter repeats.
+        */
+       int                     last_cx, last_cy;
        char                    last_screen[MD5_DIGEST_SIZE*2+1];
        char                    next_screen[MD5_DIGEST_SIZE*2+1];
        /* The next event to generate when idle */
@@ -190,6 +194,7 @@ static void record_key(struct pane *p safe, char *key safe)
        else
                return;
        fprintf(dd->log, "Key %c%s%c\n", q,key,q);
+       dd->last_cx = -2; /* Force next Display to be shown */
        fflush(dd->log);
 }
 
@@ -208,6 +213,7 @@ static void record_mouse(struct pane *p safe, char *key safe, int x, int y)
        else
                return;
        fprintf(dd->log, "Mouse %c%s%c %d,%d\n", q,key,q, x, y);
+       dd->last_cx = -2; /* Force next Display to be shown */
        fflush(dd->log);
 }
 
@@ -244,13 +250,18 @@ static void record_screen(struct pane *p safe)
                                   (l+3) * sizeof(uint16_t));
                }
        md5_final_txt(&ctx, out);
-       if (dd->log) {
+       if (strcmp(out, dd->last_screen) == 0 &&
+            p->cx == dd->last_cx && p->cy == dd->last_cy) {
+               /* No  change - filter it */
+               dd->clears -= 1;
+       } else if (dd->log) {
                fprintf(dd->log, "Display %d,%d %s", p->w, p->h, out);
-               strcpy(dd->last_screen, out);
                if (p->cx >= 0)
                        fprintf(dd->log, " %d,%d", p->cx, p->cy);
                fprintf(dd->log, "\n");
                fflush(dd->log);
+               strcpy(dd->last_screen, out);
+               dd->last_cx = p->cx; dd->last_cy = p->cy;
        }
        if (dd->input && dd->input_sleeping) {
                char *delay = getenv("EDLIB_REPLAY_DELAY");
index 4746963a01d293c457a1a7fb538fddeba50f4ede..19803e41563f7955d68548b24cb8aad1b121731a 100644 (file)
@@ -33,26 +33,20 @@ Key ":C-S"
 Display 80,30 63A619FB970F4269EDAAD8EF6122E3E1 50,0
 Key "-C"
 Display 80,30 2ABE81D110E84CFC18C1A38321DA1A5A 51,0
-Display 80,30 2ABE81D110E84CFC18C1A38321DA1A5A 51,0
 Key "-H"
 Display 80,30 F1AD3F8DDA8B8B41183AA70269CA8ACC 52,0
-Display 80,30 F1AD3F8DDA8B8B41183AA70269CA8ACC 52,0
 Key "-E"
 Display 80,30 B4C136FD64B9726206E56B07D4BA88C8 53,0
-Display 80,30 B4C136FD64B9726206E56B07D4BA88C8 53,0
 Key "-C"
 Display 80,30 7F99135616B878E9C2D5AD5864C2D705 54,0
-Display 80,30 7F99135616B878E9C2D5AD5864C2D705 54,0
 Key "-K"
 Display 80,30 34255E04731117C91CED704659681715 55,0
-Display 80,30 34255E04731117C91CED704659681715 55,0
 Key ":Enter"
 Display 80,30 B68508FFA1672F54FDFAB5350572D055 17,9
 Key ":C-S"
 Display 80,30 CF2148CC2223862FFE807163F52C2148 50,0
 Key ":C-S"
 Display 80,30 0163AD7FBE7DCE00421EF281CE943420 55,0
-Display 80,30 0163AD7FBE7DCE00421EF281CE943420 55,0
 Key ":Enter"
 Display 80,30 82EB5416598294BB86C1831523354064 51,10
 Key ":A->"
@@ -89,4 +83,4 @@ Key ":C-X"
 Display 80,30 45BD9A363837C8B0DAF047FB0002FC1D 14,3
 Key ":C-C"
 Display 80,30 115B1A4CFA0E343777EA20394DC3932E 14,3
-Close 569
+Close 557
index ce6e45c3139bf315c8af0a002cf30422f89bd661..99b830f808e73a5381d9eb8da15e514a05679525 100644 (file)
@@ -59,7 +59,6 @@ Display 80,30 7AF880709F751AC18A0A603E089FA1A1 52,0
 Display 80,30 B0E22C222A207D5F527A3B111DC6D098 52,0
 Key "-n"
 Display 80,30 9588A0BE2448A07E087FB9AAF83AAD20 53,0
-Display 80,30 9588A0BE2448A07E087FB9AAF83AAD20 53,0
 Key ":Enter"
 Display 80,30 0AACF65EE47F78322E278C43FB3773A6 28,7
 Key ":A-."
@@ -243,4 +242,4 @@ Key ":C-X"
 Display 80,30 FA17B346317A69478E56D0FFAEE3BD13 1,7
 Key ":C-C"
 Display 80,30 C6ED20B5EF84117E136B0EEC0F58C031 1,7
-Close 866
+Close 862