1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-18 23:57:33 +02:00

Improve macros and coverage rules that were hiding missing coverage.

The branch coverage exclusion rules were overly broad and included functions that ended in a capital letter, which disabled all coverage for the statement.  Improve matching so that all characters in the name must be upper-case for a match.

Some macros with internal branches accepted parameters that might contain conditionals.  This made it impossible to tell which branches belonged to which, and in any case an overzealous exclusion rule was ignoring all branches in such cases.  Add the DEBUG_COVERAGE flag to build a modified version of the macros without any internal branches to be used for coverage testing.  In most cases, the branches were optimizations (like checking logWill()) that improve production performance but are not needed for testing.  In other cases, a parameter needed to be added to the underlying function to handle the branch during coverage testing.

Also tweak the coverage rules so that macros without conditionals are automatically excluded from branch coverage as long as they are not themselves a parameter.

Finally, update tests and code where missing coverage was exposed by these changes.  Some code was updated to remove existing coverage exclusions when it was a simple change.
This commit is contained in:
David Steele
2019-05-11 14:51:51 -04:00
parent f819a32cdf
commit 87f36e814e
38 changed files with 279 additions and 123 deletions

View File

@ -252,7 +252,7 @@ testRun(void)
// Throw errors
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop with error text");
ioWriteStrLine(write, strNew("{\"err\":25,\"out\":\"sample error message\"}"));
ioWriteStrLine(write, strNew("{\"err\":25,\"out\":\"sample error message\",\"errStack\":\"stack data\"}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop with no error text");
@ -321,8 +321,15 @@ testRun(void)
// Throw errors
TEST_ERROR(
protocolClientNoOp(client), AssertError,
"raised from test client: sample error message\nno stack trace available");
TEST_ERROR(protocolClientNoOp(client), UnknownError, "raised from test client: no details available");
"raised from test client: sample error message\nstack data");
harnessLogLevelSet(logLevelDebug);
TEST_ERROR(
protocolClientNoOp(client), UnknownError,
"raised from test client: no details available\nno stack trace available");
harnessLogLevelReset();
// No output expected
TEST_ERROR(protocolClientNoOp(client), AssertError, "no output required by command");
// Get command output