Force to show all functions (#50)

This commit is contained in:
Rafał Mikrut 2021-05-18 06:57:08 +02:00 committed by GitHub
parent 7177d6034a
commit a02f53255e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 27 deletions

View File

@ -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()

View File

@ -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)