Skip to content

test: delete 94 tests that assert string literals against themselves - #46

Merged
Snider merged 1 commit into
mainfrom
test/remove-tautology-suites
Aug 8, 2026
Merged

test: delete 94 tests that assert string literals against themselves#46
Snider merged 1 commit into
mainfrom
test/remove-tautology-suites

Conversation

@Snider

@Snider Snider commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Every one of these had the same shape — one Good/Bad/Ugly triplet per exported symbol:

func TestRegister_Register_Good(t *core.T) {
    ax7Variant := "Register:good"
    core.AssertContains(t, ax7Variant, "good")
    label := "Register:good"
    core.AssertContains(t, label, "Register")
    core.AssertContains(t, label, "good")
}

Register is never called. The test asserts that a string literal contains its own substring — true before the package is written, and still true after it is deleted. Thirteen files were nothing but this; two more carried it alongside real tests.

The justification is measured, not asserted

Coverage was captured per package before and after. Every package is byte-identical — same total, same per-function numbers:

package coverage before after
p2p 89.2% 89.2%
browser 78.2% 78.2%
chat 61.5% 61.5%
contextmenu 58.3% 58.3%
dock 53.1% 53.1%
events 76.5% 76.5%
internal/coreutil 100.0% 100.0%
internal/textutil 100.0% 100.0%
keybinding 56.0% 56.0%
lifecycle 60.5% 60.5%
menu 69.3% 69.3%
systray 63.2% 63.2%
mcp 55.7% 55.7%
webkit 28.6% 28.6%
engine/php 0.0% 0.0%

Nothing moved because nothing was covered. That is the whole case: they were coverage-shaped noise sitting beside the real suites. p2p's service_test.go was 27 fakes next to a service_behaviour_test.go that genuinely opens a Service, publishes, subscribes and asserts on the driver.

Worth saying plainly

engine/php now has no test file. It also had no coverage before — 0.0% with twelve tests present — so nothing is lost; the package just stops advertising a suite it never had. It is now the most valuable gap in the repo, and visible.

On the analyser

The banked unreferenced-symbols.py found only 33 of these, and 17 of those were its own false positives on scenario-style names. It misses the pattern precisely because the tautology spells the symbol inside a string literal, so the body looks like it references the symbol.

The criterion used here instead: strip string literals, then flag any test whose remaining body calls nothing but core.Assert* / core.Require*.

Receipts

cd go && GOWORK=off go build ./...  exit 0
         GOWORK=off go vet   ./...  exit 0
         GOWORK=off go test  ./...  exit 0, 58 packages ok, 0 failures
gofmt -l   0 offenders

Deliberately not included

Four shells remain in display/webkit/pkg/window (register_test.go's three, window_test.go's one). That package has an in-flight PR against it, so it is not mine to touch yet.

🤖 Generated with Claude Code
Co-Authored-By: Virgil virgil@lethean.io

Every one of these had the same shape, one Good/Bad/Ugly triplet per exported
symbol:

    func TestRegister_Register_Good(t *core.T) {
        ax7Variant := "Register:good"
        core.AssertContains(t, ax7Variant, "good")
        label := "Register:good"
        core.AssertContains(t, label, "Register")
        core.AssertContains(t, label, "good")
    }

Register is never called. The test asserts that a string literal contains its
own substring, which is true before the package is written and stays true after
it is deleted. Thirteen files were nothing but this; two more carried it
alongside real tests.

The justification is measured, not asserted. Coverage was captured per package
before and after, and every one is byte-identical — same total, same per-function
numbers:

  p2p 89.2%, browser 78.2%, chat 61.5%, contextmenu 58.3%, dock 53.1%,
  events 76.5%, coreutil 100.0%, textutil 100.0%, keybinding 56.0%,
  lifecycle 60.5%, menu 69.3%, systray 63.2%, mcp 55.7%, webkit 28.6%,
  php 0.0%

Nothing moved because nothing was covered. That is the whole case for removing
them: they were coverage-shaped noise sitting next to the real suites — p2p's
service_test.go was 27 fakes beside a service_behaviour_test.go that genuinely
opens a Service, publishes, subscribes and asserts on the driver.

WORTH SAYING PLAINLY: engine/php now has no test file. It also had no coverage
before — 0.0% with twelve tests present — so this does not lose anything, it
stops the package advertising a suite it never had. It is the most valuable gap
in the repo now that it is visible.

The banked analyser only found 33 of these, and 17 of those were its own false
positives on scenario-style names. It misses the pattern precisely because the
tautology spells the symbol INSIDE a string literal, so the body looks like it
references the symbol. The criterion used here instead: strip string literals,
then flag any test whose remaining body calls nothing but core.Assert*/Require*.

  cd go && GOWORK=off go build ./...  exit 0
           GOWORK=off go vet   ./...  exit 0
           GOWORK=off go test  ./...  exit 0, 58 packages ok, 0 failures
  gofmt -l   0 offenders

Four more shells remain in display/webkit/pkg/window (register_test.go's three,
window_test.go's one). Left alone deliberately — that package has an in-flight
PR against it and is not mine to touch yet.

Co-Authored-By: Virgil <virgil@lethean.io>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Snider, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d36937ba-ea59-46a9-8e5a-8dd31267b254

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac292a and 6d7ff82.

📒 Files selected for processing (15)
  • go/display/webkit/pkg/browser/register_test.go
  • go/display/webkit/pkg/chat/messages_test.go
  • go/display/webkit/pkg/contextmenu/register_test.go
  • go/display/webkit/pkg/dock/register_test.go
  • go/display/webkit/pkg/events/register_test.go
  • go/display/webkit/pkg/internal/coreutil/action_test.go
  • go/display/webkit/pkg/internal/textutil/textutil_test.go
  • go/display/webkit/pkg/keybinding/register_test.go
  • go/display/webkit/pkg/lifecycle/register_test.go
  • go/display/webkit/pkg/mcp/tools_chat_behaviour_test.go
  • go/display/webkit/pkg/menu/register_test.go
  • go/display/webkit/pkg/p2p/service_test.go
  • go/display/webkit/pkg/systray/register_test.go
  • go/display/webkit/service_test.go
  • go/engine/php/service_test.go

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Snider
Snider merged commit 95593e4 into main Aug 8, 2026
2 checks passed
@Snider
Snider deleted the test/remove-tautology-suites branch August 8, 2026 09:04
Snider added a commit that referenced this pull request Aug 8, 2026
)

The four shells #46 could not touch while PR #44 was in flight, now
adjudicated per case rather than swept.

register_test.go — genuine fake. All three tests asserted that the
string "Register:good" contains "good" and never named Register at all.
Replaced with a real Good/Bad/Ugly triplet that calls it: the returned
constructor yields an OK Result carrying a *Service wired to the given
platform with manager and spec registry initialised (Good); a nil
platform still constructs rather than panicking during Core wiring, long
before any window opens (Bad); and the constructor is reusable, each call
producing an INDEPENDENT service — a shared specs map would let two Cores
overwrite each other's window registrations (Ugly).

window_test.go — mislabelled but real. These tests DO call WithName /
WithTitle / WithURL and assert properly; the ax7Variant lines were dead
weight prepended to working bodies. Removed those two lines per test,
116 in total, leaving every assertion byte-identical.

Receipts:
  coverage  68.3% before, 68.3% after — nothing real was removed
  Register  100.0% (was already covered by service_screen_test.go's
            real use; the deleted shells contributed nothing)
  go test -race -count=2  clean
  vet + gofmt clean
Snider added a commit that referenced this pull request Aug 8, 2026
#51)

* test(engine/php): real coverage for detect, env, extract and workspace

engine/php had 363 running tests and 0.7% coverage. They were empty
bodies and tautologies — `subject := IsLaravelProject; AssertNotNil(t,
subject); AssertEqual(t, "good", "good")` takes a func reference (non-nil
by construction) and asserts a literal equals itself. Same family PR #46
deleted 94 of elsewhere. Replaced, not deleted, for four files.

Coverage 0.7% -> 7.6%. Per function in the files touched:

  detect.go     all 12 at 100.0%
  probe.go      100.0% / 85.7%
  workspace.go  100.0% / 93.8% / 84.6% / 100.0%
  env.go        76.2% / 100.0% / 85.7% / 92.3%, resolveDataDir 35.3%
  extract.go    70.6%

resolveDataDir cannot exceed ~35% in one run: only one GOOS branch
executes. The rest of extract.go is core.MkdirTemp / PathRel / MkdirAll
failures with no injection point.

Tests are hermetic — t.TempDir fixtures, fstest.MapFS for the embedded
tree, t.Setenv to redirect HOME so PrepareRuntimeEnvironment never
touches a real user profile, t.Chdir for the workspace search. Fault
injection is real: truncated and non-JSON composer.json, unreadable
octane config, unwritable data dir and Laravel root, a filesystem whose
reads fail mid-walk, malformed and unsupported-version workspace.yaml.

ONE PRODUCTION CHANGE, from a defect the tests exposed — a second
instance of the go-io os.Root class fixed in #49, this time in
detect.go. Project probing ran through the coreio local medium, which
refuses any path leaving its root, including one that merely traverses a
symlink. Handed a symlinked project path — ~/Sites/app pointing at a
volume, a git worktree, a bind-mounted container path — every file read
as absent, so IsLaravelProject returned false FOR A LARAVEL PROJECT and
GetLaravelAppName returned "". Silently: no error, just a wrong answer.

  probe.go adds probeExists / probeRead over core.Stat / core.ReadFile,
  the same os-level probing already used by workspace.go and
  display/webkit/pkg/container. go-io is correct and untouched; coreio
  media stay for sandboxed I/O.

  Receipt: probed before the fix —
    IsLaravelProject(real)=true   IsLaravelProject(symlink)=false
    GetLaravelAppName(real)="Probe"  GetLaravelAppName(symlink)=""
  TestIsLaravelProject_ThroughSymlink now pins both as equal.

The medium seam is unaffected in practice: SetMedium has no callers
outside its own build-tagged example.

Gates: engine/php green under -race; whole library 59 packages ok, 0
failures; vet + gofmt clean.

Co-Authored-By: Virgil <virgil@lethean.io>

* test(engine/php): scope the Extract leak check to its own temp prefix

TestExtract_Bad and TestExtract_Ugly snapshotted the whole system temp
directory either side of the call, so any unrelated process creating a
temporary file between the two reads would be reported as a leaked
extraction. On a busy CI runner that is a flake that looks like a real
failure.

Only entries carrying Extract's own "go-php-laravel-" prefix are counted
now, which is still a true leak check and immune to unrelated activity.

Receipt: go test -run TestExtract_ -count=2 ./engine/php/ green.

Co-Authored-By: Virgil <virgil@lethean.io>
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.

1 participant