You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-06 08:49:29 +02:00
Improve formatting of unit test titles.
Add separation and some visual cues to help identify the start of a test. Also add a counter which can be used to search for a specific test, which is useful if there is a lot of debug output to search through.
This commit is contained in:
@@ -24,6 +24,7 @@ typedef struct TestData
|
||||
static TestData testList[TEST_LIST_SIZE];
|
||||
|
||||
static int testRun = 0;
|
||||
static int testRunSub = 0;
|
||||
static int testTotal = 0;
|
||||
static bool testFirst = true;
|
||||
|
||||
@@ -197,9 +198,10 @@ testBegin(const char *name)
|
||||
if (testRun != 1)
|
||||
printf("\n");
|
||||
|
||||
printf("run %03d - %s\n", testRun, name);
|
||||
printf("run %d - %s\n", testRun, name);
|
||||
fflush(stdout);
|
||||
|
||||
testRunSub = 1;
|
||||
timeMSecBegin = testTimeMSec();
|
||||
|
||||
#ifndef NO_LOG
|
||||
@@ -400,6 +402,27 @@ hrnDiff(const char *expected, const char *actual)
|
||||
FUNCTION_HARNESS_RESULT(STRINGZ, harnessDiffBuffer);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
hrnTestLogTitle(int lineNo)
|
||||
{
|
||||
// Output run/test
|
||||
char buffer[32];
|
||||
int bufferSize = snprintf(buffer, sizeof(buffer), "%d/%d", testRun, testRunSub);
|
||||
|
||||
printf("\nrun %s ", buffer);
|
||||
|
||||
// Output dashes
|
||||
for (int dashIdx = 0; dashIdx < 16 - bufferSize; dashIdx++)
|
||||
putchar('-');
|
||||
|
||||
// Output line number
|
||||
printf(" l%04d", lineNo);
|
||||
|
||||
// Increment testSub and reset log time
|
||||
testRunSub++;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
hrnTestLogPrefix(int lineNo, bool padding)
|
||||
@@ -435,8 +458,8 @@ hrnTestLogPrefix(int lineNo, bool padding)
|
||||
harnessTestLocal.logLastBeginTime = currentTime;
|
||||
}
|
||||
|
||||
// Add number and padding
|
||||
printf("l%04d - %s", lineNo, padding ? " " : "");
|
||||
// Add line number and padding
|
||||
printf("l%04d %s", lineNo, padding ? " " : "");
|
||||
|
||||
FUNCTION_HARNESS_RESULT_VOID();
|
||||
}
|
||||
|
||||
@@ -355,16 +355,16 @@ Test title macro
|
||||
#define TEST_TITLE(message) \
|
||||
do \
|
||||
{ \
|
||||
hrnTestLogPrefix(__LINE__, false); \
|
||||
printf("%s\n", message); \
|
||||
hrnTestLogTitle(__LINE__); \
|
||||
printf(" %s\n", message); \
|
||||
fflush(stdout); \
|
||||
} while (0)
|
||||
|
||||
#define TEST_TITLE_FMT(format, ...) \
|
||||
do \
|
||||
{ \
|
||||
hrnTestLogPrefix(__LINE__, false); \
|
||||
printf(format "\n", __VA_ARGS__); \
|
||||
hrnTestLogTitle(__LINE__); \
|
||||
printf(" " format "\n", __VA_ARGS__); \
|
||||
fflush(stdout); \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ void hrnInit(
|
||||
void hrnAdd(int run, bool selected);
|
||||
void hrnComplete(void);
|
||||
|
||||
// Output test log title with line number
|
||||
void hrnTestLogTitle(int lineNo);
|
||||
|
||||
// Output test log prefix with timing, line number, and optional padding
|
||||
void hrnTestLogPrefix(int lineNo, bool padding);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user