Skip to content

feat(test): add ut-summary.json generation for test results and coverage - #521

Merged
lzwind merged 1 commit into
linuxdeepin:masterfrom
add-uos:feat/add-ut-summary-json
Aug 13, 2026
Merged

feat(test): add ut-summary.json generation for test results and coverage#521
lzwind merged 1 commit into
linuxdeepin:masterfrom
add-uos:feat/add-ut-summary-json

Conversation

@add-uos

@add-uos add-uos commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add tests/gen-ut-summary.py: standalone script to parse gtest XML reports and lcov coverage data, generating a structured ut-summary.json
  • Update tests/test-prj-running.sh: export env vars, use -j$(nproc), set +e for test running, call gen-ut-summary.py, propagate test exit code

Output format

Running test-prj-running.sh now generates build-ut/ut-summary.json:

{
  "test_cases": {
    "total": 1144,
    "passed": 1143,
    "failed": 1
  },
  "line_coverage": {
    "total": 17414,
    "passed": 14468,
    "failed": 2946,
    "coverage": "83.10%"
  },
  "function_coverage": {
    "total": 1204,
    "passed": 1192,
    "failed": 12,
    "coverage": "99.00%"
  }
}

Test plan

  • Verified with existing build data: python3 tests/gen-ut-summary.py produces correct JSON
  • gtest XML parsing works with single test binary output
  • lcov --summary parsing extracts line and function coverage

Summary by Sourcery

Generate a unified JSON summary of unit test results and coverage as part of the test project run.

New Features:

  • Introduce gen-ut-summary.py to aggregate gtest XML results and lcov coverage into ut-summary.json.
  • Extend test-prj-running.sh to produce ut-summary.json alongside existing test and coverage artifacts.

Enhancements:

  • Export build and report directories and project root as environment variables for downstream tooling.
  • Adjust test-prj-running.sh to run tests with dynamic parallelism, preserve the test exit code, and ensure gtest XML output is written to a dedicated report directory.

- Add gen-ut-summary.py: standalone script to parse gtest XML and lcov
  coverage data, output structured JSON (test_cases/line_coverage/function_coverage)
- Update test-prj-running.sh: export env vars, use -j$(nproc), set +e
  for test running, call gen-ut-summary.py, propagate test exit code

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @add-uos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a Python helper to generate a unified ut-summary.json from gtest XML and lcov coverage output, and wires it into the bash test runner with proper env setup, parallel build, resilient test execution, and exit-code propagation.

File-Level Changes

Change Details Files
Introduce a Python script that aggregates gtest XML test results and lcov coverage summaries into a structured ut-summary.json file.
  • Implement parse_gtest_xml to walk XML reports, supporting both gtest and JUnit-style roots, and compute total/passed/failed counts.
  • Implement parse_lcov_summary to shell out to lcov --summary, parse line/function coverage using regex, and normalize totals, hits, and percentage strings.
  • Add a main routine that reads projectdir/builddir/reportdir and optional override env vars, resolves default paths for gtest XML and coverage.info, builds the result JSON structure, and writes/prints ut-summary.json.
tests/gen-ut-summary.py
Extend the shell test runner to set up required environment, run tests more robustly, generate gtest XML into a predictable location, invoke the summary generator, and return the original test exit code.
  • Export builddir and reportdir as env variables, compute scriptdir and projectdir based on the test script location.
  • Switch make to use -j$(nproc) for dynamic parallelism instead of a fixed -j8.
  • Create GTEST_XML_DIR under the build report directory, run the gtest binary with XML output pointing there, and capture its exit code using set +e/set -e.
  • After lcov/html/log copy steps, call the Python summary generator and exit with the captured test_exit_code instead of always exiting 0.
tests/test-prj-running.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "tests/test-prj-running.sh": {
            "b": [
                "export builddir=build",
                "export reportdir=build-ut",
                "export projectdir=$(cd \"$scriptdir/..\"; pwd)"
            ]
        }
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lzwind
lzwind merged commit ea95138 into linuxdeepin:master Aug 13, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants