JeremyStarTM
e7d0a9d9a6
This also adds this nice banner (thanks figlet!): _________________________________ __________ ______ __ ____/_ __ \__ __ \__ ____/ ___ ____/____________ _______ ___________ _________________ /__ _ / _ / / /_ /_/ /_ __/ __ /_ __ ___/ __ `/_ __ `__ \ _ \_ | /| / / __ \_ ___/_ //_/ / /___ / /_/ /_ _, _/_ /___ _ __/ _ / / /_/ /_ / / / / / __/_ |/ |/ // /_/ / / _ ,< \____/ \____/ /_/ |_| /_____/ /_/ /_/ \__,_/ /_/ /_/ /_/\___/____/|__/ \____//_/ /_/|_|
57 lines
2 KiB
GDScript
57 lines
2 KiB
GDScript
# CORE FRAMEWORK TEST FILE
|
|
# Copyright (c) 2024 The StarOpenSource Project & Contributors
|
|
# Licensed under the GNU Affero General Public License v3
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
extends BessereTestsTest
|
|
|
|
# CORE
|
|
var core: Core
|
|
|
|
# Used during testing
|
|
var callback: String = ""
|
|
|
|
# Unload framework after each test
|
|
func after_each() -> void:
|
|
callback = ""
|
|
await unload_framework()
|
|
|
|
# Framework management
|
|
func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
|
if is_framework_loaded(): await unload_framework()
|
|
ldiag("Loading framework")
|
|
config.logger_level = CoreTypes.LoggerLevel.DIAG
|
|
core = Core.new(config)
|
|
get_tree().root.add_child(core)
|
|
core.welcomed = true # Hides the welcome message shown by CORE so it doesn't bloat the log
|
|
await get_tree().process_frame
|
|
await core.complete_init()
|
|
|
|
func unload_framework() -> void:
|
|
if is_framework_loaded():
|
|
ldiag("Unloading framework")
|
|
await core.cleanup()
|
|
get_tree().root.remove_child.call_deferred(core)
|
|
core = null
|
|
await get_tree().process_frame
|
|
else:
|
|
if test_status == 3: lerror("Can't unload framework: Framework is not loaded")
|
|
else: lcrash("Can't unload framework: Framework is not loaded")
|
|
|
|
func is_framework_loaded() -> bool: return get_node_or_null("/root/CORE") != null
|
|
|
|
# Helper functions
|
|
func wait_process_time() -> void:
|
|
ldiag("Waiting process time")
|
|
await get_tree().create_timer(0.1).timeout
|