Commit e733f19cd4

e733f19cd4780214156d88425f18330173b8572e

parent: 8839e2cc95

Verified · cmc ci/build: success ci/test: success ci/vuln: success

cmc <hello@cleberg.net> · 2026-09-04 16:21 UTC

e2e: say the timeout is too short instead of panicking eleven minutes in

`go test` defaults to a ten-minute timeout. This suite takes about 394s
on CI and up to 873s on a laptop, so a bare `go test ./...` panics part
way through and names whichever test was executing at the deadline —
never the one at fault, and it reads like a hang. It cost this session
two full runs and a wrong report that a branch was failing.

TestMain refuses in half a second with what to run instead. Only for a
whole-package run: `-run TestOneThing -timeout 2m` is a reasonable thing
to type and none of this applies to it.

CONTRIBUTING asked for a bare `go test ./...` and said the suite takes
about two minutes. It asks for `make test` now, and says six to fifteen.

Closes #143

Layout: unified · split

CONTRIBUTING.org +6 −3
@@ -24,9 +24,12 @@ at [[https://gitbay.org/register][gitbay.org/register]] for a browser.
2424 gitbay repo clone you/gitbay && cd gitbay
2525 git checkout -b my-change
2626 #+end_src
272. Make the change. =go build ./...= and =go test ./...= must be green —
28 the e2e suite drives real =git=, =ssh=, =sshd=, and =gpg= binaries and
29 takes about two minutes.
272. Make the change. =go build ./...= and =make test= must be green. Use
28 =make test=, not a bare =go test ./...=: the e2e suite drives real
29 =git=, =ssh=, =sshd= and =gpg= binaries and takes six to fifteen
30 minutes depending on the machine, which is past =go test='s ten-minute
31 default. The bare command panics part way through and names whichever
32 test was running, which is not the one at fault.
30333. **Sign your commits.** =main= requires verified signatures: register
3134 your signing key (=gitbay auth pgp add= for OpenPGP, or sign with a
3235 registered SSH key) and make sure your author email is verified on
e2e/main_test.go added +39
@@ -0,0 +1,39 @@
1package e2e
2
3import (
4 "flag"
5 "fmt"
6 "os"
7 "testing"
8 "time"
9)
10
11// This suite drives real git, ssh, sshd and gpg, and takes six to fifteen
12// minutes depending on the machine — past `go test`'s ten-minute default.
13// Exceeding it panics with the name of whichever test happened to be
14// running, which is never the one at fault and reads like a hang (#143).
15//
16// make test passes -timeout 30m and .gitbay/ci.yml passes -timeout 20m.
17// A bare `go test ./...` gets the default, so say so up front rather than
18// eleven minutes later.
19const minTimeout = 15 * time.Minute
20
21func TestMain(m *testing.M) {
22 flag.Parse()
23 // Only for a whole-package run: `-run TestOneThing -timeout 2m` is a
24 // reasonable thing to type and none of this applies to it.
25 if run := flag.Lookup("test.run"); run == nil || run.Value.String() == "" {
26 if f := flag.Lookup("test.timeout"); f != nil {
27 d, err := time.ParseDuration(f.Value.String())
28 if err == nil && d > 0 && d < minTimeout {
29 fmt.Fprintf(os.Stderr,
30 "e2e: -timeout is %s; this suite needs about %s.\n"+
31 "Run `make test` (which passes -timeout 30m), or pass -timeout yourself.\n"+
32 "Without this check the run panics part way through and blames whichever\n"+
33 "test was executing at the deadline.\n", d, minTimeout)
34 os.Exit(1)
35 }
36 }
37 }
38 os.Exit(m.Run())
39}