Set up the necessary work for having the list of tests sort by filename/line number instead of init order.
This commit is contained in:
parent
2f58c2059e
commit
dcf34e6dab
|
@ -31,10 +31,11 @@ static testingT *testsBeforeTail = NULL;
|
||||||
static testingT *testsAfter = NULL;
|
static testingT *testsAfter = NULL;
|
||||||
static testingT *testsAfterTail = NULL;
|
static testingT *testsAfterTail = NULL;
|
||||||
|
|
||||||
static testingT *newTest(const char *name, void (*f)(testingT *), testingT *prev)
|
static testingT *newTest(const char *name, void (*f)(testingT *), const char *file, long line, testingT *prev)
|
||||||
{
|
{
|
||||||
testingT *t;
|
testingT *t;
|
||||||
|
|
||||||
|
printf("%s %s %ld\n", name, file, line);
|
||||||
t = testingprivNew(testingT);
|
t = testingprivNew(testingT);
|
||||||
t->name = name;
|
t->name = name;
|
||||||
t->f = f;
|
t->f = f;
|
||||||
|
@ -49,31 +50,31 @@ static testingT *newTest(const char *name, void (*f)(testingT *), testingT *prev
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testingprivRegisterTest(const char *name, void (*f)(testingT *))
|
void testingprivRegisterTest(const char *name, void (*f)(testingT *), const char *file, long line)
|
||||||
{
|
{
|
||||||
testingT *t;
|
testingT *t;
|
||||||
|
|
||||||
t = newTest(name, f, testsTail);
|
t = newTest(name, f, file, line, testsTail);
|
||||||
testsTail = t;
|
testsTail = t;
|
||||||
if (tests == NULL)
|
if (tests == NULL)
|
||||||
tests = t;
|
tests = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testingprivRegisterTestBefore(const char *name, void (*f)(testingT *))
|
void testingprivRegisterTestBefore(const char *name, void (*f)(testingT *), const char *file, long line)
|
||||||
{
|
{
|
||||||
testingT *t;
|
testingT *t;
|
||||||
|
|
||||||
t = newTest(name, f, testsBeforeTail);
|
t = newTest(name, f, file, line, testsBeforeTail);
|
||||||
testsBeforeTail = t;
|
testsBeforeTail = t;
|
||||||
if (testsBefore == NULL)
|
if (testsBefore == NULL)
|
||||||
testsBefore = t;
|
testsBefore = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testingprivRegisterTestAfter(const char *name, void (*f)(testingT *))
|
void testingprivRegisterTestAfter(const char *name, void (*f)(testingT *), const char *file, long line)
|
||||||
{
|
{
|
||||||
testingT *t;
|
testingT *t;
|
||||||
|
|
||||||
t = newTest(name, f, testsAfterTail);
|
t = newTest(name, f, file, line, testsAfterTail);
|
||||||
testsAfterTail = t;
|
testsAfterTail = t;
|
||||||
if (testsAfter == NULL)
|
if (testsAfter == NULL)
|
||||||
testsAfter = t;
|
testsAfter = t;
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#define testingprivCtorPtrName(basename) testingprivCtorPtr ## basename
|
#define testingprivCtorPtrName(basename) testingprivCtorPtr ## basename
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define testingprivMkCtor(basename, regfunc) \
|
#define testingprivMkCtor(basename, regfunc) \
|
||||||
__attribute__((constructor)) static void testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename)); }
|
__attribute__((constructor)) static void testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename), __FILE__, __LINE__); }
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define testingprivMkCtor(basename, reg) \
|
#define testingprivMkCtor(basename, reg) \
|
||||||
static int testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename)); return 0; } \
|
static int testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename), __FILE__, __LINE__); return 0; } \
|
||||||
__pragma(section(".CRT$XCU",read)) \
|
__pragma(section(".CRT$XCU",read)) \
|
||||||
__declspec(allocate(".CRT$XCU")) static int (*testingprivCtorPtrName(basename))(void) = testingprivCtorName(basename);
|
__declspec(allocate(".CRT$XCU")) static int (*testingprivCtorPtrName(basename))(void) = testingprivCtorName(basename);
|
||||||
#else
|
#else
|
||||||
|
@ -67,9 +67,9 @@ extern void testingTFailNow(testingT *t);
|
||||||
extern void testingTSkipNow(testingT *t);
|
extern void testingTSkipNow(testingT *t);
|
||||||
extern void testingTDefer(testingT *t, void (*f)(testingT *t, void *data), void *data);
|
extern void testingTDefer(testingT *t, void (*f)(testingT *t, void *data), void *data);
|
||||||
|
|
||||||
extern void testingprivRegisterTest(const char *, void (*)(testingT *));
|
extern void testingprivRegisterTest(const char *, void (*)(testingT *), const char *, long);
|
||||||
extern void testingprivRegisterTestBefore(const char *, void (*)(testingT *));
|
extern void testingprivRegisterTestBefore(const char *, void (*)(testingT *), const char *, long);
|
||||||
extern void testingprivRegisterTestAfter(const char *, void (*)(testingT *));
|
extern void testingprivRegisterTestAfter(const char *, void (*)(testingT *), const char *, long);
|
||||||
// see https://stackoverflow.com/questions/32399191/va-args-expansion-using-msvc
|
// see https://stackoverflow.com/questions/32399191/va-args-expansion-using-msvc
|
||||||
#define testingprivExpand(x) x
|
#define testingprivExpand(x) x
|
||||||
#define testingprivTLogfThen(then, t, ...) ((testingprivTLogfFull(t, __FILE__, __LINE__, __VA_ARGS__)), (then(t)))
|
#define testingprivTLogfThen(then, t, ...) ((testingprivTLogfFull(t, __FILE__, __LINE__, __VA_ARGS__)), (then(t)))
|
||||||
|
|
Loading…
Reference in New Issue