### Verify Installer Installation (PowerShell) Source: https://covdbg.com/docs/getting-started/installation After installing covdbg using the recommended installer, open a new terminal and run this command to verify the installation by checking the help output. ```powershell covdbg --help ``` -------------------------------- ### Quick Example: Running and Exporting Coverage Source: https://covdbg.com/docs/use-cases/ci-cd Demonstrates a quick example of how to run tests with covdbg to generate coverage data, and then export that data to the LCOV format for use with downstream tools. This is a common starting point for CI integration. ```powershell # 1. Run tests with coverage covdbg --output coverage.covdb tests.exe # 2. Export to LCOV covdbg convert -i coverage.covdb -f LCOV -o coverage.lcov # 3. Upload to coverage service (example) codecov --file coverage.lcov ``` -------------------------------- ### Verify covdbg Installation and Basic Test (PowerShell) Source: https://covdbg.com/docs/getting-started/installation Run these commands to check the covdbg version, display help, and perform a basic coverage test on a program if you have one built with PDBs. ```powershell # Check version and help covdbg --help # Test with a simple program (if you have one built with PDBs) $env:COVDBG_LICENSE = "" covdbg --output "test.covdb" "your_program.exe" ``` -------------------------------- ### Basic covdbg Usage with Environment License Source: https://covdbg.com/docs/cli-reference Demonstrates how to use the covdbg tool with a license provided via an environment variable. This is a fundamental way to start using the tool for coverage collection. ```powershell $env:COVDBG_LICENSE = "" covdbg --output "C:\path\to\results.covdb" "C:\path\to\tests.exe" ``` -------------------------------- ### covdbg Configuration File: Complete Example Source: https://covdbg.com/llms A comprehensive example of a .covdbg.yaml configuration file. It includes settings for log level, source root, file inclusion/exclusion patterns, function exclusion patterns, and target-specific overrides. ```yaml version: 1 source_root: "." settings: log_level: "INFO" coverage: default: files: include: - "src/**/*.cpp" - "src/**/*.h" - "lib/**/*.cpp" exclude: - "build/**" - "third_party/**" - "**/*_test.cpp" functions: exclude: - "operator*" - "*::" targets: - target: "integration_tests.exe" type: override files: include: - "integration/**" ``` -------------------------------- ### Covdbg File Pattern Examples Source: https://covdbg.com/docs/configuration Illustrates file pattern syntax for covdbg's coverage filters, including examples for recursive matching and specific directory exclusions. ```yaml coverage: default: files: include: - "src/**/*.cpp" # All .cpp files under src/ recursively - "lib/**" # Everything under lib/ exclude: - "build/**" # Exclude build directory - "**/test_*". # Exclude test files ``` -------------------------------- ### Activate CI/CD License (PowerShell) Source: https://covdbg.com/docs/getting-started/installation For CI/CD environments, activate your license by setting the COVDBG_LICENSE environment variable with your JWT token. Store the token as a secret. ```powershell $env:COVDBG_LICENSE = "" ``` -------------------------------- ### Run Coverage Analysis with Covdbg Source: https://covdbg.com/docs/getting-started/quick-start This command runs code coverage analysis using a specified configuration file and outputs the results to a .covdb file. It requires the path to the configuration file, the output file, and the executable to analyze. ```bash covdbg --config .covdbg.yaml --output out.covdb tests.exe ``` -------------------------------- ### Covdbg Automatic Discovery Example (File Structure) Source: https://covdbg.com/docs/reference/configuration This example illustrates the file structure for automatic discovery of the .covdbg.yaml configuration file. The configuration file should be placed in the same directory as the executable being analyzed. ```css C:\project\build\ ├── tests.exe ├── .covdbg.yaml └── tests.pdb ``` -------------------------------- ### Setup covdbg Action for GitHub Actions Source: https://covdbg.com/docs/github-actions Installs the covdbg tool on your GitHub Actions runner. Specify the desired version or use 'latest'. ```yaml - name: Setup covdbg uses: covdbg/setup-covdbg@v0 with: version: '1.0.0' # Specify version or use 'latest' ``` -------------------------------- ### Merge Multiple .covdb Databases Source: https://covdbg.com/docs/cli-reference Shows how to merge several `.covdb` files into one. This example uses line continuation characters for readability when specifying multiple input files. ```powershell covdbg merge \ --input "tests-suite1.covdb" \ --input "tests-suite2.covdb" \ --input "tests-suite3.covdb" \ --output "all-tests.covdb" ``` -------------------------------- ### Analyze Executable for Coverage Symbols Source: https://covdbg.com/docs/cli-reference Provides an example of using the `analyze` subcommand to generate a `.covdb` database from an executable without running it. This captures symbol information and can include uncovered code. ```powershell covdbg analyze --input "C:\path\to\app.exe" --output "C:\path\to\app-symbols.covdb" ``` -------------------------------- ### Activate Local License (PowerShell) Source: https://covdbg.com/docs/getting-started/installation To activate a local license file for covdbg, set the COVDBG_LICENSE_FILE environment variable to the path of your license file. ```powershell $env:COVDBG_LICENSE_FILE = "C:\path\to\license.jwt" ``` -------------------------------- ### Complete Covdbg Configuration Example Source: https://covdbg.com/docs/configuration A comprehensive covdbg configuration including source root, logging settings, detailed file and function include/exclude patterns, and target-specific overrides for integration tests. ```yaml version: 1 source_root: "." settings: log_level: "INFO" log_file: "C:/logs/covdbg.log" coverage: default: files: include: - "src/**/*.cpp" - "src/**/*.h" - "lib/**/*.cpp" exclude: - "build/**" - "third_party/**" - "**/*_test.cpp" functions: include: - "*" exclude: - "operator*" - "*::*" targets: - target: "integration_tests.exe" type: override files: include: - "integration/**" ``` -------------------------------- ### Add Portable covdbg to PATH (PowerShell) Source: https://covdbg.com/docs/getting-started/installation For a portable installation, you can temporarily add the covdbg directory to your PATH for the current session or permanently add it to the user's PATH. ```powershell # Temporary: Add to PATH for current session only $env:PATH += ";C:\Tools\covdbg" # Permanent: Add to user PATH (no admin required) [Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";C:\Tools\covdbg", "User") ``` -------------------------------- ### Analyze Binary for Symbols with Covdbg Source: https://covdbg.com/docs/getting-started/quick-start This command analyzes an executable binary to extract symbol information, which can be used for coverage analysis. It requires the path to the executable and an output file name for the symbol database. ```bash covdbg analyze -i app.exe -o symbols.covdb ``` -------------------------------- ### Use Covdbg Config from CLI (PowerShell) Source: https://covdbg.com/docs/reference/configuration These PowerShell examples show how to use the covdbg configuration file from the command line. Options include specifying an explicit path, using an environment variable, or relying on automatic discovery when the config file is placed next to the executable. ```powershell covdbg --config "C:\project\.covdbg.yaml" --output "results.covdb" "tests.exe" ``` ```powershell $env:COVDBG_CONFIG = "C:\project\.covdbg.yaml" covdbg --output "results.covdb" "tests.exe" ``` ```powershell covdbg --output "results.covdb" "C:\project\build\tests.exe" ``` -------------------------------- ### CI Pipeline Example with Codecov Source: https://covdbg.com/docs/guides/report-formats This workflow demonstrates a typical CI pipeline: running tests to generate a .covdb file, converting it to LCOV format, and then uploading it to Codecov using their CLI. ```powershell # Run tests with coverage covdbg --output coverage.covdb tests.exe # Export to LCOV for Codecov covdbg convert -i coverage.covdb -f LCOV -o coverage.lcov # Upload (example with Codecov CLI) codecov --file coverage.lcov ``` -------------------------------- ### Convert .covdb to LCOV Format Source: https://covdbg.com/docs/cli-reference Provides an example of using the `convert` subcommand to export a `.covdb` file into the LCOV format. This is useful for integrating with other coverage reporting tools that support LCOV. ```powershell covdbg convert --input "C:\path\to\results.covdb" --format LCOV --output "C:\path\to\coverage.lcov" ``` -------------------------------- ### GitHub Actions Workflow for Coverage Source: https://covdbg.com/llms This GitHub Actions workflow automates the process of building a project, running coverage tests using covdbg, converting the results to LCOV format, and uploading them to Codecov. It handles setup, build, execution, and reporting steps. ```yaml name: Coverage on: [push, pull_request] jobs: coverage: runs-on: windows-latest steps: - uses: actions/checkout@v4 - name: Setup covdbg uses: covdbg/setup-covdbg@v0 with: version: '1.0.0' - name: Build run: | cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build build - name: Run Coverage shell: pwsh env: COVDBG_APPDATA: .covdbg COVDBG_FETCH_LICENSE: true # Open source # Or for commercial: COVDBG_LICENSE: ${{ secrets.COVDBG_LICENSE }} run: | covdbg --config .covdbg.yaml --output tests.covdb build/tests.exe - name: Convert to LCOV run: covdbg convert -i tests.covdb -f LCOV -o coverage.lcov - name: Upload to Codecov uses: codecov/codecov-action@v5 with: files: coverage.lcov env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} ``` -------------------------------- ### Merge Multiple Covdbg Databases Source: https://covdbg.com/docs/getting-started/quick-start This command merges multiple .covdb files into a single database. This is useful for combining coverage results from different test runs or configurations. It requires specifying each input file and the desired output file. ```bash covdbg merge -i a.covdb -i b.covdb -o merged.covdb ``` -------------------------------- ### Merging Multiple Test Runs Source: https://covdbg.com/docs/use-cases/ci-cd Provides an example of how to merge coverage results from multiple test executables or parallel test jobs. This involves running covdbg for each test suite separately, then merging the resulting `.covdb` files before exporting. ```powershell # Run each test suite covdbg --output unit.covdb unit_tests.exe covdbg --output integration.covdb integration_tests.exe # Merge results covdbg merge -i unit.covdb -i integration.covdb -o merged.covdb # Export merged coverage covdbg convert -i merged.covdb -f LCOV -o coverage.lcov ``` -------------------------------- ### Merge Multiple Test Runs Source: https://covdbg.com/docs/guides/report-formats This example shows how to merge coverage results from multiple test runs into a single .covdb file. This is useful when different test suites produce separate coverage reports that need to be combined. ```powershell # Run different test suites covdbg --output unit.covdb unit_tests.exe covdbg --output integration.covdb integration_tests.exe # Merge results covdbg merge -i unit.covdb -i integration.covdb -o merged.covdb # Export merged coverage covdbg convert -i merged.covdb -f LCOV -o coverage.lcov ``` -------------------------------- ### Set covdbg License via Environment Variable Source: https://covdbg.com/docs/troubleshooting Configures the covdbg license using environment variables, either by directly providing a JWT token or a path to a license file. This is necessary to avoid 'evaluation mode' limitations and ensure proper .covdb file generation. ```powershell $env:COVDBG_LICENSE = "" # Or $env:COVDBG_LICENSE_FILE = "C:\path\to\license.jwt" covdbg --output "results.covdb" "tests.exe" ``` -------------------------------- ### Fetch Free License for Open Source Projects with covdbg Source: https://covdbg.com/hello-from-covdbg This command shows how to obtain a free license for covdbg when working with open-source projects. The `--fetch-license` flag automatically provisions a license by verifying the repository's public status. ```powershell covdbg --fetch-license -o coverage.covdb tests.exe ``` -------------------------------- ### covdbg Usage with Configuration File for Filtering Source: https://covdbg.com/docs/cli-reference Shows how to use covdbg with a configuration file to specify filtering rules. This allows for more granular control over which code is included in the coverage report. ```powershell covdbg --config "C:\path\to\.covdbg.yaml" --output "C:\path\to\results.covdb" "C:\path\to\tests.exe" ``` -------------------------------- ### Combine Analysis and Test Coverage Source: https://covdbg.com/docs/cli-reference Illustrates a two-step process to achieve complete code coverage: first analyzing the executable to capture all code, then running tests to capture executed code, and finally merging the results. ```powershell # 1. Analyze all code (captures uncovered functions) covdbg analyze --input "app.exe" --output "all-code.covdb" # 2. Run tests (captures executed code) covdbg --output "tests.covdb" "app.exe" --run-tests ``` -------------------------------- ### Export Coverage Data to GCOV Format Source: https://covdbg.com/docs/getting-started/quick-start This command converts the collected coverage data from a .covdb file into the GCOV format, typically used with GCC. It requires the input .covdb file and the output directory. ```bash covdbg convert -i out.covdb -f GCOV -o ./gcov/ ``` -------------------------------- ### Analyze Executable with Filtering Source: https://covdbg.com/docs/cli-reference Demonstrates analyzing an executable using filtering rules defined in a configuration file. This allows for selective inclusion of code during the analysis phase. ```powershell covdbg analyze --input "C:\path\to\app.exe" --output "C:\path\to\app-symbols.covdb" --config "C:\path\to\.covdbg.yaml" ``` -------------------------------- ### Export Coverage Data to LCOV Format Source: https://covdbg.com/docs/getting-started/quick-start This command converts the collected coverage data from a .covdb file into the LCOV format for compatibility with other tools. It requires the input .covdb file and the desired output file name. ```bash covdbg convert -i out.covdb -f LCOV -o coverage.lcov ``` -------------------------------- ### Typical CI Workflow Steps Source: https://covdbg.com/docs/use-cases/ci-cd Outlines the standard steps in a CI workflow for integrating code coverage: building tests, running covdbg, exporting to LCOV, and uploading artifacts. This process helps catch regressions and monitor coverage trends. ```text Build Tests → Run covdbg → Export LCOV → Upload/Store Artifacts ``` -------------------------------- ### Fetch License Information with Covdbg CLI Source: https://covdbg.com/llms Fetches and displays license information for open-source components used by covdbg. This command is useful for compliance and understanding the licensing of the tool's dependencies. ```bash covdbg --fetch-license -c .covdbg.yaml -o out.covdb tests.exe ``` -------------------------------- ### Run covdbg in Silent Mode for CI Source: https://covdbg.com/docs/reference/troubleshooting Executes covdbg with logging completely disabled, showing only test output. This is ideal for continuous integration environments where extraneous messages should be suppressed. ```powershell covdbg --log-level NONE --output "results.covdb" "tests.exe" ``` -------------------------------- ### Run Coverage with Covdbg CLI Source: https://covdbg.com/llms Executes code coverage analysis using the covdbg CLI. It requires a configuration file and specifies the output database file and the executable to test. Dependencies include the covdbg executable and a valid .covdbg.yaml configuration file. ```bash covdbg -c .covdbg.yaml -o out.covdb tests.exe ``` -------------------------------- ### Run covdbg with Debug Logging Source: https://covdbg.com/docs/reference/troubleshooting Executes covdbg with detailed debug logging enabled to help diagnose filtering issues or other runtime problems. This provides verbose output that can be crucial for troubleshooting. ```powershell covdbg --log-level DEBUG --output "results.covdb" "tests.exe" ``` -------------------------------- ### Configure covdbg Coverage Include Patterns Source: https://covdbg.com/docs/reference/troubleshooting Defines file inclusion patterns for coverage analysis in the .covdbg.yaml configuration file. This helps ensure that relevant source files are included in the coverage report. ```yaml version: 1 coverage: default: files: include: - "**/*.cpp" - "**/*.h" ``` -------------------------------- ### Covdbg Run Coverage for Open Source Projects Source: https://covdbg.com/llms This snippet demonstrates how to run covdbg for coverage analysis in open-source projects. It specifically sets the environment variable COVDBG_FETCH_LICENSE to true, indicating that the tool should attempt to fetch a license automatically. ```yaml - name: Run Coverage env: COVDBG_FETCH_LICENSE: true run: covdbg --config .covdbg.yaml -o coverage.covdb tests.exe ``` -------------------------------- ### Run Tests and Export Coverage with covdbg Source: https://covdbg.com/hello-from-covdbg This snippet demonstrates the core workflow of using covdbg to run tests with coverage enabled and then convert the output to the LCOV format. It requires a configuration file and the executable to be tested. ```powershell # Run tests with coverage covdbg --config .covdbg.yaml --output coverage.covdb tests.exe # Export to LCOV for reporting covdbg convert -i coverage.covdb -f LCOV -o coverage.lcov ``` -------------------------------- ### Set Custom covdbg Application Data Directory Source: https://covdbg.com/docs/reference/troubleshooting Specifies a custom directory for covdbg to store application data, including logs. This is useful for environments with restricted write access to the default %APPDATA% location. ```powershell covdbg --appdata "C:\custom\covdbg" --output "results.covdb" "tests.exe" ``` -------------------------------- ### Convert covdbg Output to GCOV Format Source: https://covdbg.com/docs/reference/troubleshooting Converts the .covdb output file to the GCOV format. This command requires an input .covdb file, the GCOV format, and an existing directory path for the output files. ```powershell New-Item -ItemType Directory -Force -Path "gcov-output" covdbg convert --input "results.covdb" --format GCOV --output "gcov-output\" ``` -------------------------------- ### Covdbg Run Coverage for Commercial Projects Source: https://covdbg.com/llms This snippet shows how to execute covdbg for coverage analysis in commercial projects. It requires the COVDBG_LICENSE environment variable to be set, typically with a secret token, to authenticate the commercial license. ```yaml - name: Run Coverage env: COVDBG_LICENSE: ${{ secrets.COVDBG_LICENSE }} run: covdbg --config .covdbg.yaml -o coverage.covdb tests.exe ``` -------------------------------- ### covdbg Usage with Arguments Passed to Target Program Source: https://covdbg.com/docs/cli-reference Illustrates how to pass arguments directly to the target program being profiled by covdbg. This is useful for controlling test execution, such as filtering specific tests or repeating them. ```powershell covdbg --output "results.covdb" "tests.exe" --gtest_filter="MyTest.*" --gtest_repeat=3 ``` -------------------------------- ### Normalize Source Paths in covdbg Configuration Source: https://covdbg.com/docs/reference/troubleshooting Sets the 'source_root' option in the .covdbg.yaml file to normalize source file paths in exports. This is useful when dealing with absolute paths or paths from different build environments. ```yaml version: 1 source_root: "." # Paths relative to config file location coverage: default: files: include: - "src/**" ``` -------------------------------- ### Codecov Integration: Basic Coverage Upload Source: https://covdbg.com/llms This basic Codecov integration workflow outlines the three essential steps: running tests with covdbg to generate coverage data, converting the data to LCOV format, and then uploading the LCOV file to Codecov using the codecov-action. ```yaml # 1. Run tests with coverage - name: Run tests run: covdbg -c .covdbg.yaml -o coverage.covdb tests.exe # 2. Convert to LCOV - name: Convert run: covdbg convert -i coverage.covdb -f LCOV -o coverage.lcov # 3. Upload - name: Upload to Codecov uses: codecov/codecov-action@v5 with: files: coverage.lcov env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} ``` -------------------------------- ### Generate Baseline Coverage Database Source: https://covdbg.com/docs/use-cases/legacy-refactoring Runs existing tests under covdbg to capture a baseline code coverage database. This serves as a starting point to understand current test coverage. ```powershell covdbg --output "C:\path\to\baseline.covdb" "C:\path\to\existing_tests.exe" ``` -------------------------------- ### Set Custom covdbg Log File Path Source: https://covdbg.com/docs/reference/troubleshooting Configures covdbg to write detailed logs to a specified file path instead of the default location. This is helpful for centralized log management or when the default location is inaccessible. ```powershell covdbg --log-file "C:\path\to\debug.log" --output "results.covdb" "tests.exe" ``` -------------------------------- ### Run Covdbg with Automatic Configuration Discovery (PowerShell) Source: https://covdbg.com/docs/configuration This command executes covdbg, relying on automatic discovery of the configuration file. The `.covdbg.yaml` file should be placed in the same directory as the executable being analyzed. Dependencies: covdbg executable. ```powershell covdbg --output "results.covdb" "C:\project\build\tests.exe" ``` -------------------------------- ### Convert covdbg Output to LCOV Format Source: https://covdbg.com/docs/reference/troubleshooting Converts the .covdb output file to the LCOV format. This command requires specifying an input .covdb file, the output format, and a valid file path for the output LCOV file. ```powershell # Correct: file path covdbg convert --input "results.covdb" --format LCOV --output "coverage.lcov" # Wrong: directory path covdbg convert --input "results.covdb" --format LCOV --output "coverage\" ``` -------------------------------- ### Convert .covdb to GCOV Format Source: https://covdbg.com/docs/cli-reference Illustrates how to convert a `.covdb` file to the GCOV format. This involves specifying an output directory where the `.gcov` files will be generated. ```powershell # First create the output directory New-Item -ItemType Directory -Force -Path "C:\path\to\gcov" covdbg convert --input "C:\path\to\results.covdb" --format GCOV --output "C:\path\to\gcov\" ``` -------------------------------- ### Run Covdbg with Configuration from Environment Variable (PowerShell) Source: https://covdbg.com/docs/configuration This command shows how to set the covdbg configuration path using an environment variable (`COVDBG_CONFIG`). The covdbg tool will automatically pick up the configuration from this variable. Dependencies: covdbg executable. ```powershell $env:COVDBG_CONFIG = "C:\project\.covdbg.yaml" covdbg --output "results.covdb" "tests.exe" ``` -------------------------------- ### Set covdbg License Token or File Path Source: https://covdbg.com/docs/reference/troubleshooting Configures the covdbg license using either a direct JWT token or a path to a license file. This is essential for avoiding 'evaluation mode' limitations and ensuring proper .covdb file generation. ```powershell $env:COVDBG_LICENSE = "" # Or $env:COVDBG_LICENSE_FILE = "C:\path\to\license.jwt" # Then run covdbg --output "results.covdb" "tests.exe" ``` -------------------------------- ### Merge Coverage Databases using covdbg CLI Source: https://covdbg.com/docs/cli This command merges multiple coverage database files into a single output file. It takes one or more '--input' arguments specifying the .covdb files to merge and an '--output' argument for the resulting file. Environment variables can be used as alternatives to command-line options. ```powershell covdbg merge --input "all-code.covdb" --input "tests.covdb" --output "complete.covdb" ``` -------------------------------- ### Run Covdbg with Explicit Configuration Path (PowerShell) Source: https://covdbg.com/docs/configuration This command demonstrates how to explicitly specify the configuration file path for covdbg using the `--config` argument. It also specifies the output file and the executable to analyze. Dependencies: covdbg executable. ```powershell covdbg --config "C:\project\.covdbg.yaml" --output "results.covdb" "tests.exe" ``` -------------------------------- ### Run Covdbg for Code Coverage (PowerShell) Source: https://covdbg.com/docs/open-source This PowerShell command executes the covdbg tool to generate code coverage data. It uses the '--fetch-license' flag to automatically obtain a license for public repositories and outputs the coverage data to 'coverage.covdb'. ```powershell covdbg --fetch-license -o coverage.covdb myapp.exe ``` -------------------------------- ### Merge Subcommand Source: https://covdbg.com/llms Combine multiple coverage databases into a single .covdb file. ```APIDOC ## MERGE SUBCOMMAND ### Description Combine multiple coverage databases. ### Method `covdbg merge` ### Endpoint `covdbg merge --input --input --output ` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```powershell covdbg merge -i unit.covdb -i integration.covdb -o merged.covdb ``` ### Response #### Success Response (200) A new .covdb file containing the merged coverage data is created. #### Response Example (No specific response body, output is a file) ### Essential options: - `--input `: Path to a coverage database file (can be specified multiple times) - `--output `: Path for the merged .covdb file ``` -------------------------------- ### covdbg CLI: Run Program Under Coverage Source: https://covdbg.com/llms This command executes a specified program while tracking code coverage. Essential options include specifying the configuration file and the output file for the coverage data. Arguments can be passed to the target program. ```powershell covdbg [OPTIONS] [args...] # Basic usage covdbg --config .covdbg.yaml --output results.covdb tests.exe # Pass arguments to target covdbg -c .covdbg.yaml -o results.covdb tests.exe --gtest_filter="MyTest.*" # Open source (auto license) covdbg --fetch-license -c .covdbg.yaml -o results.covdb tests.exe ```