Skip to content

Commit

Permalink
BaseTools/Plugin/HostBasedUnitTestRunner: Fix invalid escape in HostB…
Browse files Browse the repository at this point in the history
…asedUnitTest.py (#899)

## Description

Fix invalid escape sequence in
BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py.
These warnings are exposed by Python 3.12.

For each item, place an "x" in between `[` and `]` if true. Example:
`[x]`.
_(you can also check items in the GitHub UI)_

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Validated no functional changes to HostBasedUnitTestRunner.

## Integration Instructions

N/A
  • Loading branch information
antklein authored Jun 12, 2024
1 parent 1475a86 commit 23c33e2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def gen_code_coverage_gcc(self, thebuilder):

buildOutputBase = thebuilder.env.GetValue("BUILD_OUTPUT_BASE")
workspace = thebuilder.env.GetValue("WORKSPACE")
# MU_CHANGE begin - regex string for exclude paths
regex_exclude = r"^.*UnitTest\|^.*MU\|^.*Mock\|^.*DEBUG"
# MU_CHANGE end - regex string for exclude paths

# Generate base code coverage for all source files
ret = RunCmd("lcov", f"--no-external --capture --initial --directory {buildOutputBase} --output-file {buildOutputBase}/cov-base.info --rc lcov_branch_coverage=1")
Expand All @@ -180,7 +183,7 @@ def gen_code_coverage_gcc(self, thebuilder):
# Filter out auto-generated and test code
# MU_CHANGE begin - reformat coverage data
file_out = thebuilder.env.GetValue("CI_PACKAGE_NAME", "") + "_coverage.xml"
ret = RunCmd("lcov_cobertura",f"{buildOutputBase}/total-coverage.info --excludes ^.*UnitTest\|^.*MU\|^.*Mock\|^.*DEBUG -o {buildOutputBase}/{file_out}")
ret = RunCmd("lcov_cobertura",f"{buildOutputBase}/total-coverage.info --excludes {regex_exclude} -o {buildOutputBase}/{file_out}")
# MU_CHANGE end - reformat coverage data
if ret != 0:
logging.error("UnitTest Coverage: Failed generate filtered coverage XML.")
Expand All @@ -200,7 +203,9 @@ def gen_code_coverage_gcc(self, thebuilder):
# Generate and XML file if requested.for all package
if os.path.isfile(f"{workspace}/Build/coverage.xml"):
os.remove(f"{workspace}/Build/coverage.xml")
ret = RunCmd("lcov_cobertura",f"{workspace}/Build/all-coverage.info --excludes ^.*UnitTest\|^.*MU\|^.*Mock\|^.*DEBUG -o {workspace}/Build/coverage.xml")
# MU_CHANGE begin - regex string for exclude paths
ret = RunCmd("lcov_cobertura",f"{workspace}/Build/all-coverage.info --excludes {regex_exclude} -o {workspace}/Build/coverage.xml")
# MU_CHANGE end - regex string for exclude paths
if ret != 0:
logging.error("UnitTest Coverage: Failed generate all coverage XML.")
return 1
Expand Down

0 comments on commit 23c33e2

Please sign in to comment.