Files
magpie/internal/gui/terminal_apps_darwin_test.go
T
Karenandyetone 2693cd8828 feat(gui): choose macOS session terminal (#241)
* feat(gui): choose macOS session terminal

* session terminal: build the darwin CLI without cgo, drop the dead macOS 11 path, and open Terminal when the .command default is not a terminal

- terminal_apps_darwin.go imports "C" but had no cgo tag, and terminal_apps_other.go was !darwin only, so `CGO_ENABLED=0 GOOS=darwin go build -tags nogui .` (make release-cli's darwin targets) failed with undefined discoverTerminals. The cgo file and its test are now darwin && cgo; the stub is !darwin || !cgo.
- magpie needs macOS 12 (LSMinimumSystemVersion, -mmacosx-version-min=12.0), so the macOS 11 branch (temp .command file, deprecated LSCopyApplicationURLsForURL, CFRelease) never ran; it is gone along with the CoreServices link.
- With no saved choice, a default .command handler that is not a listed terminal, or a failed lookup, now opens Terminal as before the PR instead of failing; Settings labels the system option "System default (Terminal)" then, and the unused "System default (unavailable)" string is dropped.
- session-terminal.test.cjs covers an editor as the default in Chromium and WebKit, en and zh, and is on the README's node --test line.

---------

Co-authored-by: yetone <yetoneful@gmail.com>
2026-09-30 02:36:12 +08:00

25 lines
516 B
Go

//go:build darwin && cgo
package gui
import "testing"
func TestDiscoverTerminals(t *testing.T) {
found, err := discoverTerminals()
if err != nil {
t.Fatal(err)
}
terminalFound := false
for _, app := range found.Apps {
if app.ID == "com.apple.TextEdit" {
t.Fatal("a text editor was offered as a session terminal")
}
if app.ID == terminalBundleID && app.Path != "" {
terminalFound = true
}
}
if !terminalFound {
t.Fatalf("Terminal.app missing from .command handlers: %+v", found.Apps)
}
}