1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Refactor the common/log tests to not depend on common/harnessLog.

common/harnessLog was not ideally suited for general testing and made all the tests quite awkward. Instead, move all code used to test the common/log module into the logTest module and repurpose common/harnessLog to do log expect testing for all other tests in a cleaner way.

Add a few exceptions for config testing since the log levels are reset by default in config/parse.
This commit is contained in:
David Steele
2018-07-20 18:51:42 -04:00
parent 1359e2908c
commit 58e9f1e50c
27 changed files with 345 additions and 247 deletions

View File

@ -53,7 +53,7 @@ testRun()
cfgCommandSet(cfgCmdArchivePush);
TEST_RESULT_INT(exitSafe(0, false, signalTypeNone), 0, "exit with no error")
testLogResult("P00 INFO: archive-push command end: completed successfully");
harnessLogResult("P00 INFO: archive-push command end: completed successfully");
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
@ -63,14 +63,14 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
testLogResult(
harnessLogResult(
"P00 ERROR: [122]: test error message\n"
"P00 INFO: archive-push command end: aborted with exception [122]");
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
logInit(logLevelDebug, logLevelOff, logLevelOff, false);
harnessLogLevelSet(logLevelDebug);
TRY_BEGIN()
{
@ -79,7 +79,7 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
testLogResultRegExp(
harnessLogResultRegExp(
"P00 ERROR\\: \\[122\\]\\: test debug error message\n"
" STACK TRACE\\:\n"
" module\\/common\\/exitTest\\:testRun\\:.*\n"
@ -87,7 +87,7 @@ testRun()
}
TRY_END();
logInit(logLevelInfo, logLevelOff, logLevelOff, false);
harnessLogLevelSet(logLevelInfo);
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
@ -97,7 +97,7 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
testLogResultRegExp(
harnessLogResultRegExp(
"P00 ASSERT\\: \\[025\\]\\: test assert message\n"
" STACK TRACE\\:\n"
" module/common/exitTest\\:testRun\\:.*\n"
@ -113,7 +113,7 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
testLogResult(
harnessLogResult(
"P00 INFO: archive-push command end: aborted with exception [122]");
}
TRY_END();
@ -121,12 +121,12 @@ testRun()
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(
exitSafe(errorTypeCode(&TermError), false, signalTypeNone), errorTypeCode(&TermError), "exit on term with no signal");
testLogResult("P00 INFO: archive-push command end: terminated on signal from child process");
harnessLogResult("P00 INFO: archive-push command end: terminated on signal from child process");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(
exitSafe(errorTypeCode(&TermError), false, signalTypeTerm), errorTypeCode(&TermError), "exit on term with SIGTERM");
testLogResult("P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
harnessLogResult("P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
}
FUNCTION_HARNESS_RESULT_VOID();