Started mapping filenames and line numbers back to their appropriate places in the tester.

This commit is contained in:
Pietro Gagliardi 2019-06-02 01:13:56 -04:00
parent 4ae6ab2727
commit 1cf545d369
2 changed files with 11 additions and 9 deletions

View File

@ -72,8 +72,7 @@ static void wantBlocked(struct handler *h)
h->wantBlocked = true; h->wantBlocked = true;
} }
// TODO carry over the file and line numbers somehow static void runFull(testingT *t, const char *file, long line, uiEvent *e, void *sender, void *args, struct handler *handlers, int n, int wantRunCount)
static void run(testingT *t, uiEvent *e, void *sender, void *args, struct handler *handlers, int n, int wantRunCount)
{ {
int i; int i;
int gotRunCount; int gotRunCount;
@ -89,9 +88,9 @@ static void run(testingT *t, uiEvent *e, void *sender, void *args, struct handle
h = handlers; h = handlers;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (!h->gotRun && h->wantRun) if (!h->gotRun && h->wantRun)
testingTErrorf(t, "%s not run; should have been", h->name); testingTErrorfFull(t, file, line, "%s not run; should have been", h->name);
else if (h->gotRun && !h->wantRun) else if (h->gotRun && !h->wantRun)
testingTErrorf(t, "%s run; should not have been", h->name); testingTErrorfFull(t, file, line, "%s run; should not have been", h->name);
if (h->gotRun && h->wantRun) { if (h->gotRun && h->wantRun) {
// only check these if it was correctly run, to reduce noise if the above failed // only check these if it was correctly run, to reduce noise if the above failed
if (h->gotSender != h->wantSender) if (h->gotSender != h->wantSender)
@ -105,9 +104,9 @@ static void run(testingT *t, uiEvent *e, void *sender, void *args, struct handle
// the following call will fail if the ID isn't valid // the following call will fail if the ID isn't valid
gotBlocked = uiEventHandlerBlocked(e, h->id); gotBlocked = uiEventHandlerBlocked(e, h->id);
if (!gotBlocked && h->wantBlocked) if (!gotBlocked && h->wantBlocked)
testingTErrorf(t, "%s not blocked; should have been", h->name); testingTErrorfFull(t, file, line, "%s not blocked; should have been", h->name);
else if (gotBlocked && !h->wantBlocked) else if (gotBlocked && !h->wantBlocked)
testingTErrorf(t, "%s blocked; should not have been", h->name); testingTErrorfFull(t, file, line, "%s blocked; should not have been", h->name);
} }
h++; h++;
} }
@ -116,6 +115,8 @@ static void run(testingT *t, uiEvent *e, void *sender, void *args, struct handle
"%d", gotRunCount, wantRunCount); "%d", gotRunCount, wantRunCount);
} }
#define run(t, e, sender, args, handlers, n, wantRunCount) runFull(t, __FILE__, __LINE__, e, sender, args, handlers, n, wantRunCount)
struct baseParams { struct baseParams {
void (*impl)(testingT *t, void *data); void (*impl)(testingT *t, void *data);
bool global; bool global;

View File

@ -109,8 +109,7 @@ static void queueOrder(struct testParams *p)
uiQueueMain(done, NULL); uiQueueMain(done, NULL);
} }
// TODO somehow funnel the caller's file/line through static void checkOrderFull(testingT *t, const char *file, long line, uint32_t flag)
static void checkOrder(testingT *t, uint32_t flag)
{ {
int i; int i;
@ -127,7 +126,9 @@ static void checkOrder(testingT *t, uint32_t flag)
flag, "unknown order", flag, "unknown order",
orders[0].result, orders[0].order); orders[0].result, orders[0].order);
} }
#define checkOrder(t, flag) checkOrderFull(t, __FILE__, __LINE__, flag)
testingTest(QueueMain_Sequence) testingTest(QueueMain_Sequence)
{ {
struct testParams p; struct testParams p;