Skip to content
woodiePublic

About

Test formatter for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

gorderly

go.mod version CI Release License

Example Screenshot

RSpec/Mocha/Vitest-style output for Go that works with plain go test by reading its raw -v output directly. No TDD framework required. Any suite using stdlib testing with nested t.Run will work without changes. See at a glance which spec actually failed, instead of hunting through a wall of PASS/FAIL lines.

Installation

go install github.com/woodie/gorderly@latest

Or build locally:

go build -o gorderly
mv gorderly ~/go/bin/

Usage

Pipe go test -v's output straight in:

go test -v ./... | gorderly -fd

Or let gorderly run go test for you:

gorderly -fd .
gorderly -fd ./...

Flags select the output style -- see Output styles below.

Version

gorderly --version

Prints the installed version and exits immediately, without waiting on stdin.

Output styles

Four named styles, each matching a convention from a familiar test runner. The first three end with the same xcbeautify-style footer; -fv ends with Vitest's own footer shape instead.

Flag Convention Look
Our base formatter Glyph + name (N seconds), failures add (FAILED - N)
-fd RSpec's doc format Plain colored name, yellow (PENDING) for skips
-fs Mocha's spec format Green ✔ + gray name, red ✗ name (FAILED - N)
-fv Vitest's own tree Green ✓ name, two-toned green 2ms, red × name, dim gray ↓ name

-fv's Test Files line counts one entry per Go package that has test files, skipping any package go test reports as [no test files] -- Go's own package boundaries give an exact, unambiguous file count, so this line has no known edge cases.

Things to know

Writing tests

gorderly only ever needs go test -v's raw output -- it renders whatever nesting your tests already produce, spec-based or not. For how we actually write those tests -- spec for structure and lifecycle hooks, expect for matchers, context nesting, the subject pattern, mocking and stubbing -- see docs/FRAMEWORK.md. gorderly's own tests (parse_test.go, render_test.go, main_test.go, version_test.go, config_test.go) are real examples of that shape, not just a sketch.

Limitations

  • Tree order follows completion order, which matches declaration order for serial tests but can reorder under t.Parallel()
  • Subtest names have spaces substituted with underscores by go test itself; gorderly reverses that for display, which is imprecise for subtest names with genuine underscores in them.
  • Package build failures are reported by outcome only, not with the underlying compiler error -- run go vet/go build separately to see why a package failed to build.
  • -fv's per-leaf millisecond timing is only as precise as go test -v's own output, which reports elapsed time to two decimal places of a second (e.g. 0.00s) -- fast subtests will often show a flat 0ms where Vitest's own JS timers would show 2ms/4ms. This is a ceiling in go test itself, not something -fv can recover.
  • A literal / in a describe/context/it string is indistinguishable from a nesting boundary once it reaches go test -v's output -- t.Run uses an unescaped / as both the subtest hierarchy separator and the -run/-bench regex-splitting delimiter, and Go's own docs are explicit that a literal / in a subtest name isn't safe. Not something gorderly (or any tool parsing go test's output) can recover after the fact -- see docs/FRAMEWORK.md for the fix on the spec-author side.

Development

make build    # go build -o gorderly
make install  # builds, then moves the binary to ~/go/bin/
make test     # verbose, dogfoods gorderly on its own suite in -fs style
make lint     # golangci-lint
make check    # terse: silent on success, full log on failure

Cutting a release: bump gorderlyVersion in version.go by hand before tagging. gorderly's primary install path is go install github.com/woodie/gorderly@latest -- a module-proxy fetch with no .git metadata to describe -- so the version string has to already be correct in the committed source at the tagged commit.

About

Test formatter for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages