Skip to content

refactor(tests): share one make_dir_link from kiro_crew.testing.links - #15060

Merged
chenmingwei23 merged 1 commit into
mainfrom
refactor/shared-make-dir-link-10494
Oct 1, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
refactor/shared-make-dir-link-10494

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Tests that stage a Windows directory junction share one make_dir_link helper instead of four private copies.

The junction-staging helper exists four times on main: the canonical make_dir_link in test/conftest.py, and a private _make_dir_link mirror in each of the auto_improvement (test_pollute.py), code_review_sage (test_followup.py) and design_critique (test_backend_routes.py) app test packages. The mirrors exist because the app-embedded test packages under src/kiro_crew/apps/builtins never see test/conftest.py. Issue #10494 was filed with three copies; PR #14595 added the fourth.

Why it matters

The four copies already drift in shape (a type: ignore, a module-level getattr block, differing docstrings). A fix to one, such as the rule that the Windows arm must stay an unconditional CreateJunction rather than symlink_or_junction, does not reach the others, so a Developer-Mode runner could silently test the symlink arm in one copy while still reporting green.

Not a goal

  • make_escaping_link and the ad-hoc inline CreateJunction calls in other test files stay as they are.
  • No change to skip behaviour: none of the helpers skips, and callers keep their own skips.

What changed (motivation → approach → change)

Four copies of one test helper → give it a home both test trees can import → move it to kiro_crew.testing (src/kiro_crew/testing/links.py), the package that already ships test utilities in the runtime wheel and is importable from test/ and the app trees alike.

make_dir_link(link, target) keeps the conftest docstring and the "deliberately not platform_compat.symlink_or_junction" rationale. On Windows it calls _winapi.CreateJunction unconditionally, with import _winapi function-local so POSIX collection works, and looks it up with getattr so mypy stays clean on Linux. Elsewhere it is link.symlink_to(target, target_is_directory=True). Behaviour is identical to every copy it replaces.

test/conftest.py now re-exports it, so its 57 from conftest import make_dir_link importers are unchanged. The three app mirrors are deleted and import the shared helper as _make_dir_link; design_critique also drops its module-level _winapi / _create_junction block, which only that mirror used. The kiro_crew/testing/__init__.py docstring lists the new module, and docs/system-specs/common/testing-conventions.md says where the helper lives.

Backwards compatibility

Compatible: from conftest import make_dir_link still resolves, and every call site keeps its name and signature. kiro_crew.testing.links.make_dir_link is a new public name in the wheel.

Tests

test/test_testing_links.py pins both arms of the new helper on any platform, so the Coverage Gate sees links.py at 100% on Linux:

  • the POSIX arm makes a directory symlink that resolves to the target;
  • the Windows arm, with IS_WINDOWS forced on and a fake _winapi, calls CreateJunction(target, link) and nothing else.

Run locally on Linux, all green: the three app test files, test/test_workflows_store_restore.py and test/test_workflows_run_identity.py (conftest importers), and test/test_coverage_omit_contract.py. mypy is clean on the new module and the three app test files. The Windows CI lanes exercise the real junction arm.

Manual verification

N/A — unit coverage sufficient: the helper has no runtime caller, only tests.

Related Issues

Closes #10494

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested a review from a team as a code owner September 29, 2026 17:22
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of fa20bc99190747855bd9aa978f2b19f8d1ce3287 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify one Windows CI lane ran green on this head: only there does the shared helper's real junction arm run — the new unit test fakes _winapi.

What this change ships

Inventory (6 items) — 6 justified

Intent: one shared make_dir_link test helper replaces four drifting private copies (closes #10494) — a FIX (consolidation of a reported duplication).

  1. make_dir_link gets one home, kiro_crew.testing.links, a new public name in the shipped wheel — justified
  2. test/conftest.py re-exports it, so its 57 importers keep working unchanged — justified
  3. The three app-test private mirrors are deleted and import the shared helper — justified
  4. design_critique's module-level _winapi/_create_junction lookup is removed, folded into the helper — justified
  5. New test pins both helper arms so the Coverage Gate sees the module at 100% on Linux — justified
  6. testing-conventions spec and kiro_crew.testing docstring name the new home, same commit — justified

[FIRST-PRINCIPLES-REVIEWED] fa20bc9

Description read

[DESCRIPTION-READ] 7c428813576d38d40f5e1a9f39702b3420d5de60de1ef484bd0b85181b9481fe

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of fa20bc99190747855bd9aa978f2b19f8d1ce3287 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fa20bc9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt fa20bc99190747855bd9aa978f2b19f8d1ce3287: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of fa20bc99190747855bd9aa978f2b19f8d1ce3287 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Confirm a Windows CI lane ran green on this PR, since local verification was Linux-only and the junction arm only executes there.

[DESIGN-REVIEWED] fa20bc9

Description read

[DESCRIPTION-READ] fd594098fb195c3c42a7dbebcb15dbad1b172cba6a4bc8924d59d2c6179b7ed9

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed fa20bc99190747855bd9aa978f2b19f8d1ce3287 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fa20bc9

Verdict parsed from the review's SHA-scoped output markers for commit fa20bc99190747855bd9aa978f2b19f8d1ce3287.

False positive or not applicable? A repository writer can comment:
/ai-review override fable fa20bc99190747855bd9aa978f2b19f8d1ce3287: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the refactor/shared-make-dir-link-10494 branch 2 times, most recently from 4365829 to d3068fc Compare September 29, 2026 22:34
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 29, 2026
@iamwhatever
iamwhatever force-pushed the refactor/shared-make-dir-link-10494 branch from d3068fc to 281e9a4 Compare September 29, 2026 23:19
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 29, 2026
@iamwhatever
iamwhatever force-pushed the refactor/shared-make-dir-link-10494 branch from 281e9a4 to 16663a9 Compare September 30, 2026 08:23
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
Four private copies of the junction-staging helper (test/conftest.py plus
mirrors in the auto_improvement, code_review_sage and design_critique app
tests) collapse into kiro_crew.testing.links.make_dir_link. The conftest
re-exports it, so its 57 importers are unchanged. Behaviour is identical:
unconditional CreateJunction on Windows, a directory symlink elsewhere.

Closes #10494
@iamwhatever
iamwhatever force-pushed the refactor/shared-make-dir-link-10494 branch from 16663a9 to fa20bc9 Compare September 30, 2026 12:47
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 30, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) October 1, 2026 04:47
@chenmingwei23
chenmingwei23 merged commit 0ebe1b3 into main Oct 1, 2026
147 of 149 checks passed
@chenmingwei23
chenmingwei23 deleted the refactor/shared-make-dir-link-10494 branch October 1, 2026 05:20
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 1, 2026
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.

test helpers: collapse three private make_dir_link junction-staging copies into one importable helper

2 participants