Skip to content

test(oneline): cover the remaining cleaning sites and the package itself; Cut no longer panics below 1 - #785

Merged
pbertsch merged 1 commit into
mainfrom
test/oneline-nits
Nov 17, 2026
Merged

pbertsch merged 1 commit into
mainfrom
test/oneline-nits

Conversation

@pbertsch

Copy link
Copy Markdown
Member

Summary

Follow-ups from the review of #775 (device names, serials, app ids and process names printed as one clean line). Mostly tests, plus one small fix.

Tests for the five cleaning sites that had none. In each, a hostile id (a new line with a forged pass --yes line, a screen clear, a title sequence, a bidi override, a zero-width space) must come out as one clean line, with its visible text kept:

  • the WebView forward fallback error, adb forward tcp:%d … failed on <serial>;
  • the WebView forward error after every fallback port was in use, … after 5 ports were in use;
  • the WebView forward removal error, adb forward --remove tcp:%d failed on <serial>;
  • the Android "Granting all permissions for " line, with grantPerms on. Every pm grant call still gets the real app id;
  • adb's error, which names the command it ran: the joined arguments are cleaned;
  • the pid from lsof in the port-holder message: cleaned and cut to 20 runes.

internal/oneline has its own tests (oneline_test.go):

  • Clean on every class of character it handles: controls, escape and title sequences, bidi controls and isolates, zero-width, line and paragraph separators, Hangul fillers, braille blank, grapheme joiner, object replacement, invalid UTF-8; also collapsing and trimming, and visible text in other scripts left unchanged;
  • the limit is counted after cleaning;
  • Cut never splits a rune;
  • Hidden on a hidden and a visible list.

Fix: oneline.Cut panicked for a limit below 1 on non-empty text (r[:n-1]). It now returns an empty string. Every caller passes 20 or more, so no run hit it.

Style:

  • The Hangul fillers, braille blank, combining grapheme joiner and object replacement character in oneline.go are written as \u escapes instead of literal glyphs.
  • The internal/oneline import moved out of the standard-library group in crash_collect.go, webview_ops.go, ios/simctl.go and probelink/portholder.go. The other files with a mixed group were already like that on main, so they are left alone.

Mutation check

Each mutant was applied, the tests were run, and the file was restored byte for byte. All 12 were killed.

Mutant Result
fallback tcp:%d error prints the raw serial killed
ports-in-use error prints the raw serial killed
removal error prints the raw serial killed
grant line prints the raw app id killed
adb error prints the raw arguments killed
lsof pid printed raw killed
Hidden misses the Hangul fillers killed
Hidden misses braille blank / grapheme joiner / object replacement killed
Clean keeps a leading space killed
Clean does not trim the end killed
Cut has no guard below 1 killed
Cut marks no cut killed

Test plan

  • go test ./internal/oneline/ ./internal/device/ ./internal/probelink/ ./internal/ios/ passes.
  • go vet and staticcheck pass on those packages.
  • No raw format or blank characters in the changed files.
  • Mutation check (table above).

@pbertsch
pbertsch requested a review from a team as a code owner November 17, 2026 07:56
@pbertsch
pbertsch merged commit e4a4a07 into main Nov 17, 2026
10 of 11 checks passed
jay23606 added a commit to jay23606/flutter-probe that referenced this pull request Nov 17, 2026
…elf; Cut no longer panics below 1 (AlphaWaveSystems#785)

## Summary

Follow-ups from the review of AlphaWaveSystems#775 (device names, serials, app ids and process names printed as one clean line). Mostly tests, plus one small fix.

**Tests for the five cleaning sites that had none.** In each, a hostile id (a new line with a forged `pass --yes` line, a screen clear, a title sequence, a bidi override, a zero-width space) must come out as one clean line, with its visible text kept:
- the WebView forward fallback error, `adb forward tcp:%d … failed on <serial>`;
- the WebView forward error after every fallback port was in use, `… after 5 ports were in use`;
- the WebView forward removal error, `adb forward --remove tcp:%d failed on <serial>`;
- the Android "Granting all permissions for <app>" line, with `grantPerms` on. Every `pm grant` call still gets the real app id;
- adb's error, which names the command it ran: the joined arguments are cleaned;
- the pid from `lsof` in the port-holder message: cleaned and cut to 20 runes.

**`internal/oneline` has its own tests** (`oneline_test.go`):
- `Clean` on every class of character it handles: controls, escape and title sequences, bidi controls and isolates, zero-width, line and paragraph separators, Hangul fillers, braille blank, grapheme joiner, object replacement, invalid UTF-8; also collapsing and trimming, and visible text in other scripts left unchanged;
- the limit is counted after cleaning;
- `Cut` never splits a rune;
- `Hidden` on a hidden and a visible list.

**Fix:** `oneline.Cut` panicked for a limit below 1 on non-empty text (`r[:n-1]`). It now returns an empty string. Every caller passes 20 or more, so no run hit it.

**Style:**
- The Hangul fillers, braille blank, combining grapheme joiner and object replacement character in `oneline.go` are written as `\u` escapes instead of literal glyphs.
- The `internal/oneline` import moved out of the standard-library group in `crash_collect.go`, `webview_ops.go`, `ios/simctl.go` and `probelink/portholder.go`. The other files with a mixed group were already like that on `main`, so they are left alone.

## Mutation check

Each mutant was applied, the tests were run, and the file was restored byte for byte. All 12 were killed.

| Mutant | Result |
|---|---|
| fallback `tcp:%d` error prints the raw serial | killed |
| ports-in-use error prints the raw serial | killed |
| removal error prints the raw serial | killed |
| grant line prints the raw app id | killed |
| adb error prints the raw arguments | killed |
| `lsof` pid printed raw | killed |
| `Hidden` misses the Hangul fillers | killed |
| `Hidden` misses braille blank / grapheme joiner / object replacement | killed |
| `Clean` keeps a leading space | killed |
| `Clean` does not trim the end | killed |
| `Cut` has no guard below 1 | killed |
| `Cut` marks no cut | killed |

## Test plan

- [x] `go test ./internal/oneline/ ./internal/device/ ./internal/probelink/ ./internal/ios/` passes.
- [x] `go vet` and `staticcheck` pass on those packages.
- [x] No raw format or blank characters in the changed files.
- [x] Mutation check (table above).
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