run-coverage
Skill0 starsChanged 21 days agoMITView on GitHub
Run MSVC code coverage on unit test executables using Microsoft.CodeCoverage.Console. Use this skill when the user wants to check code coverage, see uncovered lines, measure test coverage percentage, or identify untested code paths. Triggers include "coverage", "code coverage", "uncovered lines", "test coverage", "coverage report".
In this repository6 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- address-pr-commentsSkill
- apply-change-to-repo-hierarchySkill
- create-new-taskSkill
- extract-learningsSkill
- watch-multiple-pr-statusSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Run native C/C++ code coverage using Microsoft.CodeCoverage.Console.exe (Visual Studio Enterprise) and parse Cobertura XML results.
- Distinctive: line 36
If the user provides just a module name, construct the full path:
- Distinctive: line 41
Verify the executable exists before running coverage.
- Very specific: line 47
All source files: "*src\*.c"
- Distinctive: line 73
If the user wants to improve coverage, read the uncovered lines from the source file to understand what code paths are not exercised, then …
- Very specific: line 108
"No source files matched the filter": Check the -SourceFilter pattern.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Coverage with MSVC
Run native C/C++ code coverage using Microsoft.CodeCoverage.Console.exe (Visual Studio Enterprise) and parse Cobertura XML results.
Prerequisites
- Visual Studio Enterprise installed (provides
Microsoft.CodeCoverage.Console.exe) - Unit test executable already built (Debug configuration)
Script Location
The coverage script is at #file:../../scripts/run_coverage.ps1 (in the azure-messaging-ai-context .github/scripts/ directory).
For projects that consume azure-messaging-ai-context as a submodule, the path is:
<repo_root>/deps/azure-messaging-ai-context/.github/scripts/run_coverage.ps1Workflow
Step 1: Identify the Test Executable
The test executable path follows the pattern:
$env:BUILD_BINARIESDIRECTORY\Debug\<target_name>\<target_name>.exeWhere <target_name> is typically <module_name>_ut_exe_<project_name> (e.g., peer_library_ut_exe_zrpc).
If the user provides just a module name, construct the full path:
$testExe = "$env:BUILD_BINARIESDIRECTORY\Debug\<module>_ut_exe_<project>\<module>_ut_exe_<project>.exe"Verify the executable exists before running coverage.
Step 2: Determine Source Filter
The source filter uses wildcard patterns (-like matching) to select which source files appear in the report:
- Single file:
"*src\<module_name>.c" - All source files:
"*src\*.c" - Multiple patterns:
"*src\module1.c", "*src\module2.c"
Step 3: Run Coverage
Locate the script via the azure-messaging-ai-context submodule path and run it. Always use -ShowFunctions and -ShowUncoveredLines for maximum detail.
pwsh -NoProfile -ExecutionPolicy Bypass -File "<repo_root>/deps/azure-messaging-ai-context/.github/scripts/run_coverage.ps1" -TestExe "<test_exe_path>" -SourceFilter "*src\<module_name>.c" -ShowFunctions -ShowUncoveredLinesStep 4: Analyze Results
The script outputs:
- Per-file summary table - Lines, Covered, Uncovered, Pct% (color-coded: green >=80%, yellow >=50%, red <50%)
- Per-function coverage (with
-ShowFunctions) - Shows each function's coverage, sorted worst-first - Uncovered line ranges (with
-ShowUncoveredLines) - Groups consecutive uncovered lines into ranges (e.g., "Lines: 45-52, 78, 90-95") - Cobertura XML file - Saved to
<script_dir>/coverage/with timestamp
Step 5: Report to User
Summarize:
- Overall coverage percentage
- Functions with lowest coverage (potential areas to add tests)
- Specific uncovered line ranges that may need test coverage
If the user wants to improve coverage, read the uncovered lines from the source file to understand what code paths are not exercised, then suggest specific test cases.
Script Parameters
| Parameter | Required | Description |
-TestExe | Yes | Path to the unit test executable |
-SourceFilter | No | Wildcard patterns to filter source files (e.g., "*src\module.c") |
-OutputDir | No | Directory for coverage output (default: <script_dir>/coverage/) |
-ShowFunctions | No | Show per-function coverage breakdown |
-ShowUncoveredLines | No | List uncovered line numbers/ranges |
-SettingsFile | No | XML settings file for fine-grained instrumentation control |
Examples
Coverage for a single module
pwsh -NoProfile -ExecutionPolicy Bypass -File "deps/azure-messaging-ai-context/.github/scripts/run_coverage.ps1" -TestExe "$BUILD_BINARIESDIRECTORY/Debug/my_module_ut_exe_myproject/my_module_ut_exe_myproject.exe" -SourceFilter "*src\my_module.c" -ShowFunctions -ShowUncoveredLinesCoverage for all source files in a test
pwsh -NoProfile -ExecutionPolicy Bypass -File "deps/azure-messaging-ai-context/.github/scripts/run_coverage.ps1" -TestExe "$BUILD_BINARIESDIRECTORY/Debug/my_module_ut_exe_myproject/my_module_ut_exe_myproject.exe" -SourceFilter "*src\*.c" -ShowFunctionsQuick summary (no function/line detail)
pwsh -NoProfile -ExecutionPolicy Bypass -File "deps/azure-messaging-ai-context/.github/scripts/run_coverage.ps1" -TestExe "$BUILD_BINARIESDIRECTORY/Debug/my_module_ut_exe_myproject/my_module_ut_exe_myproject.exe" -SourceFilter "*src\my_module.c"Troubleshooting
- "vswhere.exe not found": Visual Studio is not installed
- "Microsoft.CodeCoverage.Console.exe not found": VS Enterprise is required (Community/Professional don't include this tool)
- "Coverage file was not created": The test executable crashed or failed. Run the test directly to see the error.
- "No source files matched the filter": Check the
-SourceFilterpattern. Use*src\*.cto see all files, then narrow down. Patterns use-like(wildcard), not regex. - Test failures in output: Coverage is still collected even if some tests fail. The coverage report reflects whatever code paths were executed.
Output Location
Coverage XML files are saved with timestamped names:
<script_dir>/coverage/<test_name>_<YYYYMMDD_HHmmss>.cobertura.xmlDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

