From a02f53255efc996bc774ef87699116567bfc80eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Tue, 18 May 2021 06:57:08 +0200 Subject: [PATCH] Force to show all functions (#50) --- Autoload/Autoload.gd | 41 ++++++++++++++++++++++------------------- Start.gd | 22 ++++++++++++++-------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Autoload/Autoload.gd b/Autoload/Autoload.gd index 4436293..ec1a18d 100644 --- a/Autoload/Autoload.gd +++ b/Autoload/Autoload.gd @@ -2,47 +2,50 @@ extends Node const screen_size = Vector2(1024, 600) -var start_time : int -var last_time : int +var start_time: int +var last_time: int -const PRINT_TIME_EVERY_MILISECONDS : int = 5000 -var time_to_print_next_time : int = PRINT_TIME_EVERY_MILISECONDS +const PRINT_TIME_EVERY_MILISECONDS: int = 5000 +var time_to_print_next_time: int = PRINT_TIME_EVERY_MILISECONDS -var time_to_show: int = 25 * 1000 # How long test works in miliseconds +var time_to_show: int = 25 * 1000 # How long test works in miliseconds -var time_for_each_step : int = -1 +var time_for_each_step: int = -1 + +var can_be_closed: bool = true # Each scene runs alone -const alone_steps : Array = [ +const alone_steps: Array = [ "res://Nodes/Nodes.tscn", "res://Physics/2D/Physics2D.tscn", "res://Physics/3D/Physics3D.tscn", "res://ReparentingDeleting/ReparentingDeleting.tscn", - "res://AutomaticBugs/FunctionExecutor.tscn", # Only runs + "res://AutomaticBugs/FunctionExecutor.tscn", # Only runs ] -func _init(): + +func _init(): start_time = OS.get_ticks_msec() - + # In case when user doesn't provide time time_for_each_step = time_to_show / (alone_steps.size()) - + for argument in OS.get_cmdline_args(): - if argument.is_valid_float(): # Ignore all non numeric arguments + if argument.is_valid_float(): # Ignore all non numeric arguments time_to_show = int(argument.to_float() * 1000) time_for_each_step = time_to_show / (alone_steps.size()) - print("Time set to: " + str(time_to_show / 1000.0) + " seconds with "+ str(alone_steps.size()) + " steps, each step will take " + str(time_for_each_step / 1000.0) + " seconds.") - break # We only need to take first argument + print("Time set to: " + str(time_to_show / 1000.0) + " seconds with " + str(alone_steps.size()) + " steps, each step will take " + str(time_for_each_step / 1000.0) + " seconds.") + break # We only need to take first argument func _process(delta: float) -> void: - var current_run_time : int = OS.get_ticks_msec() - start_time - + var current_run_time: int = OS.get_ticks_msec() - start_time + # While loop instead if, will allow to properly flush results under heavy operations(e.g. Thread sanitizer) - while current_run_time > time_to_print_next_time: + while current_run_time > time_to_print_next_time: print("Test is running now " + str(int(time_to_print_next_time / 1000)) + " seconds") time_to_print_next_time += PRINT_TIME_EVERY_MILISECONDS - - if current_run_time > time_to_show: + + if current_run_time > time_to_show && can_be_closed: print("######################## Ending test ########################") get_tree().quit() diff --git a/Start.gd b/Start.gd index de02dcb..4e37154 100644 --- a/Start.gd +++ b/Start.gd @@ -1,24 +1,30 @@ extends Control -var current_scene : int = -1 -var time_to_switch : int -const NUMBER_OF_INSTANCES : int = 1 # Use more than 1 to stress test, 1 should be optimal for casual CI +var current_scene: int = -1 +var time_to_switch: int +const NUMBER_OF_INSTANCES: int = 1 # Use more than 1 to stress test, 1 should be optimal for casual CI + +var array_with_time_to_change: Array = [] -var array_with_time_to_change : Array = [] func _ready(): + Autoload.can_be_closed = false + for i in Autoload.alone_steps.size() + 1: array_with_time_to_change.append(OS.get_ticks_msec() + i * Autoload.time_for_each_step) + func _process(_delta): if current_scene < Autoload.alone_steps.size() - 1 && OS.get_ticks_msec() > array_with_time_to_change[current_scene + 1]: current_scene += 1 - + if current_scene == Autoload.alone_steps.size() - 1: + Autoload.can_be_closed = true + for child in get_children(): child.queue_free() - + print("Changed scene to " + Autoload.alone_steps[current_scene]) - + for _i in range(NUMBER_OF_INSTANCES): - var scene : Node = load(Autoload.alone_steps[current_scene]).instance() + var scene: Node = load(Autoload.alone_steps[current_scene]).instance() add_child(scene)