mirror of
https://github.com/Relintai/regression-test-project.git
synced 2024-11-12 10:25:30 +01:00
Time support (#63)
This commit is contained in:
parent
95da6a1ad7
commit
c4fe91f121
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ logs/
|
||||
.godot/imported/
|
||||
.godot/editor
|
||||
shader_cache/
|
||||
.import/
|
||||
|
@ -24,9 +24,18 @@ const alone_steps: Array = [
|
||||
"res://AutomaticBugs/FunctionExecutor.tscn", # Only runs
|
||||
]
|
||||
|
||||
var time_object : Object
|
||||
|
||||
func _init():
|
||||
start_time = OS.get_ticks_msec()
|
||||
if ClassDB.class_exists("_Time"):
|
||||
time_object = ClassDB.instance("_Time")
|
||||
elif ClassDB.class_exists("Time"):
|
||||
time_object = ClassDB.instance("_Time")
|
||||
else:
|
||||
time_object = ClassDB.instance("_OS")
|
||||
|
||||
|
||||
start_time = time_object.get_ticks_msec()
|
||||
|
||||
# In case when user doesn't provide time
|
||||
time_for_each_step = time_to_show / (alone_steps.size())
|
||||
@ -40,7 +49,7 @@ func _init():
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var current_run_time: int = OS.get_ticks_msec() - start_time
|
||||
var current_run_time: int = time_object.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:
|
||||
@ -50,3 +59,6 @@ func _process(delta: float) -> void:
|
||||
if current_run_time > time_to_show && can_be_closed:
|
||||
print("######################## Ending test ########################")
|
||||
get_tree().quit()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
time_object.free()
|
||||
|
4
Start.gd
4
Start.gd
@ -11,11 +11,11 @@ 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)
|
||||
array_with_time_to_change.append(Autoload.time_object.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]:
|
||||
if current_scene < Autoload.alone_steps.size() - 1 && Autoload.time_object.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
|
||||
|
Loading…
Reference in New Issue
Block a user