Skip to content

Commit

Permalink
append
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Schulze committed Mar 9, 2023
1 parent 906c937 commit faf430d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 72 deletions.
6 changes: 3 additions & 3 deletions addons/gdUnit4/bin/GdUnitCmdTool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ class CLIRunner extends Node:
var to_execute := config.to_execute()
# scan for the requested test suites
var _scanner := GdUnitTestSuiteScanner.new()
for resource_path in to_execute.keys():
var selected_tests :PackedStringArray = to_execute.get(resource_path)
var scaned_suites := _scanner.scan(resource_path)
for resource_path_ in to_execute.keys():
var selected_tests :PackedStringArray = to_execute.get(resource_path_)
var scaned_suites := _scanner.scan(resource_path_)
skip_test_case(scaned_suites, selected_tests)
test_suites_to_process.append_array(scaned_suites)
skip_suites(test_suites_to_process, config)
Expand Down
27 changes: 13 additions & 14 deletions addons/gdUnit4/src/core/GdUnitProperty.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ var _value
var _value_set :PackedStringArray
var _default

@warning_ignore("shadowed_variable")
func _init(name :String, type :int, value, default_value, help :="", value_set := PackedStringArray()):
_name = name
_type = type
_value = value
_value_set = value_set
_default = default_value
_help = help

func _init(p_name :String, p_type :int, p_value, p_default_value, p_help :="", p_value_set := PackedStringArray()):
_name = p_name
_type = p_type
_value = p_value
_value_set = p_value_set
_default = p_default_value
_help = p_help


func name() -> String:
Expand All @@ -38,17 +38,16 @@ func is_selectable_value() -> bool:
return not _value_set.is_empty()


@warning_ignore("shadowed_variable")
func set_value(value) -> void:
func set_value(p_value) -> void:
match _type:
TYPE_STRING:
_value = str(value)
_value = str(p_value)
TYPE_BOOL:
_value = bool(value)
_value = bool(p_value)
TYPE_INT:
_value = int(value)
_value = int(p_value)
TYPE_FLOAT:
_value = float(value)
_value = float(p_value)


func default():
Expand Down
32 changes: 16 additions & 16 deletions addons/gdUnit4/src/core/GdUnitSceneRunnerImpl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ var _key_on_press := []
var _time_factor := 1.0
var _saved_iterations_per_second :float

@warning_ignore("shadowed_variable")
func _init(scene, verbose :bool, hide_push_errors = false):
_verbose = verbose

func _init(p_scene, p_verbose :bool, p_hide_push_errors = false):
_verbose = p_verbose
_saved_iterations_per_second = Engine.get_physics_ticks_per_second()
set_time_factor(1)
# handle scene loading by resource path
if typeof(scene) == TYPE_STRING:
if !FileAccess.file_exists(scene):
if not hide_push_errors:
push_error("GdUnitSceneRunner: Can't load scene by given resource path: '%s'. The resource not exists." % scene)
if typeof(p_scene) == TYPE_STRING:
if !FileAccess.file_exists(p_scene):
if not p_hide_push_errors:
push_error("GdUnitSceneRunner: Can't load scene by given resource path: '%s'. The resource not exists." % p_scene)
return
if !str(scene).ends_with("tscn"):
if not hide_push_errors:
push_error("GdUnitSceneRunner: The given resource: '%s'. is not a scene." % scene)
if !str(p_scene).ends_with("tscn"):
if not p_hide_push_errors:
push_error("GdUnitSceneRunner: The given resource: '%s'. is not a scene." % p_scene)
return
_current_scene = load(scene).instantiate()
_current_scene = load(p_scene).instantiate()
else:
# verify we have a node instance
if not scene is Node:
if not hide_push_errors:
push_error("GdUnitSceneRunner: The given instance '%s' is not a Node." % scene)
if not p_scene is Node:
if not p_hide_push_errors:
push_error("GdUnitSceneRunner: The given instance '%s' is not a Node." % p_scene)
return
_current_scene = scene
_current_scene = p_scene
if _current_scene == null:
if not hide_push_errors:
if not p_hide_push_errors:
push_error("GdUnitSceneRunner: Scene must be not null!")
return
_scene_tree = Engine.get_main_loop()
Expand Down
7 changes: 3 additions & 4 deletions addons/gdUnit4/src/core/GdUnitSignals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ signal gdunit_set_test_failed(is_failed :bool)
const META_KEY := "GdUnitSignals"


@warning_ignore("shadowed_variable")
static func instance() -> GdUnitSignals:
if Engine.has_meta(META_KEY):
return Engine.get_meta(META_KEY)
var instance := GdUnitSignals.new()
Engine.set_meta(META_KEY, instance)
return instance
var instance_ := GdUnitSignals.new()
Engine.set_meta(META_KEY, instance_)
return instance_


static func dispose() -> void:
Expand Down
17 changes: 8 additions & 9 deletions addons/gdUnit4/src/core/GdUnitSingleton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ static func instance(name :String, clazz :Callable) -> Variant:
return singleton


@warning_ignore("shadowed_variable")
static func unregister(singleton :String) -> void:
static func unregister(p_singleton :String) -> void:
var singletons :PackedStringArray = Engine.get_meta(MEATA_KEY, PackedStringArray())
if singletons.has(singleton):
GdUnitTools.prints_verbose(" Unregister singleton '%s'" % singleton);
var index := singletons.find(singleton)
if singletons.has(p_singleton):
GdUnitTools.prints_verbose(" Unregister singleton '%s'" % p_singleton);
var index := singletons.find(p_singleton)
singletons.remove_at(index)
var instance :Variant = Engine.get_meta(singleton)
GdUnitTools.prints_verbose(" Free singeleton instance '%s:%s'" % [singleton, instance])
var instance :Variant = Engine.get_meta(p_singleton)
GdUnitTools.prints_verbose(" Free singeleton instance '%s:%s'" % [p_singleton, instance])
GdUnitTools.free_instance(instance)
Engine.remove_meta(singleton)
GdUnitTools.prints_verbose(" Succesfully freed '%s'" % singleton)
Engine.remove_meta(p_singleton)
GdUnitTools.prints_verbose(" Succesfully freed '%s'" % p_singleton)
Engine.set_meta(MEATA_KEY, singletons)


Expand Down
49 changes: 23 additions & 26 deletions addons/gdUnit4/src/core/_TestCase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,36 @@ func _init():
_default_timeout = GdUnitSettings.test_timeout()


@warning_ignore("shadowed_variable", "shadowed_variable_base_class")
func configure(name: String, line_number: int, script_path: String, timeout :int = DEFAULT_TIMEOUT, fuzzers :Array = [], iterations: int = 1, p_seed :int = -1) -> _TestCase:
set_name(name)
_line_number = line_number
_fuzzers = fuzzers
_iterations = iterations
@warning_ignore("shadowed_variable_base_class")
func configure(p_name: String, p_line_number: int, p_script_path: String, p_timeout :int = DEFAULT_TIMEOUT, p_fuzzers :Array = [], p_iterations: int = 1, p_seed :int = -1) -> _TestCase:
set_name(p_name)
_line_number = p_line_number
_fuzzers = p_fuzzers
_iterations = p_iterations
_seed = p_seed
_script_path = script_path
_script_path = p_script_path
_timeout = _default_timeout
if timeout != DEFAULT_TIMEOUT:
_timeout = timeout
if p_timeout != DEFAULT_TIMEOUT:
_timeout = p_timeout
return self


@warning_ignore("shadowed_variable")
func execute(test_parameter := Array(), iteration := 0):
_current_iteration = iteration - 1
if iteration == 0:
func execute(p_test_parameter := Array(), p_iteration := 0):
_current_iteration = p_iteration - 1
if p_iteration == 0:
_set_failure_handler()
set_timeout()
_monitor.start()
if not test_parameter.is_empty():
update_fuzzers(test_parameter, iteration)
_execute_test_case(name, test_parameter)
if not p_test_parameter.is_empty():
update_fuzzers(p_test_parameter, p_iteration)
_execute_test_case(name, p_test_parameter)
else:
_execute_test_case(name, [])
await completed
_monitor.stop()
for report in _monitor.reports():
if report.is_error():
_report = report
for report_ in _monitor.reports():
if report_.is_error():
_report = report_
_interupted = true


Expand Down Expand Up @@ -196,9 +195,8 @@ func skip(skipped :bool, error :String = "") -> void:
_skip_info = error


@warning_ignore("shadowed_variable")
func set_test_parameters(test_parameters :Array) -> void:
_test_parameters = test_parameters
func set_test_parameters(p_test_parameters :Array) -> void:
_test_parameters = p_test_parameters


func set_test_parameter_index(index :int) -> void:
Expand All @@ -213,13 +211,12 @@ func test_parameter_index() -> int:
return _test_param_index


@warning_ignore("shadowed_variable")
func test_case_names() -> PackedStringArray:
var test_case_names := PackedStringArray()
var test_cases := PackedStringArray()
var test_name = get_name()
for index in _test_parameters.size():
test_case_names.append("%s:%d %s" % [test_name, index, str(_test_parameters[index]).replace('"', "'")])
return test_case_names
test_cases.append("%s:%d %s" % [test_name, index, str(_test_parameters[index]).replace('"', "'")])
return test_cases


func _to_string():
Expand Down

0 comments on commit faf430d

Please sign in to comment.