gotest

command
v0.143.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command gotest runs `go test` and refuses to call a selection a pass when part of it selected nothing.

⛔⛔ `ok` IS ABOUT THE TESTS THAT RAN, NOT ABOUT THE ONE YOU ASKED FOR. Measured on 2026-11-09, in go-zpkg/zbk, while checking a README gate:

$ go test -run 'TestREADME|TestUsage|TestMain' ./cmd/zbk
ok  	github.com/go-zpkg/zbk/cmd/zbk	0.159s

The gate was `TestTheREADMECountsTheSubcommandsItHas`, and `TestREADME` matched NOTHING. Three other alternatives did — the same run with -v shows TestMainMultiCallDispatch, TestUsageAndErrors, TestMainSeam and TestRunTestUsage — so the selection was not empty, `go test` had nothing to warn about, and the `ok` was true. The gate had simply not run, and ran red the moment it was named correctly:

39 subcommands, and numberWords does not spell that

⛔ GO ONLY WARNS WHEN THE SELECTION IS WHOLLY EMPTY, and even then it exits 0. Measured the same day:

$ go test -run NoSuchTestNameAtAll ./cmd/covblocks ; echo $?
ok  	…/cmd/covblocks	0.051s [no tests to run]
0

So the information exists in both cases and the VERDICT does not. That is what this adds, and it is the only thing it adds: every argument is passed through to `go test` unchanged.

gotest -run 'TestFoo|TestBar' ./pkg      # fails if either matched nothing
gotest ./...                             # no -run: a plain pass-through

⭐ IT CHECKS EACH ALTERNATIVE, not the selection as a whole, because that is where the defect lives: a pattern with four alternatives and one typo reports the three that worked.

⛔ AND IT ADDS -v WHEN IT HAS TO, saying so. The names that ran are only printed by `go test -v`; without it there is nothing to check against, and silently running a different command than the one asked for is worse than the extra output.

Exit status: 0 the selection ran and `go test` passed, 1 an alternative matched no test or `go test` failed, 2 the arguments could not be read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL