fix test otherwise we result on fucking luck per build

This commit is contained in:
KingKDot
2026-03-06 19:32:16 -06:00
parent 973837ebfd
commit e196145d6f
2 changed files with 37 additions and 4 deletions
@@ -4,7 +4,10 @@ package capture
import (
"image"
"os"
"strings"
"testing"
"time"
)
func TestDesktopDuplicationToggleResetsState(t *testing.T) {
@@ -48,8 +51,30 @@ func TestCaptureDisplayDXGI(t *testing.T) {
SetDesktopDuplication(true)
t.Cleanup(func() { SetDesktopDuplication(false) })
img, err := captureDisplayDXGI(0)
var (
img *image.RGBA
err error
)
for attempt := 0; attempt < 4; attempt++ {
img, err = captureDisplayDXGI(0)
if err == nil {
break
}
msg := strings.ToLower(err.Error())
if strings.Contains(msg, "dxgi: frame timeout") || strings.Contains(msg, "dxgi: access lost") {
time.Sleep(60 * time.Millisecond)
continue
}
break
}
if err != nil {
msg := strings.ToLower(err.Error())
if os.Getenv("GITHUB_ACTIONS") == "true" &&
(strings.Contains(msg, "dxgi: frame timeout") || strings.Contains(msg, "dxgi: access lost")) {
t.Skipf("skipping unstable DXGI capture on CI runner: %v", err)
}
t.Fatalf("dxgi capture failed: %v", err)
}
if img == nil {