Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/loopzero/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,12 @@ def _mergify_timeout_detail(
)
detail = f"still queued in {queue}. {location}"
if state.unmet_conditions:
detail += ". Unmet candidate conditions: " + "; ".join(state.unmet_conditions)
labels = [label.encode() for label in state.unmet_conditions[:4]]
shown = [label[:160].decode(errors="ignore") + ("…" if len(label) > 160 else "")
for label in labels]
detail += ". Unmet candidate conditions: " + "; ".join(shown)
if omitted := len(state.unmet_conditions) - len(shown):
detail += f"; {omitted} more"
return detail


Expand Down
20 changes: 10 additions & 10 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4453,22 +4453,22 @@ def test_mergify_reports_current_queue_attempt(wt, gh, capsys, monkeypatch, conf
assert (f"{URL}#issuecomment-43" in out) is (kind == "current")


@pytest.mark.parametrize("result", ["blocking", "neutral", "skipped", None])
@pytest.mark.parametrize("result", ["blocking", "neutral", "skipped", None, "long", "many"])
def test_mergify_timeout_reports_evaluated_candidate_conditions(wt, gh, capsys, monkeypatch, result):
head = commit_mergify_configuration(wt)
arm_approved_ready_pr(gh, head, wt, isDraft=False)
monkeypatch.setattr(mergify, "configured", lambda *_: True)
monkeypatch.setattr(mergify, "markers", lambda *_: (True, False))
monkeypatch.setattr(mergify, "mark_confirmed", lambda *_: None)
responses = iter([None, MERGIFY_QUEUE_FIXTURE["candidate_responses"][result or "missing"]])
monkeypatch.setattr(mergify, "api_get", lambda *_: next(responses))

monkeypatch.setattr(mergify, "markers", lambda *_: (True, True))
payload = MERGIFY_QUEUE_FIXTURE["candidate_responses"]["blocking" if result in {"long", "many"} else result or "missing"]
if extra := {"long": 1, "many": 30}.get(result, 0):
conditions = payload["mergeability_check"]["conditions_evaluation"]
monkeypatch.setitem(conditions, "subconditions", conditions["subconditions"] + [{"match": False, "label": "界" * 3000}] * extra)
monkeypatch.setattr(mergify, "api_get", lambda *_: payload)
code, out, err = run(capsys, "merge", "--wait=0")

assert (code, err) == (3, "")
assert f"https://github.com/{REPO}/pull/42" in out
assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) is (result == "blocking")
assert (code, err) == (3, "") and f"https://github.com/{REPO}/pull/42" in out
assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) == (result in {"blocking", "long", "many"})
assert "failed" not in out and "check-success = checks" not in out
assert len(out.encode()) < 2048 and ("27 more" in out) == (extra == 30)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Assert that the oversized condition retains a readable preview

The size and omission-count assertions would still pass if every oversized label rendered as an empty string. In the extra == 1 case, also assert that the output contains a prefix of the multibyte label followed by the truncation marker. This directly covers the preview users see.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Check that the oversized condition has a visible preview

In the long case, the condition asserted here is the original short one. Silently dropping the oversized label would still satisfy the byte limit and pass this case. Assert that 界 appears in the output for long so the test covers both the preview and its size bound.



@pytest.mark.parametrize("queue_state", ["unsafe", "error", "safe", "becomes_unsafe"])
Expand Down
Loading