trying to fix Export
All checks were successful
Create tag and build when new code gets to main / Export (push) Successful in 6m53s
All checks were successful
Create tag and build when new code gets to main / Export (push) Successful in 6m53s
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
var _context_menus := Dictionary()
|
||||
var _command_handler := GdUnitCommandHandler.instance()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
set_name("EditorFileSystemContextMenuHandler")
|
||||
|
||||
var is_test_suite := func is_visible(script: Script, is_ts: bool) -> bool:
|
||||
if script == null:
|
||||
return false
|
||||
return GdUnitTestSuiteScanner.is_test_suite(script) == is_ts
|
||||
var context_menus :Array[GdUnitContextMenuItem] = [
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_RUN, "Run Testsuites", "Play", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTSUITE)),
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_DEBUG, "Debug Testsuites", "PlayStart", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTSUITE_DEBUG)),
|
||||
]
|
||||
for menu in context_menus:
|
||||
_context_menus[menu.id] = menu
|
||||
var popup := _menu_popup()
|
||||
var file_tree := _file_tree()
|
||||
@warning_ignore("return_value_discarded")
|
||||
popup.about_to_popup.connect(on_context_menu_show.bind(popup, file_tree))
|
||||
@warning_ignore("return_value_discarded")
|
||||
popup.id_pressed.connect(on_context_menu_pressed.bind(file_tree))
|
||||
|
||||
|
||||
func on_context_menu_show(context_menu: PopupMenu, file_tree: Tree) -> void:
|
||||
context_menu.add_separator()
|
||||
var current_index := context_menu.get_item_count()
|
||||
|
||||
for menu_id: int in _context_menus.keys():
|
||||
var menu_item: GdUnitContextMenuItem = _context_menus[menu_id]
|
||||
|
||||
context_menu.add_item(menu_item.name, menu_id)
|
||||
#context_menu.set_item_icon_modulate(current_index, Color.MEDIUM_PURPLE)
|
||||
context_menu.set_item_disabled(current_index, !menu_item.is_enabled(null))
|
||||
context_menu.set_item_icon(current_index, GdUnitUiTools.get_icon(menu_item.icon))
|
||||
current_index += 1
|
||||
|
||||
|
||||
func on_context_menu_pressed(id: int, file_tree: Tree) -> void:
|
||||
if !_context_menus.has(id):
|
||||
return
|
||||
var menu_item: GdUnitContextMenuItem = _context_menus[id]
|
||||
var test_suites := collect_testsuites(menu_item, file_tree)
|
||||
|
||||
menu_item.execute([test_suites])
|
||||
|
||||
|
||||
func collect_testsuites(_menu_item: GdUnitContextMenuItem, file_tree: Tree) -> Array[Script]:
|
||||
var file_system := EditorInterface.get_resource_filesystem()
|
||||
var selected_item := file_tree.get_selected()
|
||||
var selected_test_suites: Array[Script] = []
|
||||
var suite_scaner := GdUnitTestSuiteScanner.new()
|
||||
|
||||
while selected_item:
|
||||
var resource_path: String = selected_item.get_metadata(0)
|
||||
var file_type := file_system.get_file_type(resource_path)
|
||||
var is_dir := DirAccess.dir_exists_absolute(resource_path)
|
||||
if is_dir:
|
||||
selected_test_suites.append_array(suite_scaner.scan_directory(resource_path))
|
||||
elif is_dir or file_type == "GDScript" or file_type == "CSharpScript":
|
||||
# find a performant way to check if the selected item a testsuite
|
||||
var resource: Script = ResourceLoader.load(resource_path, "Script", ResourceLoader.CACHE_MODE_REUSE)
|
||||
if _menu_item.is_visible(resource):
|
||||
@warning_ignore("return_value_discarded")
|
||||
selected_test_suites.append(resource)
|
||||
selected_item = file_tree.get_next_selected(selected_item)
|
||||
return selected_test_suites
|
||||
|
||||
|
||||
func _file_tree() -> Tree:
|
||||
return GdObjects.find_nodes_by_class(EditorInterface.get_file_system_dock(), "Tree", true)[-1]
|
||||
|
||||
|
||||
func _menu_popup() -> PopupMenu:
|
||||
return GdObjects.find_nodes_by_class(EditorInterface.get_file_system_dock(), "PopupMenu")[-1]
|
||||
@@ -1 +0,0 @@
|
||||
uid://njdp45y5pnap
|
||||
@@ -1,47 +0,0 @@
|
||||
@tool
|
||||
extends EditorContextMenuPlugin
|
||||
|
||||
var _context_menus := Dictionary()
|
||||
var _command_handler := GdUnitCommandHandler.instance()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
var is_test_suite := func is_visible(script: Script, is_ts: bool) -> bool:
|
||||
if script == null:
|
||||
return false
|
||||
return GdUnitTestSuiteScanner.is_test_suite(script) == is_ts
|
||||
_context_menus[GdUnitContextMenuItem.MENU_ID.TEST_RUN] = GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_RUN, "Run Testsuites", "Play", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTSUITE))
|
||||
_context_menus[GdUnitContextMenuItem.MENU_ID.TEST_DEBUG] = GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_DEBUG, "Debug Testsuites", "PlayStart", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTSUITE_DEBUG))
|
||||
|
||||
# setup shortcuts
|
||||
for menu_item: GdUnitContextMenuItem in _context_menus.values():
|
||||
var cb := func call(files: Array) -> void:
|
||||
menu_item.execute([files])
|
||||
add_menu_shortcut(menu_item.shortcut(), cb)
|
||||
|
||||
|
||||
func _popup_menu(paths: PackedStringArray) -> void:
|
||||
var test_suites: Array[Script] = []
|
||||
var suite_scaner := GdUnitTestSuiteScanner.new()
|
||||
|
||||
for resource_path in paths:
|
||||
# directories and test-suites are valid to enable the menu
|
||||
if DirAccess.dir_exists_absolute(resource_path):
|
||||
test_suites.append_array(suite_scaner.scan_directory(resource_path))
|
||||
continue
|
||||
|
||||
var file_type := resource_path.get_extension()
|
||||
if file_type == "gd" or file_type == "cs":
|
||||
var script: Script = ResourceLoader.load(resource_path, "Script", ResourceLoader.CACHE_MODE_REUSE)
|
||||
if GdUnitTestSuiteScanner.is_test_suite(script):
|
||||
test_suites.append(script)
|
||||
|
||||
# no direcory or test-suites selected?
|
||||
if test_suites.is_empty():
|
||||
return
|
||||
|
||||
for menu_item: GdUnitContextMenuItem in _context_menus.values():
|
||||
@warning_ignore("unused_parameter")
|
||||
var cb := func call(files: Array) -> void:
|
||||
menu_item.execute([test_suites])
|
||||
add_context_menu_item(menu_item.name, cb, GdUnitUiTools.get_icon(menu_item.icon))
|
||||
@@ -1,69 +0,0 @@
|
||||
class_name GdUnitContextMenuItem
|
||||
|
||||
enum MENU_ID {
|
||||
UNDEFINED = 0,
|
||||
TEST_RUN = 1000,
|
||||
TEST_DEBUG = 1001,
|
||||
TEST_RERUN = 1002,
|
||||
CREATE_TEST = 1010,
|
||||
}
|
||||
|
||||
var id: MENU_ID = MENU_ID.UNDEFINED:
|
||||
set(value):
|
||||
id = value
|
||||
get:
|
||||
return id
|
||||
|
||||
var name: StringName:
|
||||
set(value):
|
||||
name = value
|
||||
get:
|
||||
return name
|
||||
|
||||
var command: GdUnitCommand:
|
||||
set(value):
|
||||
command = value
|
||||
get:
|
||||
return command
|
||||
|
||||
var visible: Callable:
|
||||
set(value):
|
||||
visible = value
|
||||
get:
|
||||
return visible
|
||||
|
||||
var icon: String:
|
||||
set(value):
|
||||
icon = value
|
||||
get:
|
||||
return icon
|
||||
|
||||
|
||||
func _init(p_id: MENU_ID, p_name: StringName, p_icon :String, p_is_visible: Callable, p_command: GdUnitCommand) -> void:
|
||||
assert(p_id != null, "(%s) missing parameter 'MENU_ID'" % p_name)
|
||||
assert(p_is_visible != null, "(%s) missing parameter 'GdUnitCommand'" % p_name)
|
||||
assert(p_command != null, "(%s) missing parameter 'GdUnitCommand'" % p_name)
|
||||
self.id = p_id
|
||||
self.name = p_name
|
||||
self.icon = p_icon
|
||||
self.command = p_command
|
||||
self.visible = p_is_visible
|
||||
|
||||
|
||||
func shortcut() -> Shortcut:
|
||||
return GdUnitCommandHandler.instance().get_shortcut(command.shortcut)
|
||||
|
||||
|
||||
func is_enabled(script: Script) -> bool:
|
||||
return command.is_enabled.call(script)
|
||||
|
||||
|
||||
func is_visible(script: Script) -> bool:
|
||||
return visible.call(script)
|
||||
|
||||
|
||||
func execute(arguments:=[]) -> void:
|
||||
if arguments.is_empty():
|
||||
command.runnable.call()
|
||||
else:
|
||||
command.runnable.callv(arguments)
|
||||
@@ -1 +0,0 @@
|
||||
uid://bla1g2ce6t53i
|
||||
@@ -1,81 +0,0 @@
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
var _context_menus := Dictionary()
|
||||
var _editor: ScriptEditor
|
||||
var _command_handler := GdUnitCommandHandler.instance()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
set_name("ScriptEditorContextMenuHandler")
|
||||
|
||||
var is_test_suite := func is_visible(script: Script, is_ts: bool) -> bool:
|
||||
return GdUnitTestSuiteScanner.is_test_suite(script) == is_ts
|
||||
var context_menus :Array[GdUnitContextMenuItem] = [
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_RUN, "Run Tests", "Play", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTCASE)),
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_DEBUG, "Debug Tests", "PlayStart", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTCASE_DEBUG)),
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.CREATE_TEST, "Create Test", "New", is_test_suite.bind(false), _command_handler.command(GdUnitCommandHandler.CMD_CREATE_TESTCASE))
|
||||
]
|
||||
for menu in context_menus:
|
||||
_context_menus[menu.id] = menu
|
||||
_editor = EditorInterface.get_script_editor()
|
||||
@warning_ignore("return_value_discarded")
|
||||
_editor.editor_script_changed.connect(on_script_changed)
|
||||
on_script_changed(active_script())
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.is_pressed():
|
||||
for action: GdUnitContextMenuItem in _context_menus.values():
|
||||
if action.shortcut().matches_event(event) and action.is_visible(active_script()):
|
||||
#if not has_editor_focus():
|
||||
# return
|
||||
action.execute()
|
||||
accept_event()
|
||||
return
|
||||
|
||||
|
||||
func has_editor_focus() -> bool:
|
||||
return (Engine.get_main_loop() as SceneTree).root.gui_get_focus_owner() == active_base_editor()
|
||||
|
||||
|
||||
func on_script_changed(script: Script) -> void:
|
||||
if script is Script:
|
||||
var popups: Array[Node] = GdObjects.find_nodes_by_class(active_editor(), "PopupMenu", true)
|
||||
for popup: PopupMenu in popups:
|
||||
if not popup.about_to_popup.is_connected(on_context_menu_show):
|
||||
popup.about_to_popup.connect(on_context_menu_show.bind(script, popup))
|
||||
if not popup.id_pressed.is_connected(on_context_menu_pressed):
|
||||
popup.id_pressed.connect(on_context_menu_pressed)
|
||||
|
||||
|
||||
func on_context_menu_show(script: Script, context_menu: PopupMenu) -> void:
|
||||
#prints("on_context_menu_show", _context_menus.keys(), context_menu, self)
|
||||
context_menu.add_separator()
|
||||
var current_index := context_menu.get_item_count()
|
||||
for menu_id: int in _context_menus.keys():
|
||||
var menu_item: GdUnitContextMenuItem = _context_menus[menu_id]
|
||||
if menu_item.is_visible(script):
|
||||
context_menu.add_item(menu_item.name, menu_id)
|
||||
context_menu.set_item_disabled(current_index, !menu_item.is_enabled(script))
|
||||
context_menu.set_item_shortcut(current_index, menu_item.shortcut(), true)
|
||||
current_index += 1
|
||||
|
||||
|
||||
func on_context_menu_pressed(id: int) -> void:
|
||||
if !_context_menus.has(id):
|
||||
return
|
||||
var menu_item: GdUnitContextMenuItem = _context_menus[id]
|
||||
menu_item.execute()
|
||||
|
||||
|
||||
func active_editor() -> ScriptEditorBase:
|
||||
return _editor.get_current_editor()
|
||||
|
||||
|
||||
func active_base_editor() -> TextEdit:
|
||||
return active_editor().get_base_editor()
|
||||
|
||||
|
||||
func active_script() -> Script:
|
||||
return _editor.get_current_script()
|
||||
@@ -1 +0,0 @@
|
||||
uid://cy5cblh8psm0a
|
||||
@@ -1,33 +0,0 @@
|
||||
@tool
|
||||
extends EditorContextMenuPlugin
|
||||
|
||||
var _context_menus := Dictionary()
|
||||
var _editor: ScriptEditor
|
||||
var _command_handler := GdUnitCommandHandler.instance()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
var is_test_suite := func is_visible(script: Script, is_ts: bool) -> bool:
|
||||
return GdUnitTestSuiteScanner.is_test_suite(script) == is_ts
|
||||
var context_menus :Array[GdUnitContextMenuItem] = [
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_RUN, "Run Tests", "Play", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTCASE)),
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.TEST_DEBUG, "Debug Tests", "PlayStart", is_test_suite.bind(true), _command_handler.command(GdUnitCommandHandler.CMD_RUN_TESTCASE_DEBUG)),
|
||||
GdUnitContextMenuItem.new(GdUnitContextMenuItem.MENU_ID.CREATE_TEST, "Create Test", "New", is_test_suite.bind(false), _command_handler.command(GdUnitCommandHandler.CMD_CREATE_TESTCASE))
|
||||
]
|
||||
for menu in context_menus:
|
||||
_context_menus[menu.id] = menu
|
||||
_editor = EditorInterface.get_script_editor()
|
||||
@warning_ignore("return_value_discarded")
|
||||
|
||||
|
||||
func _popup_menu(paths: PackedStringArray) -> void:
|
||||
var script_path := paths[0]
|
||||
var script: Script = ResourceLoader.load(script_path, "Script", ResourceLoader.CACHE_MODE_REUSE)
|
||||
|
||||
for menu_id: int in _context_menus.keys():
|
||||
var menu_item: GdUnitContextMenuItem = _context_menus[menu_id]
|
||||
if menu_item.is_visible(script):
|
||||
add_context_menu_item(menu_item.name,
|
||||
func call(files: Array) -> void:
|
||||
menu_item.execute([script_path]),
|
||||
GdUnitUiTools.get_icon(menu_item.icon))
|
||||
Reference in New Issue
Block a user