mirror of
https://github.com/zebrajr/ansible.git
synced 2025-12-06 12:19:53 +01:00
Fixes the coverage path translation for modules located in integration test paths. Instead of trying to match by the unique temporary path name that the module is executed as, the reporting tool will translate it to the static path that the module is actually located under.
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import os.path
|
|
|
|
|
|
def main() -> None:
|
|
collection_root = os.getcwd()
|
|
print(f"Running windows-integration coverage test in '{collection_root}'")
|
|
|
|
result_path = os.path.join(collection_root, "tests", "output", "coverage", "coverage-powershell")
|
|
module_path = os.path.join(collection_root, "plugins", "modules", "win_collection.ps1")
|
|
test_path = os.path.join(collection_root, "tests", "integration", "targets", "win_collection", "library", "test_win_collection.ps1")
|
|
with open(result_path, mode="rb") as fd:
|
|
data = json.load(fd)
|
|
|
|
for path, result in data.items():
|
|
print(f"Testing result for path '{path}' -> {result!r}")
|
|
assert path in [module_path, test_path], f"Found unexpected coverage result path '{path}'"
|
|
assert result == {'5': 1, '6': 1}, "Coverage result did not pick up a hit on lines 5 and 6"
|
|
|
|
assert len(data) == 2, f"Expected coverage results for 2 files but got {len(data)}"
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|