Skip to content

Commit

Permalink
Issue 525 (#532)
Browse files Browse the repository at this point in the history
* signal is now disconnected when time expires
* CHANGES
  • Loading branch information
bitwes authored Nov 26, 2023
1 parent 80f6f96 commit f7c5491
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Added errors and better failure messages when trying to stub or spy on an invalid method. For example, if your script does not implement `_ready` and you try to spy on it, your test will now fail since `_ready` is virtual and you didn't overload it.
* Doubled methods that have a vararg argument are now auto detected and extra parameters (up to 10) are added to the method signature to handle most use cases (i.e. `rpc_id`, `emit_signal`). If you call a doubled method that has a vararg argument and you have not stubbed `param_count` on the object's script then a warning is generated.
* Fixed an issue where command line would not launch in 4.2rc1.
* __Issue 510__ Added all types to strutils to address #510.
* __Issue #510__ Added all types to strutils to address #510.
* __Issue #525__ Signals are now disconnected when waiting on signals that do not fire in the expected amount of time.

# 9.1.0 (requires Godot 4.1)
* GUT generated errors now cause tests to fail (not engine errors, just things GUT thinks are bad). You can disable this through the CLI, .gutconfig, or the panel.
Expand Down
3 changes: 3 additions & 0 deletions addons/gut/awaiter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func _physics_process(delta):


func _end_wait():
if(_signal_to_wait_on != null and _signal_to_wait_on.is_connected(_signal_callback)):
_signal_to_wait_on.disconnect(_signal_callback)

_wait_time = 0.0
_wait_frames = 0
_signal_to_wait_on = null
Expand Down
8 changes: 4 additions & 4 deletions addons/gut/gui/GutSceneTheme.tres

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/unit/test_awaiter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@ func test_is_not_paused_when_signal_emitted_before_max_time():
# gotta wait for the 2 additional frames
await get_tree().create_timer(.05).timeout
assert_false(a.is_waiting())

func test_after_timeout_signal_is_disconnected():
var s = Signaler.new()
var a = add_child_autoqfree(Awaiter.new())
watch_signals(a)
a.wait_for_signal(s.the_signal, .1)
await get_tree().create_timer(.5).timeout
assert_not_connected(s, a, 'the_signal')

0 comments on commit f7c5491

Please sign in to comment.