diff --git a/sdk/core/azure-core/src/azure_assert.cpp b/sdk/core/azure-core/src/azure_assert.cpp index 6a5c21ad8..0942ec12e 100644 --- a/sdk/core/azure-core/src/azure_assert.cpp +++ b/sdk/core/azure-core/src/azure_assert.cpp @@ -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 diff --git a/sdk/core/azure-core/src/datetime.cpp b/sdk/core/azure-core/src/datetime.cpp index 4bfca2415..d506f6d6f 100644 --- a/sdk/core/azure-core/src/datetime.cpp +++ b/sdk/core/azure-core/src/datetime.cpp @@ -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 diff --git a/sdk/identity/azure-identity/src/managed_identity_credential.cpp b/sdk/identity/azure-identity/src/managed_identity_credential.cpp index d827755d6..38d414333 100644 --- a/sdk/identity/azure-identity/src/managed_identity_credential.cpp +++ b/sdk/identity/azure-identity/src/managed_identity_credential.cpp @@ -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 diff --git a/sdk/identity/ci.yml b/sdk/identity/ci.yml index d791b0d05..510b2ed52 100644 --- a/sdk/identity/ci.yml +++ b/sdk/identity/ci.yml @@ -29,7 +29,7 @@ stages: CtestRegex: azure-identity. LiveTestCtestRegex: azure-identity. LineCoverageTarget: 99 - BranchCoverageTarget: 62 + BranchCoverageTarget: 63 Artifacts: - Name: azure-identity Path: azure-identity