Description
Motivation
We often use (*testing.T).Skip
to skip tests that fail due to known bugs in the Go toolchain, the standard library, or a specific platform where the test runs.
When the underlying bugs are fixed, it is important that we remove the skips to prevent regressions.
However, bugs are sometimes fixed without us noticing — especially if they are platform bugs. In such cases, it would be helpful to have some way to detect that situation short of editing and recompiling all of the tests in a project.
Here is a concrete example in the standard library: a t.Skip
call that references an issue that was marked closed back in 2016 (#17065). Given how easy that call was to find, I expect that similarly outdated skips are pervasive.
Proposal
A new boolean flag for the testing
package, tentatively named -test.unskip
, with the corresponding go test
flag -unskip
. -test.unskip
takes a regular expression, which is matched against the formatted arguments of t.Skip
or t.Skipf
or the most recent test log entry before t.SkipNow
.
If a Skip
matches the regular expression, the test does not stop its execution as usual: instead, it continues to run. If the skipped test passes, the test is recorded as unnecessarily-skipped and the binary will exit with a nonzero exit code. If the skipped test fails, the test log (and the exit code of the test binary) ignores the failure and proceeds as usual.
Comparison
Test frameworks in a few other languages provide an explicit mechanism for expecting a test to fail. For example, Python has @unittest.expectedFailure
; Boost has an expected_failures
decorator; RSpec has the pending keyword.