v0.4.1 122e784

drivers_test.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package drivers
4
5import (
6	"go/ast"
7	"go/parser"
8	"go/token"
9	"testing"
10)
11
12// The container option that lets a driver run against a rootless Docker daemon
13// exists for tests: with it the nested dockerd of the job cannot start, so jobs
14// would run without Docker and with weaker isolation than the runner promises.
15// Production code (this package builds the drivers of `ermite-runner run`) must
16// never mention it, neither as a field of Options nor in a value.
17func TestProductionFactoriesNeverSetTheTestOnlyRootlessOption(t *testing.T) {
18	fset := token.NewFileSet()
19	files, err := parser.ParseFile(fset, "drivers.go", nil, 0)
20	if err != nil {
21		t.Fatal(err)
22	}
23	found := false
24	ast.Inspect(files, func(n ast.Node) bool {
25		switch x := n.(type) {
26		case *ast.Ident:
27			if x.Name == "UnsafeAllowRootlessForTests" || x.Name == "AllowRootless" {
28				t.Errorf("%s: %s is a test-only option", fset.Position(x.Pos()), x.Name)
29			}
30		case *ast.CompositeLit:
31			if sel, ok := x.Type.(*ast.SelectorExpr); ok && sel.Sel.Name == "Options" {
32				found = true
33				if len(x.Elts) != 0 {
34					t.Errorf("%s: %s{...} sets options in production code", fset.Position(x.Pos()), sel.Sel.Name)
35				}
36			}
37		}
38		return true
39	})
40	if !found {
41		t.Fatal("drivers.go no longer builds container.Options{}: update this test")
42	}
43}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 11

↑↓ moveenter openesc close