Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: brew install gpgme gnupg@1.4
- run: brew install gpgme gnupg
- uses: actions/setup-go@v3
with:
go-version: '1.17.12'
Expand Down
45 changes: 2 additions & 43 deletions gpgme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)

Expand Down Expand Up @@ -118,10 +117,10 @@ func TestGetDirInfo(t *testing.T) {
}

func ctxWithCallback(t *testing.T) *Context {
ensureVersion(t, "1.", "can only set password callback for GPG v1.x")

ctx, err := New()
checkError(t, err)
err = ctx.SetPinEntryMode(PinEntryLoopback)
checkError(t, err)

checkError(t, ctx.SetCallback(func(uid_hint string, prev_was_bad bool, f *os.File) error {
if prev_was_bad {
Expand Down Expand Up @@ -395,46 +394,6 @@ func TestContext_AssuanSend(t *testing.T) {
checkError(t, err)
}

func isVersion(t testing.TB, version string) bool {
t.Helper()
var info *EngineInfo
info, err := GetEngineInfo()
checkError(t, err)
for info != nil {
if info.Protocol() == ProtocolOpenPGP {
if strings.Contains(info.FileName(), "gpg") && strings.HasPrefix(info.Version(), version) {
return true
}
return false
}
info = info.Next()
}
return false
}

var gpgBins = []string{"gpg2", "gpg1", "gpg"}

// ensureVersion tries to setup gpgme with a specific version or skip
func ensureVersion(t testing.TB, version, msg string) {
t.Helper()
if isVersion(t, version) {
return
}
for _, bin := range gpgBins {
path, err := exec.LookPath(bin)
if err != nil {
continue
}
if err := SetEngineInfo(ProtocolOpenPGP, path, absTestGPGHome()); err != nil {
continue
}
if isVersion(t, version) {
return
}
}
t.Skip(msg)
}

func diff(t testing.TB, dst, src []byte) {
t.Helper()
line := 1
Expand Down
Loading