agentleFS
Microsoft AzureKnown publisherAzure/azure-messaging-ai-context/.github/skills/run-coverage/SKILL.md

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".

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
  1. Very specific:

    Run native C/C++ code coverage using Microsoft.CodeCoverage.Console.exe (Visual Studio Enterprise) and parse Cobertura XML results.

    line 9
  2. Distinctive:

    If the user provides just a module name, construct the full path:

    line 36
  3. Distinctive:

    Verify the executable exists before running coverage.

    line 41
  4. Very specific:

    All source files: "*src\*.c"

    line 47
  5. Distinctive:

    If the user wants to improve coverage, read the uncovered lines from the source file to understand what code paths are not exercised, then …

    line 73
  6. Very specific:

    "No source files matched the filter": Check the -SourceFilter pattern.

    line 108

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.ps1

Workflow

Step 1: Identify the Test Executable

The test executable path follows the pattern:

$env:BUILD_BINARIESDIRECTORY\Debug\<target_name>\<target_name>.exe

Where <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 -ShowUncoveredLines

Step 4: Analyze Results

The script outputs:

  1. Per-file summary table - Lines, Covered, Uncovered, Pct% (color-coded: green >=80%, yellow >=50%, red <50%)
  2. Per-function coverage (with -ShowFunctions) - Shows each function's coverage, sorted worst-first
  3. Uncovered line ranges (with -ShowUncoveredLines) - Groups consecutive uncovered lines into ranges (e.g., "Lines: 45-52, 78, 90-95")
  4. 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

ParameterRequiredDescription
-TestExeYesPath to the unit test executable
-SourceFilterNoWildcard patterns to filter source files (e.g., "*src\module.c")
-OutputDirNoDirectory for coverage output (default: <script_dir>/coverage/)
-ShowFunctionsNoShow per-function coverage breakdown
-ShowUncoveredLinesNoList uncovered line numbers/ranges
-SettingsFileNoXML 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 -ShowUncoveredLines

Coverage 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" -ShowFunctions

Quick 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 -SourceFilter pattern. Use *src\*.c to 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.xml

Download now (ZIP)

Does 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.