Skip to content

Commit

Permalink
scan_all_test_directories: Avoid default argument
Browse files Browse the repository at this point in the history
  • Loading branch information
esainane committed Dec 10, 2024
1 parent 14e45cf commit 959b9b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
11 changes: 3 additions & 8 deletions addons/gdUnit4/src/core/command/GdUnitCommandHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ func cmd_run_test_case(test_suite_resource_path: String, test_case: String, test
cmd_run(debug)


func cmd_run_overall(debug :bool) -> void:
var test_suite_paths :PackedStringArray = GdUnitCommandHandler.scan_all_test_directories()
func cmd_run_overall(debug: bool) -> void:
var test_suite_paths: PackedStringArray = GdUnitCommandHandler.scan_all_test_directories(GdUnitSettings.test_root_folder())
var result := _runner_config.clear()\
.add_test_suites(test_suite_paths)\
.save_config()
Expand Down Expand Up @@ -273,12 +273,7 @@ func cmd_create_test() -> void:
func cmd_discover_tests() -> void:
await GdUnitTestDiscoverer.run()

static func scan_all_test_directories(override_root: String = "", force_override: bool = false) -> PackedStringArray:
var root: String
if override_root == "" and not force_override:
root = GdUnitSettings.test_root_folder()
else:
root = override_root
static func scan_all_test_directories(root: String) -> PackedStringArray:
var base_directory := "res://"
# If the test root folder is configured as blank, "/", or "res://", use the root folder as described in the settings panel
if root.is_empty() or root == "/" or root == base_directory:
Expand Down
2 changes: 1 addition & 1 deletion addons/gdUnit4/src/core/discovery/GdUnitTestDiscoverer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static func run() -> void:
var t:= Thread.new()
@warning_ignore("return_value_discarded")
t.start(func () -> void:
var test_suite_directories :PackedStringArray = GdUnitCommandHandler.scan_all_test_directories()
var test_suite_directories :PackedStringArray = GdUnitCommandHandler.scan_all_test_directories(GdUnitSettings.test_root_folder())
var scanner := GdUnitTestSuiteScanner.new()
var _test_suites_to_process :Array[Node] = []

Expand Down
5 changes: 1 addition & 4 deletions addons/gdUnit4/test/core/command/GdUnitCommandHandlerTest.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func test_scan_test_directories() -> void:

func test_scan_all_test_directories() -> void:
# Test when test_root_folder is empty
assert_array(GdUnitCommandHandler.scan_all_test_directories("", true)).contains_exactly(["res://"])
assert_array(GdUnitCommandHandler.scan_all_test_directories("")).contains_exactly(["res://"])

# Test when test_root_folder is "/"
assert_array(GdUnitCommandHandler.scan_all_test_directories("/")).contains_exactly(["res://"])
Expand All @@ -84,6 +84,3 @@ func test_scan_all_test_directories() -> void:

# Test when test_root_folder is set to something which doesn't exist
assert_array(GdUnitCommandHandler.scan_all_test_directories("notest")).is_empty()

# Test when test_root_folder is not passed, retreiving the paarmeter from settings (default is "test")
assert_array(GdUnitCommandHandler.scan_all_test_directories()).contains_exactly(["res://addons/gdUnit4/test"])

0 comments on commit 959b9b1

Please sign in to comment.