main 602baa7

bootstrap_requests_test.go RawHistoryFolder

1package xturbo_test
2
3import (
4	"bytes"
5	"testing"
6
7	"bnema.dev/xturbo"
8	"bnema.dev/xturbo/bigreq"
9	"bnema.dev/xturbo/internal/xtest"
10	"bnema.dev/xturbo/xcmisc"
11	"bnema.dev/xturbo/xproto"
12)
13
14// Root encodes the requests it issues itself; they must match the generated
15// encoders byte for byte, and the committed goldens where they exist.
16func TestBootstrapRequestsMatchGenerated(t *testing.T) {
17	newBuf := func() *xturbo.Buf {
18		b := xturbo.NewBuf(0)
19		var ext xturbo.ExtTable
20		ext.Set(xturbo.ExtBigRequests, 133, 0, 0)
21		ext.Set(xturbo.ExtXCMisc, 136, 0, 0)
22		b.Ext = &ext
23		return b
24	}
25	for _, tc := range []struct {
26		name      string
27		root, gen func(*xturbo.Buf) xturbo.Seq
28		golden    string
29	}{
30		{"InternAtom", func(b *xturbo.Buf) xturbo.Seq { return xturbo.EncodeInternAtom(b, false, "XTURBO_") },
31			func(b *xturbo.Buf) xturbo.Seq { return xproto.InternAtom(b, false, "XTURBO_") }, "xproto/InternAtom"},
32		{"InternAtomOnlyIfExists", func(b *xturbo.Buf) xturbo.Seq { return xturbo.EncodeInternAtom(b, true, "WM_STATE") },
33			func(b *xturbo.Buf) xturbo.Seq { return xproto.InternAtom(b, true, "WM_STATE") }, ""},
34		{"QueryExtension", func(b *xturbo.Buf) xturbo.Seq { return xturbo.EncodeQueryExtension(b, "Generic Event Extension") },
35			func(b *xturbo.Buf) xturbo.Seq { return xproto.QueryExtension(b, "Generic Event Extension") }, ""},
36		{"QueryExtensionAligned", func(b *xturbo.Buf) xturbo.Seq { return xturbo.EncodeQueryExtension(b, "XFIXES") },
37			func(b *xturbo.Buf) xturbo.Seq { return xproto.QueryExtension(b, "XFIXES") }, ""},
38		{"GetInputFocus", xturbo.EncodeGetInputFocus, xproto.GetInputFocus, ""},
39		{"BigreqEnable", xturbo.EncodeBigreqEnable, bigreq.Enable, ""},
40		{"GetXIDRange", xturbo.EncodeGetXIDRange, xcmisc.GetXIDRange, ""},
41	} {
42		t.Run(tc.name, func(t *testing.T) {
43			rb, gb := newBuf(), newBuf()
44			if tc.root(rb) != 1 || tc.gen(gb) != 1 || rb.Err() != nil || gb.Err() != nil {
45				t.Fatal(rb.Err(), gb.Err())
46			}
47			if !bytes.Equal(rb.Bytes(), gb.Bytes()) {
48				t.Fatalf("root %x, generated %x", rb.Bytes(), gb.Bytes())
49			}
50			if tc.golden == "" {
51				return
52			}
53			want, err := xtest.LoadHex("testdata/golden/" + tc.golden + ".req.hex")
54			if err != nil {
55				t.Fatal(err)
56			}
57			if !bytes.Equal(rb.Bytes(), want) {
58				t.Fatalf("root %x, golden %x", rb.Bytes(), want)
59			}
60		})
61	}
62	// Extension requests fail sticky when the extension is absent.
63	b := xturbo.NewBuf(0)
64	b.Ext = &xturbo.ExtTable{}
65	if xturbo.EncodeGetXIDRange(b) != 0 || b.Err() != xturbo.ErrExtMissing {
66		t.Fatal(b.Err())
67	}
68}

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 1

Tags 1

↑↓ moveenter openesc close