fix test otherwise we result on fucking luck per build
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user