Versions
- Godot: 4.x
- GUT: 9.x
- OS: not OS Specific
The Bug
When a method that is stubbed to call super returns a Signal, GUT will hang forever.
This happens because all calls to super are done using await because there is no way to know if the method is a co-routine via the metadata (maybe that has changed, idk). Since you can't know if the await is required, we have to treat everything like it is a co-routine.
The await in the double's wrapper method waits on the returned signal to be emitted, thus causing the run to hang.
This was found when implementing default return values for functions that have a typed return. GUT should probably generate an error whenever it tries to wrap a method that returns a Signal. This doesn't help untyped methods that return a Signal, but it's something. Something should also be added to the documentation.
The workaround is to call ignore_method_when_doubling on the class, prior to creating doubles. In the below example this would look like:
func before_all():
ignore_method_when_doubling(MyClass, 'get_my_signal')
Steps To Reproduce
The class
class_name MyClass
signal my_signal
func get_my_signal():
return my_signal
The test
extends GutTest
func test_the_problem():
var inst = partial_double(MyClass).new()
var result = inst.get_my_signal() # Hangs here
Versions
The Bug
When a method that is stubbed to call super returns a
Signal, GUT will hang forever.This happens because all calls to
superare done usingawaitbecause there is no way to know if the method is a co-routine via the metadata (maybe that has changed, idk). Since you can't know if theawaitis required, we have to treat everything like it is a co-routine.The
awaitin the double's wrapper method waits on the returned signal to be emitted, thus causing the run to hang.This was found when implementing default return values for functions that have a typed return. GUT should probably generate an error whenever it tries to wrap a method that returns a Signal. This doesn't help untyped methods that return a Signal, but it's something. Something should also be added to the documentation.
The workaround is to call
ignore_method_when_doublingon the class, prior to creating doubles. In the below example this would look like:Steps To Reproduce
The class
The test