detached 3d41bc5

smoke_test.go RawHistoryFolder

1package indicator
2
3import (
4	"context"
5	"os"
6	"testing"
7	"time"
8
9	"github.com/bnema/wlturbo"
10	"github.com/stretchr/testify/assert"
11	"github.com/stretchr/testify/require"
12
13	"github.com/bnema/nefercap/internal/ports"
14)
15
16// TestSmokeRun shows the real HUD. It needs a Wayland compositor with
17// layer-shell and Vulkan, so it runs only when NEFERCAP_INDICATOR_SMOKE is
18// "click" (an input driver presses Stop) or "cancel" (the context ends).
19// NEFERCAP_INDICATOR_OUTPUT names the wl_output to show it on (for example
20// HEADLESS-1 on a NeferWL headless compositor) and is required with it.
21func TestSmokeRun(t *testing.T) {
22	mode := os.Getenv("NEFERCAP_INDICATOR_SMOKE")
23	if mode == "" {
24		t.Skip("set NEFERCAP_INDICATOR_SMOKE=click|cancel on a Wayland session")
25	}
26	name := os.Getenv("NEFERCAP_INDICATOR_OUTPUT")
27	if name == "" {
28		t.Skip("set NEFERCAP_INDICATOR_OUTPUT to the output name")
29	}
30	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
31	defer cancel()
32	stop := make(chan struct{}, 1)
33	var authorized bool
34	ind := New(func(_ context.Context, display *wlturbo.Display, surface wlturbo.Proxy) error {
35		authorized = display != nil && surface != nil && surface.Context() == display.Context()
36		return nil
37	}, stop)
38	done := make(chan error, 1)
39	go func() { done <- ind.Run(ctx, ports.Output{ID: 1, Name: name}) }()
40	switch mode {
41	case "click":
42		select {
43		case <-stop:
44		case err := <-done:
45			t.Fatalf("Run ended before Stop: %v", err)
46		case <-ctx.Done():
47			t.Fatal("Stop was never requested")
48		}
49	case "cancel":
50		time.Sleep(3 * time.Second)
51	}
52	cancel()
53	require.NoError(t, <-done)
54	assert.True(t, authorized, "authorize must run with the live surface")
55}

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 2

Tags 9

↑↓ moveenter openesc close