Exclude uncoverable lines from code coverage (#3179)

* Use code coverage annotations in places that never can be covered

* Comments

* Increment goal

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
Anton Kolesnyk 2021-12-14 15:25:48 -08:00 committed by GitHub
parent 7301f348b0
commit 07d20e78e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

View File

@ -3,6 +3,8 @@
#include "azure/core/internal/azure_assert.hpp"
// Calling this function would terminate program, therefore this function can't be covered in tests.
// LCOV_EXCL_START
[[noreturn]] void Azure::Core::_internal::AzureNoReturnPath(std::string const& msg)
{
// void msg for Release build where Assert is ignored
@ -10,3 +12,4 @@
_azure_ASSERT_MSG(false, msg);
std::abort();
}
// LCOV_EXCL_STOP

View File

@ -342,7 +342,10 @@ T ParseNumber(
}
ThrowParseError(description);
return T();
// ThrowParseError() will always throw, but there's no way to tell that to compiler, so a return
// statement is required. It is not possible to cover the return line with tests.
return T(); // LCOV_EXCL_LINE
}
template <typename T>

View File

@ -20,7 +20,9 @@ std::unique_ptr<_detail::ManagedIdentitySource> CreateManagedIdentitySource(
AzureArcManagedIdentitySource::Create,
ImdsManagedIdentitySource::Create};
for (auto create : managedIdentitySourceCreate)
// IMDS ManagedIdentity, which comes last in the list, will never return nullptr from Create().
// For that reason, it is not possible to cover that execution branch in tests.
for (auto create : managedIdentitySourceCreate) // LCOV_EXCL_LINE
{
if (auto source = create(clientId, options))
{
@ -28,8 +30,10 @@ std::unique_ptr<_detail::ManagedIdentitySource> CreateManagedIdentitySource(
}
}
// LCOV_EXCL_START
throw AuthenticationException(
"ManagedIdentityCredential authentication unavailable. No Managed Identity endpoint found.");
// LCOV_EXCL_STOP
}
} // namespace

View File

@ -29,7 +29,7 @@ stages:
CtestRegex: azure-identity.
LiveTestCtestRegex: azure-identity.
LineCoverageTarget: 99
BranchCoverageTarget: 62
BranchCoverageTarget: 63
Artifacts:
- Name: azure-identity
Path: azure-identity