From bbf77d6c58dc360a7a9b4d390bcad7f4ea48d9e7 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 5 Sep 2023 14:51:50 -0700 Subject: [PATCH] Add "coverage" Makefile target for lcov.info, add a test that extends coverage --- Makefile | 5 +++++ soroban-env-host/src/events/diagnostic.rs | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Makefile b/Makefile index 0211ae5c7..7ddfca70e 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,8 @@ publish: publish-dry-run: ./publish-dry-run.sh + +# Requires: cargo-install llvm-cov +coverage: + rm -f lcov.info + cargo llvm-cov test --all-features --tests --lcov --output-path=lcov.info diff --git a/soroban-env-host/src/events/diagnostic.rs b/soroban-env-host/src/events/diagnostic.rs index efef2f28b..da16b977c 100644 --- a/soroban-env-host/src/events/diagnostic.rs +++ b/soroban-env-host/src/events/diagnostic.rs @@ -177,3 +177,20 @@ impl Host { }) } } + +#[test] +fn misc_coverage() -> Result<(), HostError> { + use crate::xdr::HostFunctionType; + let host = Host::default(); + + // cover get_current_contract_id_unmetered on HostFunctionType::InvokeContract + host.with_frame( + Frame::HostFunction(HostFunctionType::InvokeContract), + || { + assert_eq!(host.get_current_contract_id_unmetered()?, None); + Ok(Val::VOID.into()) + }, + )?; + + Ok(()) +}