Just restored TestEventErrors as is for now. There's definitely room for cleanup here.

This commit is contained in:
Pietro Gagliardi 2019-06-09 18:08:50 -04:00
parent 94d638e601
commit a0fd823328
4 changed files with 14 additions and 22 deletions

View File

@ -916,8 +916,8 @@ testingTest(EventInvalidateSender)
runArgsSubtests(t, &p);
}
#if 0
TODOTODO
// TODO table-ize these
// TODO deduplicate this from the one in noinitwrongthread.c?
static void testWhileFiring(void *sender, void *args, void *data)
{
@ -1054,5 +1054,3 @@ testingTest(EventErrors)
"attempt to free a uiEvent that still has handlers registered");
uiEventFire(firingEvent, NULL, firingEvent);
}
#endif

View File

@ -6,20 +6,14 @@ void timeoutMain(void *data)
uiMain();
}
struct errorParams errorParams;
void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal)
void catchProgrammerError(const char *msg, void *data)
{
errorParams.caught = true;
if (strcmp(prefix, "libui programmer error") != 0)
// TODO use diff
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s prefix string doesn't contain \"programmer error\": %s", errorParams.exprstr, prefix);
if (internal)
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s error is marked internal; should not have been", errorParams.exprstr);
if (strcmp(msg, errorParams.msgWant) != 0)
// TODO use diff
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s: message doesn't contain expected substring:" diff("%s"),
errorParams.exprstr, msg, errorParams.msgWant);
struct errorParams *errorParams = (struct errorParams *) data;
errorParams->caught = true;
if (strcmp(msg, errorParams->msgWant) != 0)
testingTErrorfFull(errorParams->t, errorParams->file, errorParams->line, "%s: message doesn't match expected string:" diff("%s"),
errorParams->exprstr, msg, errorParams->msgWant);
}
static void runSetORingResults(testingSet *set, const struct testingOptions *options, bool *anyRun, bool *anyFailed)

View File

@ -36,7 +36,7 @@ static void deferResetProgrammerError(testingT *t, void *data)
if (!c->caught) \
testingTErrorf(t, "did not throw a programmer error; should have"); \
if (c->msgGot != NULL) { \
testingTErrorf(t, "message doesn't contain expected string:" diff("%s"), \
testingTErrorf(t, "message doesn't match expected string:" diff("%s"), \
c->msgGot, c->msgWant); \
testingUtilFreeStrdup(c->msgGot); \
} \

View File

@ -34,11 +34,11 @@ struct errorParams {
const char *msgWant;
bool caught;
};
extern struct errorParams errorParams;
extern void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal);
extern void catchProgrammerError(const char *msg, void *data);
#define testProgrammerError(tt, expr, mw) { \
struct errorParams errorParams; \
testingTLogf(t, "*** %s", #expr); \
uiprivTestHookReportProgrammerError(catchProgrammerError); \
uiprivTestHookReportProgrammerError(catchProgrammerError, &errorParams); \
errorParams.t = tt; \
errorParams.file = __FILE__; \
errorParams.line = __LINE__; \
@ -48,7 +48,7 @@ extern void catchProgrammerError(const char *prefix, const char *msg, const char
expr; \
if (!errorParams.caught) \
testingTErrorfFull(t, errorParams.file, errorParams.line, "%s did not throw a programmer error; should have", #expr); \
uiprivTestHookReportProgrammerError(NULL); \
uiprivTestHookReportProgrammerError(NULL, NULL); \
}
// init.c