Just restored TestEventErrors as is for now. There's definitely room for cleanup here.
This commit is contained in:
parent
94d638e601
commit
a0fd823328
|
@ -916,8 +916,8 @@ testingTest(EventInvalidateSender)
|
||||||
runArgsSubtests(t, &p);
|
runArgsSubtests(t, &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
// TODO table-ize these
|
||||||
TODOTODO
|
// TODO deduplicate this from the one in noinitwrongthread.c?
|
||||||
|
|
||||||
static void testWhileFiring(void *sender, void *args, void *data)
|
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");
|
"attempt to free a uiEvent that still has handlers registered");
|
||||||
uiEventFire(firingEvent, NULL, firingEvent);
|
uiEventFire(firingEvent, NULL, firingEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
20
test/main.c
20
test/main.c
|
@ -6,20 +6,14 @@ void timeoutMain(void *data)
|
||||||
uiMain();
|
uiMain();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct errorParams errorParams;
|
void catchProgrammerError(const char *msg, void *data)
|
||||||
|
|
||||||
void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
|
||||||
{
|
{
|
||||||
errorParams.caught = true;
|
struct errorParams *errorParams = (struct errorParams *) data;
|
||||||
if (strcmp(prefix, "libui programmer error") != 0)
|
|
||||||
// TODO use diff
|
errorParams->caught = true;
|
||||||
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s prefix string doesn't contain \"programmer error\": %s", errorParams.exprstr, prefix);
|
if (strcmp(msg, errorParams->msgWant) != 0)
|
||||||
if (internal)
|
testingTErrorfFull(errorParams->t, errorParams->file, errorParams->line, "%s: message doesn't match expected string:" diff("%s"),
|
||||||
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s error is marked internal; should not have been", errorParams.exprstr);
|
errorParams->exprstr, msg, errorParams->msgWant);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runSetORingResults(testingSet *set, const struct testingOptions *options, bool *anyRun, bool *anyFailed)
|
static void runSetORingResults(testingSet *set, const struct testingOptions *options, bool *anyRun, bool *anyFailed)
|
||||||
|
|
|
@ -36,7 +36,7 @@ static void deferResetProgrammerError(testingT *t, void *data)
|
||||||
if (!c->caught) \
|
if (!c->caught) \
|
||||||
testingTErrorf(t, "did not throw a programmer error; should have"); \
|
testingTErrorf(t, "did not throw a programmer error; should have"); \
|
||||||
if (c->msgGot != NULL) { \
|
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); \
|
c->msgGot, c->msgWant); \
|
||||||
testingUtilFreeStrdup(c->msgGot); \
|
testingUtilFreeStrdup(c->msgGot); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -34,11 +34,11 @@ struct errorParams {
|
||||||
const char *msgWant;
|
const char *msgWant;
|
||||||
bool caught;
|
bool caught;
|
||||||
};
|
};
|
||||||
extern struct errorParams errorParams;
|
extern void catchProgrammerError(const char *msg, void *data);
|
||||||
extern void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal);
|
|
||||||
#define testProgrammerError(tt, expr, mw) { \
|
#define testProgrammerError(tt, expr, mw) { \
|
||||||
|
struct errorParams errorParams; \
|
||||||
testingTLogf(t, "*** %s", #expr); \
|
testingTLogf(t, "*** %s", #expr); \
|
||||||
uiprivTestHookReportProgrammerError(catchProgrammerError); \
|
uiprivTestHookReportProgrammerError(catchProgrammerError, &errorParams); \
|
||||||
errorParams.t = tt; \
|
errorParams.t = tt; \
|
||||||
errorParams.file = __FILE__; \
|
errorParams.file = __FILE__; \
|
||||||
errorParams.line = __LINE__; \
|
errorParams.line = __LINE__; \
|
||||||
|
@ -48,7 +48,7 @@ extern void catchProgrammerError(const char *prefix, const char *msg, const char
|
||||||
expr; \
|
expr; \
|
||||||
if (!errorParams.caught) \
|
if (!errorParams.caught) \
|
||||||
testingTErrorfFull(t, errorParams.file, errorParams.line, "%s did not throw a programmer error; should have", #expr); \
|
testingTErrorfFull(t, errorParams.file, errorParams.line, "%s did not throw a programmer error; should have", #expr); \
|
||||||
uiprivTestHookReportProgrammerError(NULL); \
|
uiprivTestHookReportProgrammerError(NULL, NULL); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// init.c
|
// init.c
|
||||||
|
|
Loading…
Reference in New Issue