regression-test-project/Autoload/Autoload.gd

59 lines
1.8 KiB
GDScript3
Raw Normal View History

2020-08-05 11:03:11 +02:00
extends Node
const screen_size = Vector2(1024, 600)
2020-10-29 08:52:56 +01:00
2020-12-04 13:50:02 +01:00
var start_time : int
var last_time : int
2020-12-04 13:50:02 +01:00
const PRINT_TIME_EVERY_MILISECONDS : int = 5000
var time_to_print_next_time : int = PRINT_TIME_EVERY_MILISECONDS
2020-08-05 11:03:11 +02:00
2020-12-04 13:50:02 +01:00
var time_to_show: int = 30 * 1000 # How long test works in miliseconds
2020-08-05 11:03:11 +02:00
2020-12-04 13:50:02 +01:00
var time_for_each_step : int = -1
2020-11-17 19:21:50 +01:00
# Each scene runs alone
const alone_steps : Array = [
"res://MainScenes/Control.tscn",
"res://MainScenes/Node2D.tscn",
"res://MainScenes/Other.tscn",
"res://MainScenes/Spatial.tscn",
"res://Physics/2D/Physics2D.tscn",
"res://Physics/3D/Physics3D.tscn",
"res://Rendering/Lights2D/Lights2D.tscn",
"res://Rendering/Lights3D/Lights3D.tscn",
2020-12-01 10:16:36 +01:00
"res://Text/Text.tscn"
2020-11-17 19:21:50 +01:00
]
# All scenes run in one step
# This should be put regression scripts which needs to run only once
const all_in_one : Array = [
"res://AIO/Operators/Operators.tscn",
]
func _init():
2020-12-04 13:50:02 +01:00
start_time = OS.get_system_time_msecs()
2020-11-17 19:21:50 +01:00
# In case when user doesn't provide time
time_for_each_step = time_to_show / (alone_steps.size() + 1)
2020-08-05 11:03:11 +02:00
for argument in OS.get_cmdline_args():
var rr: String = argument
2020-12-04 13:50:02 +01:00
if rr.ends_with("tscn"): # Ignore all tscn scenes/names
2020-08-05 11:03:11 +02:00
continue
2020-12-04 13:50:02 +01:00
time_to_show = int(argument.to_float() * 1000)
2020-11-17 19:21:50 +01:00
time_for_each_step = time_to_show / (alone_steps.size() + 1)
2020-12-04 13:50:02 +01:00
print("Time set to: " + str(time_to_show / 1000.0) + " seconds with "+ str(alone_steps.size() + 1) + " steps, each step will take " + str(time_for_each_step / 1000.0) + " seconds.")
2020-08-05 11:03:11 +02:00
func _process(delta: float) -> void:
2020-12-04 13:50:02 +01:00
var current_run_time : int = OS.get_system_time_msecs() - start_time
2020-11-17 19:21:50 +01:00
if current_run_time > time_to_print_next_time:
2020-12-04 13:50:02 +01:00
print("Test is running now " + str(int(time_to_print_next_time / 1000)) + " seconds")
time_to_print_next_time += PRINT_TIME_EVERY_MILISECONDS
2020-11-17 19:21:50 +01:00
if current_run_time > time_to_show:
2020-12-04 13:50:02 +01:00
print("Ending test")
2020-08-05 11:03:11 +02:00
get_tree().quit()