fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25k stars 1.39k forks source link

Test in internal/driver/glfw/ suite cannot run multiple times #714

Open stuartmscott opened 4 years ago

stuartmscott commented 4 years ago

Context:

go test has a parameter '-count n' that executes the tests n times which can be used to find race conditions and sporadic bugs.

Describe the bug:

Running the fyne tests multiple times causes several failures:

To Reproduce:

Steps to reproduce the behaviour:

  1. go test -count=10 fyne.io/fyne/...

Device:

Error:

$ go test -count=10 fyne.io/fyne/...
# fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw
In file included from ../../../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw_darwin.go:8:
../../../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/cocoa_window.m:989:9: warning: multiple methods named 'center' found [-Wobjc-multiple-method-names]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCollectionViewCompositionalLayout.h:601:19: note: using
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:312:1: note: also found
# fyne.io/fyne/internal/driver/glfw
../../../fyne.io/fyne/internal/driver/glfw/gl_darwinfix.go:10:5: warning: 'NSOpenGLContext' is deprecated: first deprecated in macOS 10.14 - Please use Metal or MetalKit. [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:193:12: note: 'NSOpenGLContext' has been explicitly marked deprecated here
ok      fyne.io/fyne    0.381s
ok      fyne.io/fyne/app    0.511s
ok      fyne.io/fyne/canvas 0.418s
ok      fyne.io/fyne/cmd/fyne   0.422s
?       fyne.io/fyne/cmd/fyne/internal/mobile   [no test files]
?       fyne.io/fyne/cmd/fyne/internal/mobile/binres    [no test files]
?       fyne.io/fyne/cmd/fyne_demo  [no test files]
?       fyne.io/fyne/cmd/fyne_demo/data [no test files]
?       fyne.io/fyne/cmd/fyne_demo/screens  [no test files]
?       fyne.io/fyne/cmd/fyne_settings  [no test files]
?       fyne.io/fyne/cmd/fyne_settings/data [no test files]
?       fyne.io/fyne/cmd/fyne_settings/settings [no test files]
?       fyne.io/fyne/cmd/hello  [no test files]
ok      fyne.io/fyne/dialog 0.266s
ok      fyne.io/fyne/driver/desktop 0.191s
?       fyne.io/fyne/driver/mobile  [no test files]
ok      fyne.io/fyne/internal   0.198s
ok      fyne.io/fyne/internal/app   1.066s
?       fyne.io/fyne/internal/cache [no test files]
ok      fyne.io/fyne/internal/driver    0.349s
# fyne.io/fyne/internal/driver/glfw
fyne.io/fyne/internal/driver/glfw/gl_darwinfix.go:10:5: warning: 'NSOpenGLContext' is deprecated: first deprecated in macOS 10.14 - Please use Metal or MetalKit. [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:193:12: note: 'NSOpenGLContext' has been explicitly marked deprecated here
2020/02/26 08:24:35 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:35   Cause: image: unknown format
2020/02/26 08:24:35   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:38 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:38   Cause: image: unknown format
2020/02/26 08:24:38   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:40 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:40   Cause: image: unknown format
2020/02/26 08:24:40   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:43 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:43   Cause: image: unknown format
2020/02/26 08:24:43   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:45 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:45   Cause: image: unknown format
2020/02/26 08:24:45   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:48 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:48   Cause: image: unknown format
2020/02/26 08:24:48   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:51 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:51   Cause: image: unknown format
2020/02/26 08:24:51   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:54 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:54   Cause: image: unknown format
2020/02/26 08:24:54   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:24:57 Fyne error:  Failed to decode image for window icon
2020/02/26 08:24:57   Cause: image: unknown format
2020/02/26 08:24:57   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:213
2020/02/26 08:31:58 Fyne error:  window creation error
2020/02/26 08:31:58   Cause: VersionUnavailable: NSGL: Failed to create OpenGL context
2020/02/26 08:31:58   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:1044
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x4386af6]

goroutine 1758 [running]:
testing.tRunner.func1(0xc00010c100)
    /usr/local/go/src/testing/testing.go:874 +0x3a3
panic(0x443fa20, 0x4a838c0)
    /usr/local/go/src/runtime/panic.go:679 +0x1b2
fyne.io/fyne/internal/driver/glfw.(*window).SetPadded(0x0, 0x44c0f01)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:188 +0x26
fyne.io/fyne/internal/driver/glfw.Test_glCanvas_SetContent.func2(0xc00010c100)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/canvas_test.go:68 +0xa3
testing.tRunner(0xc00010c100, 0xc0005a4000)
    /usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:960 +0x350
FAIL    fyne.io/fyne/internal/driver/glfw   445.917s
ok      fyne.io/fyne/internal/driver/gomobile   4.031s
?       fyne.io/fyne/internal/painter   [no test files]
ok      fyne.io/fyne/internal/painter/gl    0.450s
?       fyne.io/fyne/internal/painter/software  [no test files]
ok      fyne.io/fyne/layout 0.358s
ok      fyne.io/fyne/test   0.279s
ok      fyne.io/fyne/theme  0.212s
ok      fyne.io/fyne/tools/modvendor    0.149s
?       fyne.io/fyne/tools/playground   [no test files]
panic: test timed out after 10m0s

goroutine 349 [running]:
testing.(*M).startAlarm.func1()
    /usr/local/go/src/testing/testing.go:1377 +0xdf
created by time.goFunc
    /usr/local/go/src/time/sleep.go:168 +0x44

goroutine 1 [chan receive, 9 minutes]:
testing.(*T).Run(0xc000116300, 0x141535d, 0x1d, 0x1426cb8, 0x107e801)
    /usr/local/go/src/testing/testing.go:961 +0x377
testing.runTests.func1(0xc0001d2600)
    /usr/local/go/src/testing/testing.go:1202 +0x78
testing.tRunner(0xc0001d2600, 0xc00010bdc0)
    /usr/local/go/src/testing/testing.go:909 +0xc9
testing.runTests(0xc0000b43c0, 0x18ea480, 0xfb, 0xfb, 0x0)
    /usr/local/go/src/testing/testing.go:1200 +0x2a7
testing.(*M).Run(0xc000114000, 0x0)
    /usr/local/go/src/testing/testing.go:1117 +0x176
main.main()
    _testmain.go:544 +0x135

goroutine 19 [chan receive, 9 minutes]:
fyne.io/fyne/test.NewApp.func1(0xc0000880c0, 0xc00009cd80)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:105 +0x3d
created by fyne.io/fyne/test.NewApp
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:103 +0x1ce

goroutine 101 [chan receive, 9 minutes]:
fyne.io/fyne/test.NewApp.func1(0xc00006c180, 0xc00009cf30)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:105 +0x3d
created by fyne.io/fyne/test.NewApp
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:103 +0x1ce

goroutine 103 [chan receive, 9 minutes]:
fyne.io/fyne/test.NewApp.func1(0xc00006c240, 0xc000020630)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:105 +0x3d
created by fyne.io/fyne/test.NewApp
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:103 +0x1ce

goroutine 104 [chan receive, 9 minutes]:
fyne.io/fyne/test.NewApp.func1(0xc000088240, 0xc0001d8330)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:105 +0x3d
created by fyne.io/fyne/test.NewApp
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:103 +0x1ce

goroutine 196 [chan receive]:
fyne.io/fyne/widget.(*infProgressRenderer).infiniteProgressLoop(0xc000087b00)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/progressbarinfinite.go:119 +0x3a
created by fyne.io/fyne/widget.(*infProgressRenderer).start
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/progressbarinfinite.go:105 +0xe9

goroutine 200 [chan receive, 9 minutes]:
fyne.io/fyne/widget.(*infProgressRenderer).infiniteProgressLoop(0xc000087d80)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/progressbarinfinite.go:119 +0x3a
created by fyne.io/fyne/widget.(*infProgressRenderer).start
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/progressbarinfinite.go:105 +0xe9

goroutine 297 [chan receive, 9 minutes]:
fyne.io/fyne/test.NewApp.func1(0xc0000892c0, 0xc0001b8c90)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:105 +0x3d
created by fyne.io/fyne/test.NewApp
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:103 +0x1ce

goroutine 188 [chan send, 9 minutes]:
fyne.io/fyne/widget.(*myWidget).Refresh(0xc0001324b0)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/widget_test.go:21 +0x3b
fyne.io/fyne/test.(*testApp).applyThemeTo(0xc00009dc50, 0x14980e0, 0xc0001324b0, 0x149a3c0, 0xc000206b40)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:57 +0x3e
fyne.io/fyne/test.(*testApp).applyThemeTo(0xc00009dc50, 0x1497ba0, 0xc00013ad20, 0x149a3c0, 0xc000206b40)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:61 +0x1a7
fyne.io/fyne/test.(*testApp).applyTheme(0xc00009dc50)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:75 +0xe0
fyne.io/fyne/test.NewApp.func1(0xc00006cd20, 0xc00009dc50)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:106 +0x4b
created by fyne.io/fyne/test.NewApp
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:103 +0x1ce

goroutine 376 [chan send, 9 minutes]:
fyne.io/fyne/test.(*testSettings).apply(0xc000213f00)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:149 +0xbd
fyne.io/fyne/test.(*testSettings).SetTheme(0xc000213f00, 0x149ac00, 0x190a748)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/test/testapp.go:130 +0x45
fyne.io/fyne/widget.withTestTheme(0xc000494748)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/widget_test.go:174 +0x97
fyne.io/fyne/widget.TestButtonRenderer_ApplyTheme(0xc000116300)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/widget/button_test.go:229 +0xb5
testing.tRunner(0xc000116300, 0x1426cb8)
    /usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:960 +0x350
FAIL    fyne.io/fyne/widget 600.211s
FAIL
stuartmscott commented 4 years ago

Darwin Menu Tests are failing on develop when run multiple times:

$ git rev-parse HEAD
a907f129e7b41c03d825c6da3c2fa71ab5b4fb6f
$ go test -count 2 ./...
ok      fyne.io/fyne    0.232s
ok      fyne.io/fyne/app    0.257s
ok      fyne.io/fyne/canvas 0.279s
ok      fyne.io/fyne/cmd/fyne   0.234s
?       fyne.io/fyne/cmd/fyne/internal/mobile   [no test files]
?       fyne.io/fyne/cmd/fyne/internal/mobile/binres    [no test files]
?       fyne.io/fyne/cmd/fyne_demo  [no test files]
?       fyne.io/fyne/cmd/fyne_demo/data [no test files]
?       fyne.io/fyne/cmd/fyne_demo/screens  [no test files]
?       fyne.io/fyne/cmd/fyne_settings  [no test files]
?       fyne.io/fyne/cmd/fyne_settings/data [no test files]
ok      fyne.io/fyne/cmd/fyne_settings/settings 0.296s
?       fyne.io/fyne/cmd/hello  [no test files]
ok      fyne.io/fyne/dialog 7.661s
ok      fyne.io/fyne/driver/desktop 0.175s
?       fyne.io/fyne/driver/mobile  [no test files]
ok      fyne.io/fyne/internal   0.301s
ok      fyne.io/fyne/internal/app   0.388s
?       fyne.io/fyne/internal/cache [no test files]
ok      fyne.io/fyne/internal/driver    0.274s

2020/05/20 20:20:03 Fyne error:  Failed to decode image for window icon
2020/05/20 20:20:03   Cause: image: unknown format
2020/05/20 20:20:03   At: /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/window.go:219
--- FAIL: TestDarwinMenu (0.00s)
panic: runtime error: index out of range [2] with length 2 [recovered]
    panic: runtime error: index out of range [2] with length 2

goroutine 301 [running]:
testing.tRunner.func1.1(0x44c7d80, 0xc000258000)
    /usr/local/go/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc00028c000)
    /usr/local/go/src/testing/testing.go:943 +0x3f9
panic(0x44c7d80, 0xc000258000)
    /usr/local/go/src/runtime/panic.go:969 +0x166
fyne.io/fyne/internal/driver/glfw.resetMainMenu()
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/menu_darwin_test.go:134 +0x24d
fyne.io/fyne/internal/driver/glfw.TestDarwinMenu(0xc00028c000)
    /Users/stuartscott/Documents/Projects/Go/src/fyne.io/fyne/internal/driver/glfw/menu_darwin_test.go:21 +0xb3
testing.tRunner(0xc00028c000, 0x4526218)
    /usr/local/go/src/testing/testing.go:991 +0xdc
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:1042 +0x357
FAIL    fyne.io/fyne/internal/driver/glfw   26.921s
ok      fyne.io/fyne/internal/driver/gomobile   1.159s
ok      fyne.io/fyne/internal/painter   1.791s
ok      fyne.io/fyne/internal/painter/gl    0.211s
ok      fyne.io/fyne/internal/painter/software  0.234s
ok      fyne.io/fyne/internal/widget    8.626s
ok      fyne.io/fyne/layout 0.262s
ok      fyne.io/fyne/storage    0.171s
ok      fyne.io/fyne/test   0.256s
ok      fyne.io/fyne/theme  0.222s
?       fyne.io/fyne/tools/playground   [no test files]
ok      fyne.io/fyne/widget 20.478s
FAIL

@toaster can you take a look?

andydotxyz commented 4 years ago

That menu test is now addressed by PR #1029.

When I tried to run the GLFW tests 10 times it failed after 5 due to the GL context issue that caused your Nil above, so there is still work to do

andydotxyz commented 3 years ago

I can't seem to replicate this on develop any more, is that just me?

❯ go test ../../internal/driver/glfw/ -count 3
ok      fyne.io/fyne/v2/internal/driver/glfw    28.278s