Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
402 changes: 0 additions & 402 deletions addons/gdUnit4/GdUnitRunner.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion addons/gdUnit4/bin/GdUnitCmdTool.gd.uid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uid://cvcdrd6j7raat
uid://b6ndm5kmgui1n
4 changes: 2 additions & 2 deletions addons/gdUnit4/bin/GdUnitCopyLog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func _process(_delta: float) -> bool:
func set_current_report_path() -> void:
# scan for latest report directory
var iteration := GdUnitFileAccess.find_last_path_index(
_report_root_path, GdUnitHtmlReport.REPORT_DIR_PREFIX
_report_root_path, GdUnitConstants.REPORT_DIR_PREFIX
)
_current_report_path = "%s/%s%d" % [_report_root_path, GdUnitHtmlReport.REPORT_DIR_PREFIX, iteration]
_current_report_path = "%s/%s%d" % [_report_root_path, GdUnitConstants.REPORT_DIR_PREFIX, iteration]


func set_report_directory(path: String) -> void:
Expand Down
2 changes: 1 addition & 1 deletion addons/gdUnit4/bin/GdUnitCopyLog.gd.uid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uid://bfimf41feem4m
uid://byyjqylc7tk4j
2 changes: 1 addition & 1 deletion addons/gdUnit4/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="gdUnit4"
description="Unit Testing Framework for Godot Scripts"
author="Mike Schulze"
version="5.0.5"
version="6.0.0"
script="plugin.gd"
36 changes: 23 additions & 13 deletions addons/gdUnit4/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
extends EditorPlugin

# We need to define manually the slot id's, to be downwards compatible
const CONTEXT_SLOT_FILESYSTEM = 1 # EditorContextMenuPlugin.CONTEXT_SLOT_FILESYSTEM
const CONTEXT_SLOT_SCRIPT_EDITOR = 2 # EditorContextMenuPlugin.CONTEXT_SLOT_SCRIPT_EDITOR
const CONTEXT_SLOT_FILESYSTEM: int = 1 # EditorContextMenuPlugin.CONTEXT_SLOT_FILESYSTEM
const CONTEXT_SLOT_SCRIPT_EDITOR: int = 2 # EditorContextMenuPlugin.CONTEXT_SLOT_SCRIPT_EDITOR

var _gd_inspector: Control
var _gd_console: Control
Expand All @@ -12,13 +12,22 @@ var _gd_scripteditor_context_menu: Variant


func _enter_tree() -> void:

var inferred_declaration: int = ProjectSettings.get_setting("debug/gdscript/warnings/inferred_declaration")
var exclude_addons: bool = ProjectSettings.get_setting("debug/gdscript/warnings/exclude_addons")
if !exclude_addons and inferred_declaration != 0:
printerr("GdUnit4: 'inferred_declaration' is set to Warning/Error!")
printerr("GdUnit4 is not 'inferred_declaration' save, you have to excluded addons (debug/gdscript/warnings/exclude_addons)")
printerr("Loading GdUnit4 Plugin failed.")
return

if check_running_in_test_env():
@warning_ignore("return_value_discarded")
GdUnitCSIMessageWriter.new().prints_warning("It was recognized that GdUnit4 is running in a test environment, therefore the GdUnit4 plugin will not be executed!")
return

if Engine.get_version_info().hex < 0x40300:
prints("The GdUnit4 plugin requires Godot version 4.3 or higher to run.")
if Engine.get_version_info().hex < 0x40500:
prints("This GdUnit4 plugin version '%s' requires Godot version '4.5' or higher to run." % GdUnit4Version.current())
return
GdUnitSettings.setup()
# Install the GdUnit Inspector
Expand All @@ -27,7 +36,7 @@ func _enter_tree() -> void:
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_UR, _gd_inspector)
# Install the GdUnit Console
_gd_console = (load("res://addons/gdUnit4/src/ui/GdUnitConsole.tscn") as PackedScene).instantiate()
var control := add_control_to_bottom_panel(_gd_console, "gdUnitConsole")
var control: Control = add_control_to_bottom_panel(_gd_console, "gdUnitConsole")
@warning_ignore("unsafe_method_access")
await _gd_console.setup_update_notification(control)
if GdUnit4CSharpApiLoader.is_api_loaded():
Expand All @@ -51,22 +60,22 @@ func _exit_tree() -> void:
if is_instance_valid(_gd_console):
remove_control_from_bottom_panel(_gd_console)
_gd_console.free()
var gdUnitTools := load("res://addons/gdUnit4/src/core/GdUnitTools.gd")
var gdUnitTools: GDScript = load("res://addons/gdUnit4/src/core/GdUnitTools.gd")
@warning_ignore("unsafe_method_access")
gdUnitTools.dispose_all(true)
prints("Unload GdUnit4 Plugin success")


func check_running_in_test_env() -> bool:
var args := OS.get_cmdline_args()
var args: PackedStringArray = OS.get_cmdline_args()
args.append_array(OS.get_cmdline_user_args())
return DisplayServer.get_name() == "headless" or args.has("--selftest") or args.has("--add") or args.has("-a") or args.has("--quit-after") or args.has("--import")


func _add_context_menus() -> void:
if Engine.get_version_info().hex >= 0x40400:
# With Godot 4.4 we have to use the 'add_context_menu_plugin' to register editor context menus
_gd_filesystem_context_menu = _create_context_menu("res://addons/gdUnit4/src/ui/menu/EditorFileSystemContextMenuHandlerV44.gdx")
_gd_filesystem_context_menu = _preload_gdx_script("res://addons/gdUnit4/src/ui/menu/EditorFileSystemContextMenuHandlerV44.gdx")
call_deferred("add_context_menu_plugin", CONTEXT_SLOT_FILESYSTEM, _gd_filesystem_context_menu)
# the CONTEXT_SLOT_SCRIPT_EDITOR is adding to the script panel instead of script editor see https://github.com/godotengine/godot/pull/100556
#_gd_scripteditor_context_menu = _preload("res://addons/gdUnit4/src/ui/menu/ScriptEditorContextMenuHandlerV44.gdx")
Expand All @@ -86,13 +95,14 @@ func _remove_context_menus() -> void:
call_deferred("remove_context_menu_plugin", _gd_scripteditor_context_menu)


func _create_context_menu(script_path: String) -> Variant:
var context_menu_script := GDScript.new()
context_menu_script.source_code = FileAccess.get_file_as_string(script_path)
var err := context_menu_script.reload(true)
func _preload_gdx_script(script_path: String) -> Variant:
var script: GDScript = GDScript.new()
script.source_code = GdUnitFileAccess.resource_as_string(script_path)
script.take_over_path(script_path)
var err :Error = script.reload()
if err != OK:
push_error("Can't create context menu %s, error: %s" % [script_path, error_string(err)])
return context_menu_script.new()
return script.new()


func _on_resource_saved(resource: Resource) -> void:
Expand Down
2 changes: 1 addition & 1 deletion addons/gdUnit4/plugin.gd.uid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uid://b6jqtcf22jkil
uid://bofr1yjhccui
28 changes: 14 additions & 14 deletions addons/gdUnit4/runtest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
setlocal enabledelayedexpansion

:: Initialize variables
set "godot_bin="
set "godot_binary="
set "filtered_args="

:: Process all arguments
set "i=0"
:parse_args
if "%~1"=="" goto end_parse_args

if "%~1"=="--godot_bin" (
set "godot_bin=%~2"
if "%~1"=="--godot_binary" (
set "godot_binary=%~2"
shift
shift
) else (
Expand All @@ -21,28 +21,28 @@ if "%~1"=="--godot_bin" (
goto parse_args
:end_parse_args

:: If --godot_bin wasn't provided, fallback to environment variable
if "!godot_bin!"=="" (
set "godot_bin=%GODOT_BIN%"
:: If --godot_binary wasn't provided, fallback to environment variable
if "!godot_binary!"=="" (
set "godot_binary=%GODOT_BIN%"
)

:: Check if we have a godot_bin value from any source
if "!godot_bin!"=="" (
:: Check if we have a godot_binary value from any source
if "!godot_binary!"=="" (
echo Godot binary path is not specified.
echo Please either:
echo - Set the environment variable: set GODOT_BIN=C:\path\to\godot.exe
echo - Or use the --godot_bin argument: --godot_bin C:\path\to\godot.exe
echo - Or use the --godot_binary argument: --godot_binary C:\path\to\godot.exe
exit /b 1
)

:: Check if the Godot binary exists
if not exist "!godot_bin!" (
echo Error: The specified Godot binary '!godot_bin!' does not exist.
if not exist "!godot_binary!" (
echo Error: The specified Godot binary '!godot_binary!' does not exist.
exit /b 1
)

:: Get Godot version and check if it's a mono build
for /f "tokens=*" %%i in ('"!godot_bin!" --version') do set GODOT_VERSION=%%i
for /f "tokens=*" %%i in ('"!godot_binary!" --version') do set GODOT_VERSION=%%i
echo !GODOT_VERSION! | findstr /I "mono" >nul
if !errorlevel! equ 0 (
echo Godot .NET detected
Expand All @@ -52,11 +52,11 @@ if !errorlevel! equ 0 (
)

:: Run the tests with the filtered arguments
"!godot_bin!" --path . -s -d res://addons/gdUnit4/bin/GdUnitCmdTool.gd !filtered_args!
"!godot_binary!" --path . -s -d res://addons/gdUnit4/bin/GdUnitCmdTool.gd !filtered_args!
set exit_code=%ERRORLEVEL%
echo Run tests ends with %exit_code%

:: Run the copy log command
"!godot_bin!" --headless --path . --quiet -s res://addons/gdUnit4/bin/GdUnitCopyLog.gd !filtered_args! > nul
"!godot_binary!" --headless --path . --quiet -s res://addons/gdUnit4/bin/GdUnitCopyLog.gd !filtered_args! > nul
set exit_code2=%ERRORLEVEL%
exit /b %exit_code%
34 changes: 17 additions & 17 deletions addons/gdUnit4/runtest.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
#!/bin/bash

# Check for command-line argument
godot_bin=""
godot_binary=""
filtered_args=""

# Process all arguments with a more compatible approach
while [ $# -gt 0 ]; do
if [ "$1" = "--godot_bin" ] && [ $# -gt 1 ]; then
if [ "$1" = "--godot_binary" ] && [ $# -gt 1 ]; then
# Get the next argument as the value
godot_bin="$2"
godot_binary="$2"
shift 2
else
# Keep non-godot_bin arguments for passing to Godot
# Keep non-godot_binary arguments for passing to Godot
filtered_args="$filtered_args $1"
shift
fi
done

# If --godot_bin wasn't provided, fallback to environment variable
if [ -z "$godot_bin" ]; then
godot_bin="$GODOT_BIN"
# If --godot_binary wasn't provided, fallback to environment variable
if [ -z "$godot_binary" ]; then
godot_binary="$GODOT_BIN"
fi

# Check if we have a godot_bin value from any source
if [ -z "$godot_bin" ]; then
# Check if we have a godot_binary value from any source
if [ -z "$godot_binary" ]; then
echo "Godot binary path is not specified."
echo "Please either:"
echo " - Set the environment variable: export GODOT_BIN=/path/to/godot"
echo " - Or use the --godot_bin argument: --godot_bin /path/to/godot"
echo " - Or use the --godot_binary argument: --godot_binary /path/to/godot"
exit 1
fi

# Check if the Godot binary exists and is executable
if [ ! -f "$godot_bin" ]; then
echo "Error: The specified Godot binary '$godot_bin' does not exist."
if [ ! -f "$godot_binary" ]; then
echo "Error: The specified Godot binary '$godot_binary' does not exist."
exit 1
fi

if [ ! -x "$godot_bin" ]; then
echo "Error: The specified Godot binary '$godot_bin' is not executable."
if [ ! -x "$godot_binary" ]; then
echo "Error: The specified Godot binary '$godot_binary' is not executable."
exit 1
fi

# Get Godot version and check if it's a .NET build
GODOT_VERSION=$("$godot_bin" --version)
GODOT_VERSION=$("$godot_binary" --version)
if echo "$GODOT_VERSION" | grep -i "mono" > /dev/null; then
echo "Godot .NET detected"
echo "Compiling c# classes ... Please Wait"
Expand All @@ -52,11 +52,11 @@ if echo "$GODOT_VERSION" | grep -i "mono" > /dev/null; then
fi

# Run the tests with the filtered arguments
"$godot_bin" --path . -s -d res://addons/gdUnit4/bin/GdUnitCmdTool.gd $filtered_args
"$godot_binary" --path . -s -d res://addons/gdUnit4/bin/GdUnitCmdTool.gd $filtered_args
exit_code=$?
echo "Run tests ends with $exit_code"

# Run the copy log command
"$godot_bin" --headless --path . --quiet -s res://addons/gdUnit4/bin/GdUnitCopyLog.gd $filtered_args > /dev/null
"$godot_binary" --headless --path . --quiet -s res://addons/gdUnit4/bin/GdUnitCopyLog.gd $filtered_args > /dev/null
exit_code2=$?
exit $exit_code
2 changes: 1 addition & 1 deletion addons/gdUnit4/src/Comparator.gd.uid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uid://crwb16mgg0hhi
uid://ck7j1jr7s6y46
2 changes: 1 addition & 1 deletion addons/gdUnit4/src/Fuzzers.gd.uid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uid://bt0u6wsl4ad1x
uid://dxq47rabgbsc1
Loading
Loading