Skip to content

Add unit tests for modules/cmdrunner (0% → 88% coverage) - #2136

Merged
Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-cmdrunner-test-coverage
Jul 26, 2026
Merged

Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-cmdrunner-test-coverage

Conversation

@Seanstoppable

Copy link
Copy Markdown
Collaborator

Summary

Adds table-driven unit tests for modules/cmdrunner, raising test coverage from 0% to 88.0%.

Tests added

settings_test.go

  • NewSettingsFromYAML: defaults, fully specified config, cmd without args
  • Default title/focusable constants
  • ConfigText

widget_test.go

  • Widget.String() title formatting (no args, single arg, multiple args, empty command)
  • Buffer writing and maxLines line-draining behavior (under/at/over limit, zero limit)
  • drainLines error path when insufficient lines exist
  • environment() construction (WTF_WIDGET_WIDTH/HEIGHT + inherited env)
  • handleError writing errors into the output buffer
  • runCommand using real, safe commands (echo) plus a nonexistent-binary error case
  • content() title/text rendering, including fallback to the rendered command string as title
  • End-to-end integration test exercising NewWidget + Refresh with a real command through the actual goroutine pipeline

Validation

  • go build ./... passes
  • go test ./modules/cmdrunner/... -cover passes, 88.0% coverage
  • golangci-lint run ./modules/cmdrunner/... passes for all new/modified files (3 pre-existing gofmt findings remain in untouched files settings.go, widget.go, pty_windows.go, caused by this repo's Windows core.autocrlf checkout behavior — unrelated to this change)

No behavioral changes to production code.

Table-driven tests covering:
- Settings parsing from YAML (defaults, full config, edge cases)
- Widget.String() title formatting
- Buffer writing and maxLines line draining
- Environment variable construction
- Error handling into the output buffer
- runCommand with real safe commands (echo) and a nonexistent binary
- content() title/text rendering, including default-title fallback
- End-to-end NewWidget/Refresh loop using a real command
@Seanstoppable
Seanstoppable force-pushed the seanstoppable-cmdrunner-test-coverage branch from 60d0e20 to 55a441c Compare July 26, 2026 03:20
@Seanstoppable
Seanstoppable merged commit b6f457b into wtfutil:trunk Jul 26, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-cmdrunner-test-coverage branch July 26, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址