diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py index 7d4e8eaba7..d719997346 100644 --- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py +++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py @@ -12,7 +12,6 @@ import xml.etree.ElementTree from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin from edk2toolext import edk2_logging -import edk2toollib.windows.locate_tools as locate_tools from edk2toolext.environment import shell_environment from edk2toollib.utility_functions import RunCmd from edk2toollib.utility_functions import GetHostInfo @@ -293,13 +292,14 @@ def organize_coverage(self, thebuilder) -> int: package = thebuilder.env.GetValue("CI_PACKAGE_NAME", "") file_out = package + "_coverage.xml" cov_file = os.path.join(buildOutputBase, file_out) + exclude = thebuilder.env.GetValue("CC_EXCLUDE", "*NULL*,*Null*,*null*") params = f"--database {db_path} coverage {cov_file} -o {cov_file} --by-package -ws {workspace}" params += f" -p {package}" * int(package != "") params += " --full" * int(thebuilder.env.GetValue("CC_FULL", "FALSE") == "TRUE") params += " --flatten" * int(thebuilder.env.GetValue("CC_FLATTEN", "FALSE") == "TRUE") - + params += f" --exclude {exclude}" * int(exclude != "") return RunCmd("stuart_report", params) def parse_workspace(self, thebuilder) -> str: diff --git a/UnitTestFrameworkPkg/ReadMe.md b/UnitTestFrameworkPkg/ReadMe.md index 9eeec17234..334ca9760d 100644 --- a/UnitTestFrameworkPkg/ReadMe.md +++ b/UnitTestFrameworkPkg/ReadMe.md @@ -1516,8 +1516,10 @@ or FALSE e.g. `CC_REORGANIZE=TRUE`: 1. `CC_FULL`: Generates zero'd out coverage data for untested source files in the package. Default: `FALSE` 1. `CC_FLATTEN`: Groups all source files together, rather than by INF. Default: `FALSE` +1. `CC_EXCLUDE`: Comma separated list of fnmatch expressions to exclude from results. + Default: \*NULL\*,\*Null\*,\*null\* -** NOTE: `CC_FULL` and `CC_FLATTEN` values only matter if `CC_REORGANIZE=TRUE`, as they only +** NOTE: `CC_FULL` and `CC_FLATTEN` and `CC_EXCLUDE` values only matter if `CC_REORGANIZE=TRUE`, as they only effect how the coverage report is reorganized. **TIP: `CC_FLATTEN=TRUE/FALSE` will produce different coverage percentage results as `TRUE` de-duplicates source files