package app import ( "context" "os" "os/exec" "testing" "time" ) func TestNativeOCRClipboardCopy(t *testing.T) { if os.Getenv("CTHULHU_NATIVE_OCR_COPY") != "1" { t.Skip("requires a private X11 display and xclip") } ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second) defer cancel() want := "é猫 OCR\nsecond line" if err := (xclipOCRCopier{}).Copy(ctx, want); err != nil { t.Fatal(err) } got, err := exec.CommandContext(ctx, "xclip", "-selection", "clipboard", "-out").Output() if err != nil { t.Fatal(err) } if string(got) != want { t.Fatalf("clipboard = %q, want %q", got, want) } }