loopguard: a PHPUnit or CTest run is judged without its summary, so a failing run can end a turn green

Đang mở
#353 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Shizoqua đang làm issue này rồi.

Từ ngày 29/11/2026.

  • #355 của @Shizoqua — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cmake, php, python
Lĩnh vực
devtools, testing-qa

Hướng nghiên cứu

Start with tokeneconomizer/loopguard/turn.py and trace how VERIFY_RE and runner_verdict handle PHPUnit and CTest output; the reproduction in the issue gives four cases to check. The issue links open pull request #355, so the work is already under way.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

tokeneconomizer/loopguard/turn.py counts phpunit and ctest as test runs (VERIFY_RE), but runner_verdict knows neither runner's summary. When a later command replaces a run's exit status (ctest; git status, phpunit | tail -3), the guard judges the run by the runner's summary, and with none it falls back to the last command's status or to the output's error markers (state.ERR_RE). So a failing PHPUnit or CTest run followed by another command, or a PHPUnit run that only errored, behind a pipe, counts as passed, and the turn as ended green. That feeds the per-repository envelope a turn whose tests failed. The other way round, a passing CTest run behind a pipe counts as failed, since ERR_RE's case-insensitive FAILED matches its 0 tests failed.

The summaries, from each runner's source: PHPUnit (src/TextUI/Output/SummaryPrinter.php; DefaultResultPrinter.php in 9.6) prints OK (3 tests, 5 assertions) for a pass, which runner_verdict already reads, OK, but there were issues!, OK, but some tests were skipped! (9.6: OK, but incomplete, skipped, or risky tests!) for a pass with skips or issues, and FAILURES! or ERRORS! above its Tests: N, Assertions: N, ... counts for a failure. CTest (Source/CTest/cmCTestTestHandler.cxx) prints 67% tests passed, 1 tests failed out of 3, or 100% tests passed, 0 tests failed out of 3 when none failed (100% tests passed out of 3 on CMake's master branch).

Reproduction (offline):

from tokeneconomizer import loopguard
from tokeneconomizer.loopguard import turn

cases = [
    ("vendor/bin/phpunit; git status --short", "FAILURES!\nTests: 3, Assertions: 5, Failures: 1.\n"),
    ("vendor/bin/phpunit 2>&1 | tail -3", "ERRORS!\nTests: 3, Assertions: 2, Errors: 1.\n"),
    ("ctest --test-dir build; git status --short", "67% tests passed, 1 tests failed out of 3\n"),
    ("ctest --test-dir build | tail -3", "100% tests passed, 0 tests failed out of 3\n"),
]
for cmd, out in cases:
    g = loopguard.TurnGuard(turn_key="t")
    g.fold("Edit", {"file_path": "src/a.c", "old_string": "x", "new_string": "y"}, "ok")
    g.fold("Bash", {"command": cmd}, out, 0)
    print(f"{cmd:45} verdict={turn.runner_verdict(out)} ended_green={g.resolved_proxy()}")

Expected: the three failing runs read verdict=True ended_green=False, and the passing CTest run verdict=False ended_green=True.

Actual:

vendor/bin/phpunit; git status --short        verdict=None ended_green=True
vendor/bin/phpunit 2>&1 | tail -3             verdict=None ended_green=True
ctest --test-dir build; git status --short    verdict=None ended_green=True
ctest --test-dir build | tail -3              verdict=None ended_green=False

Upstream main: 747b8016538c13da7ba9d455b89e5e6595bf5294

Python 3.13.18, Linux

Ngôn ngữ chính
Python
Star
7.4k
Fork
500
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
123

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/TokenEconomizer

Tất cả issue của microsoft/TokenEconomizer

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.