cef2gtk_boundary_test.go RawHistoryFolder

1package cef
2
3import (
4	"go/parser"
5	"go/token"
6	"os"
7	"path/filepath"
8	"runtime"
9	"strconv"
10	"strings"
11	"testing"
12)
13
14func TestCEF2GTKImportStaysInInfrastructureCEF(t *testing.T) {
15	root := repoRoot(t)
16	if err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
17		if err != nil {
18			return err
19		}
20		if d.IsDir() {
21			switch d.Name() {
22			case ".git", ".worktrees", "vendor", "dist", "tmp":
23				return filepath.SkipDir
24			}
25			return nil
26		}
27		if filepath.Ext(path) != ".go" || strings.HasSuffix(path, "_test.go") {
28			return nil
29		}
30		importsBridge, err := importsCEF2GTK(path)
31		if err != nil {
32			return err
33		}
34		if !importsBridge {
35			return nil
36		}
37		rel, err := filepath.Rel(root, path)
38		if err != nil {
39			return err
40		}
41		if strings.HasPrefix(filepath.ToSlash(rel), "internal/infrastructure/cef/") {
42			return nil
43		}
44		t.Fatalf("purego-cef2gtk imported outside cef infrastructure: %s", rel)
45		return nil
46	}); err != nil {
47		t.Fatalf("scan imports: %v", err)
48	}
49}
50
51func importsCEF2GTK(path string) (bool, error) {
52	file, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.ImportsOnly)
53	if err != nil {
54		return false, err
55	}
56	for _, spec := range file.Imports {
57		importPath, err := strconv.Unquote(spec.Path.Value)
58		if err == nil && strings.HasPrefix(importPath, "github.com/bnema/purego-cef2gtk") {
59			return true, nil
60		}
61	}
62	return false, nil
63}
64
65func repoRoot(t *testing.T) string {
66	t.Helper()
67	_, filename, _, ok := runtime.Caller(0)
68	if !ok {
69		t.Fatal("resolve caller path")
70	}
71	dir := filepath.Dir(filename)
72	for {
73		if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
74			return dir
75		}
76		parent := filepath.Dir(dir)
77		if parent == dir {
78			t.Fatalf("go.mod not found from %s", filename)
79		}
80		dir = parent
81	}
82}

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 8

Tags 42

↑↓ moveenter openesc close