Skip to content

Commit

Permalink
.pytool/Plugin/RustHostUnitTestPlugin: Handle no coverage results
Browse files Browse the repository at this point in the history
In the case that all possible crates are ignored, do not fail if
a `cobertura.xml` file is not present.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki committed Aug 30, 2023
1 parent 17f0766 commit 4a4dd5b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .pytool/Plugin/RustHostUnitTestPlugin/RustHostUnitTestPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,19 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM,

# Move coverage.xml to Build Directory
xml = Path(rust_ws.path) / "target" / "cobertura.xml"
out = Path(rust_ws.path) / "Build"
if xml.exists():
out = Path(rust_ws.path) / "Build"

if (out / "coverage.xml").exists():
(out / "coverage.xml").unlink()
xml = xml.rename(out / "coverage.xml")
if (out / "coverage.xml").exists():
(out / "coverage.xml").unlink()
xml = xml.rename(out / "coverage.xml")

with open(xml, 'r') as f:
contents = f.read()
contents = re.sub(r'<source>(.*?)</source>', r'<source>.</source>', contents)
with open(xml, 'r') as f:
contents = f.read()
contents = re.sub(r'<source>(.*?)</source>', r'<source>.</source>', contents)

with open (xml, "w") as f:
f.write(contents)
with open (xml, "w") as f:
f.write(contents)

# Return
if failed > 0:
Expand Down

0 comments on commit 4a4dd5b

Please sign in to comment.