Skip to content

Commit

Permalink
Merge branch 'dev' into improve-test-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDarigan authored Dec 17, 2021
2 parents f3c6cee + 264807b commit c459297
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 20 additions & 5 deletions addons/WAT/network/test_server.gd
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
tool
extends "res://addons/WAT/network/test_network.gd"

enum STATE { SENDING, RECEIVING }
signal network_peer_connected
signal results_received

enum STATE { SENDING, RECEIVING, DISCONNECTED }

var _peer_id: int
# Store incoming cases from client in case of abrupt termination.
var caselist: Array = []
var results_view: TabContainer
var status: int = STATE.DISCONNECTED

func _ready() -> void:
if not Engine.is_editor_hint():
return
custom_multiplayer.connect("network_peer_connected", self, "_on_network_peer_connected")
custom_multiplayer.connect("network_peer_disconnected", self, "_on_network_peer_disconnected")
if _error(_peer.create_server(PORT, MAXCLIENTS)) == OK:
custom_multiplayer.network_peer = _peer

func _on_network_peer_connected(id: int) -> void:
_peer_id = id
_peer.set_peer_timeout(id, 59000, 60000, 61000)
_peer.set_peer_timeout(id, 1000, 2000, 3000)
emit_signal("network_peer_connected")


func _on_network_peer_disconnected(_id: int) -> void:
if status == STATE.SENDING:
emit_signal("results_received", caselist)
caselist.clear()
status = STATE.DISCONNECTED

func send_tests(testdir: Array, repeat: int, thread_count: int) -> void:
status = STATE.SENDING
rpc_id(_peer_id, "_on_tests_received_from_server", testdir, repeat, thread_count)

master func _on_results_received_from_client(results: Array = []) -> void:
status = STATE.RECEIVING
emit_signal("results_received", results)
_peer.disconnect_peer(_peer_id, true)

var results_view: TabContainer

master func _on_test_script_started(data: Dictionary) -> void:
results_view.on_test_script_started(data)

master func _on_test_script_finished(data: Dictionary) -> void:
results_view.on_test_script_finished(data)
caselist.append(data)

master func _on_test_method_started(data: Dictionary) -> void:
results_view.on_test_method_started(data)
Expand Down
4 changes: 4 additions & 0 deletions addons/WAT/ui/gui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func setup_editor_context(plugin, build: FuncRef, goto_func: FuncRef, filesystem
TestMenu.update_menus()
Server.results_view = Results


# Setup tests for display. Returns false if run should be terminated.
func _setup_display(tests: Array) -> bool:
if tests.empty():
Expand All @@ -67,6 +68,7 @@ func _setup_display(tests: Array) -> bool:
Results.display(tests, Repeats.value)
return true


func _on_run_pressed(data = _filesystem.root) -> void:
Results.clear()
var current_build = true
Expand Down Expand Up @@ -114,7 +116,9 @@ func _on_debug_pressed(data = _filesystem.root) -> void:
_plugin.get_editor_interface().stop_playing_scene() # Check if this works exported
_on_test_run_finished(results)


func _on_test_run_finished(results: Array) -> void:
_plugin.get_editor_interface().stop_playing_scene() # Check if this works exported
Summary.summarize(results)
JUnitXML.write(results, Settings, Summary.time_taken)
_filesystem.failed.update(results)
Expand Down

0 comments on commit c459297

Please sign in to comment.