chiark / gitweb /
@@@ wip misc
authorMark Wooding <mdw@distorted.org.uk>
Thu, 22 Feb 2024 19:49:15 +0000 (19:49 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 22 Feb 2024 19:49:47 +0000 (19:49 +0000)
test/tests.at
test/tvec-output.c

index fa4b1d8e2b82586d2cb50e7ac6046fae7060ce11..5c9c0690cbdac82c83a21f753bc75c98dde9c202 100644 (file)
@@ -70,7 +70,7 @@ $1 = $2
 check_template([BUILDDIR/t/tvec.t -fh tv], [2],
 [tv:$3: $4
 tv:={N:\d+}: required register `$1' not set in test `copy-$1'
-copy-$1: skipped: no tests to run
+copy-$1 skipped: no tests to run
 PASSED 0 tests in 0 groups (1 skipped)
 ERRORS found in input; tests may not have run correctly
 ],
index a4a4415647232d45a62043b546b6d34b3a609792..add820dbb4b4cea974c48d3165f5fb04c4fcfae7 100644 (file)
@@ -738,8 +738,8 @@ static const struct gprintf_ops human_printops =
 static void human_bsession(struct tvec_output *o, struct tvec_state *tv)
   { struct human_output *h = (struct human_output *)o; h->tv = tv; }
 
-static void human_report_unusual(struct human_output *h,
-                                unsigned nxfail, unsigned nskip)
+static void report_unusual(struct human_output *h,
+                          unsigned nxfail, unsigned nskip)
 {
   const char *sep = " (";
   unsigned f = 0;
@@ -781,18 +781,18 @@ static int human_esession(struct tvec_output *o)
     fprintf(h->lyt.fp, " %s%u %s",
            !(all_skip || grps_skip) ? "all " : "",
            all_pass, all_pass == 1 ? "test" : "tests");
-    human_report_unusual(h, all_xfail, all_skip);
+    report_unusual(h, all_xfail, all_skip);
     fprintf(h->lyt.fp, " in %u %s",
            grps_win, grps_win == 1 ? "group" : "groups");
-    human_report_unusual(h, 0, grps_skip);
+    report_unusual(h, 0, grps_skip);
   } else {
     setattr(h, HA_LOSE); fputs("FAILED", h->lyt.fp); setattr(h, HA_PLAIN);
     fprintf(h->lyt.fp, " %u out of %u %s",
            all_lose, all_run, all_run == 1 ? "test" : "tests");
-    human_report_unusual(h, all_xfail, all_skip);
+    report_unusual(h, all_xfail, all_skip);
     fprintf(h->lyt.fp, " in %u out of %u %s",
            grps_lose, grps_run, grps_run == 1 ? "group" : "groups");
-    human_report_unusual(h, 0, grps_skip);
+    report_unusual(h, 0, grps_skip);
   }
   fputc('\n', h->lyt.fp);
 
@@ -817,14 +817,13 @@ static void human_skipgroup(struct tvec_output *o,
 {
   struct human_output *h = (struct human_output *)o;
 
-  if (!(~h->f&(HOF_TTY | HOF_PROGRESS))) {
-    h->f &= ~HOF_PROGRESS;
-    putc(' ', h->lyt.fp);
-    setattr(h, HA_SKIP); fputs("skipped", h->lyt.fp); setattr(h, HA_PLAIN);
-  } else {
-    fprintf(h->lyt.fp, "%s: ", h->tv->test->name);
-    setattr(h, HA_SKIP); fputs("skipped", h->lyt.fp); setattr(h, HA_PLAIN);
+  if (!(h->f&HOF_TTY))
+    fprintf(h->lyt.fp, "%s ", h->tv->test->name);
+  else {
+    show_progress(h); h->f &= ~HOF_PROGRESS;
+    if (h->scoreboard.len) putc(' ', h->lyt.fp);
   }
+  setattr(h, HA_SKIP); fputs("skipped", h->lyt.fp); setattr(h, HA_PLAIN);
   if (excuse) { fputs(": ", h->lyt.fp); vfprintf(h->lyt.fp, excuse, *ap); }
   fputc('\n', h->lyt.fp);
 }
@@ -843,11 +842,11 @@ static void human_egroup(struct tvec_output *o)
   if (lose) {
     fprintf(h->lyt.fp, " %u/%u ", lose, run);
     setattr(h, HA_LOSE); fputs("FAILED", h->lyt.fp); setattr(h, HA_PLAIN);
-    human_report_unusual(h, xfail, skip);
+    report_unusual(h, xfail, skip);
   } else {
     fputc(' ', h->lyt.fp); setattr(h, HA_WIN);
     fputs("ok", h->lyt.fp); setattr(h, HA_PLAIN);
-    human_report_unusual(h, xfail, skip);
+    report_unusual(h, xfail, skip);
   }
   fputc('\n', h->lyt.fp);
 }
@@ -855,8 +854,6 @@ static void human_egroup(struct tvec_output *o)
 static void human_btest(struct tvec_output *o)
   { struct human_output *h = (struct human_output *)o; show_progress(h); }
 
-static void human_skip(struct tvec_output *o,
-                      const char *excuse, va_list *ap)
 {
   struct human_output *h = (struct human_output *)o;
   struct tvec_state *tv = h->tv;
@@ -864,24 +861,18 @@ static void human_skip(struct tvec_output *o,
   clear_progress(h);
   report_location(h, h->lyt.fp, tv->infile, tv->test_lno);
   fprintf(h->lyt.fp, "`%s' ", tv->test->name);
-  setattr(h, HA_SKIP); fputs("skipped", h->lyt.fp); setattr(h, HA_PLAIN);
-  if (excuse) { fputs(": ", h->lyt.fp); vfprintf(h->lyt.fp, excuse, *ap); }
+  setattr(h, attr); fputs(outcome, h->lyt.fp); setattr(h, HA_PLAIN);
+  if (detail) { fputs(": ", h->lyt.fp); vfprintf(h->lyt.fp, detail, *ap); }
   fputc('\n', h->lyt.fp);
 }
 
+static void human_skip(struct tvec_output *o,
+                      const char *excuse, va_list *ap)
+  { human_outcome(o, HA_SKIP, "skipped", excuse, ap); }
 static void human_fail(struct tvec_output *o,
                       const char *detail, va_list *ap)
-{
-  struct human_output *h = (struct human_output *)o;
-  struct tvec_state *tv = h->tv;
+  { human_outcome(o, HA_LOSE, "FAILED", detail, ap); }
 
-  clear_progress(h);
-  report_location(h, h->lyt.fp, tv->infile, tv->test_lno);
-  fprintf(h->lyt.fp, "`%s' ", tv->test->name);
-  setattr(h, HA_LOSE); fputs("FAILED", h->lyt.fp); setattr(h, HA_PLAIN);
-  if (detail) { fputs(": ", h->lyt.fp); vfprintf(h->lyt.fp, detail, *ap); }
-  fputc('\n', h->lyt.fp);
-}
 
 static void human_dumpreg(struct tvec_output *o,
                          unsigned disp, const union tvec_regval *rv,
@@ -1052,28 +1043,10 @@ static void tap_bsession(struct tvec_output *o, struct tvec_state *tv)
 {
   struct tap_output *t = (struct tap_output *)o;
 
-  t->tv = tv; t->last = 0;
+  t->tv = tv; t->grpix = 0;
   fputs("TAP version 13\n", t->lyt.fp); /* but secretly 14 really */
 }
 
-static unsigned tap_grpix(struct tap_output *t)
-{
-  struct tvec_state *tv = t->tv;
-  unsigned i, n;
-
-  for (n = 0, i = 0; i < TVOUT_LIMIT; i++) n += tv->grps[i];
-  return (n);
-}
-
-static unsigned tap_testix(struct tap_output *t)
-{
-  struct tvec_state *tv = t->tv;
-  unsigned i, n;
-
-  for (n = 0, i = 0; i < TVOUT_LIMIT; i++) n += tv->curr[i];
-  if (tv->f&TVSF_OPEN) n++;
-  return (n);
-}
 
 static int tap_esession(struct tvec_output *o)
 {
@@ -1087,7 +1060,7 @@ static int tap_esession(struct tvec_output *o)
     return (2);
   }
 
-  fprintf(t->lyt.fp, "1..%u\n", tap_grpix(t));
+  fprintf(t->lyt.fp, "1..%u\n", t->grpix);
   t->tv = 0; return (tv->all[TVOUT_LOSE] ? 1 : 0);
 }
 
@@ -1096,6 +1069,7 @@ static void tap_bgroup(struct tvec_output *o)
   struct tap_output *t = (struct tap_output *)o;
   struct tvec_state *tv = t->tv;
 
+  t->grpix++; t->testix = t->previx = 0;
   t->maxlen = register_maxnamelen(t->tv);
   fprintf(t->lyt.fp, "# Subtest: %s\n", tv->test->name);
 }
@@ -1105,8 +1079,8 @@ static void tap_skipgroup(struct tvec_output *o,
 {
   struct tap_output *t = (struct tap_output *)o;
 
-  fprintf(t->lyt.fp, "    1..%u\n", tap_testix(t));
-  fprintf(t->lyt.fp, "ok %u %s # SKIP", tap_grpix(t), t->tv->test->name);
+  fprintf(t->lyt.fp, "    1..%u\n", t->testix);
+  fprintf(t->lyt.fp, "ok %u %s # SKIP", t->grpix, t->tv->test->name);
   if (excuse) { fputc(' ', t->lyt.fp); vfprintf(t->lyt.fp, excuse, *ap); }
   fputc('\n', t->lyt.fp);
 }
@@ -1116,13 +1090,14 @@ static void tap_egroup(struct tvec_output *o)
   struct tap_output *t = (struct tap_output *)o;
   struct tvec_state *tv = t->tv;
 
-  fprintf(t->lyt.fp, "    1..%u\n", tap_testix(t));
+  fprintf(t->lyt.fp, "    1..%u\n", t->testix);
   fprintf(t->lyt.fp, "%s %u - %s\n",
          tv->curr[TVOUT_LOSE] ? "not ok" : "ok",
-         tap_grpix(t), tv->test->name);
+         t->grpix, tv->test->name);
 }
 
-static void tap_btest(struct tvec_output *o) { ; }
+static void tap_btest(struct tvec_output *o)
+  { struct tap_output *t = (struct tap_output *)o; t->testix++; }
 
 static void tap_outcome(struct tvec_output *o,
                        const char *head, const char *tail,
@@ -1130,14 +1105,14 @@ static void tap_outcome(struct tvec_output *o,
 {
   struct tap_output *t = (struct tap_output *)o;
   struct tvec_state *tv = t->tv;
-  unsigned ix = tap_testix(t);
 
   fprintf(t->lyt.fp, "    %s %u - %s:%u%s",
-         ix == t->last ? "##" : head, ix, tv->infile, tv->test_lno, tail);
+         t->testix == t->previx ? "##" : head,
+         t->testix, tv->infile, tv->test_lno, tail);
   if (detail)
     { fputc(' ', t->lyt.fp); vfprintf(t->lyt.fp, detail, *ap); }
   fputc('\n', t->lyt.fp);
-  t->last = ix;
+  t->previx = t->testix;
 }
 
 static void tap_skip(struct tvec_output *o, const char *excuse, va_list *ap)