Skip to content

Add swift test to hook rewrite registry #765

@Decorus2009

Description

@Decorus2009

Summary

swift build is in the hook rewrite registry (src/discover/registry.rs), but swift test is not. This means the PreToolUse hook rewrites swift buildrtk swift build automatically, but swift test passes through unfiltered.

Since swift-build.toml already exists as a built-in TOML filter, and swift test output is structurally similar (build noise + test results), adding swift test to the rewrite registry would allow project-local or user-global TOML filters to handle it.

Context

  • swift test produces very verbose output (~76KB for ~580 tests using Swift Testing framework)
  • A custom TOML filter achieves 99.4% token savings (76KB → ~200 bytes)
  • But without a rewrite rule, the hook doesn't intercept swift test, so the filter never runs automatically
  • Currently requires manually patching rtk-rewrite.sh, which breaks integrity verification

Proposed Change

Add swift test to the rewrite registry in src/discover/registry.rs, similar to how swift build is already registered.

Optionally, a built-in swift-test.toml filter would be valuable — Swift Testing framework output follows a consistent pattern:

  • ◇ Test/Suite ... started. (noise)
  • ✔ Test ... passed after N seconds. (noise)
  • ✘ Test ... failed/skipped (keep)
  • ✔/✘ Test run with N tests passed/failed (summary, keep)

Environment

  • macOS, Swift 6.x, SPM (no Xcode)
  • Swift Testing framework (not XCTest)
  • rtk v0.31.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions