summaryrefslogtreecommitdiff
path: root/addons/gdUnit4/runtest.sh
diff options
context:
space:
mode:
Diffstat (limited to 'addons/gdUnit4/runtest.sh')
-rwxr-xr-xaddons/gdUnit4/runtest.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/addons/gdUnit4/runtest.sh b/addons/gdUnit4/runtest.sh
new file mode 100755
index 0000000..f0269ef
--- /dev/null
+++ b/addons/gdUnit4/runtest.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Check for command-line argument
+godot_binary=""
+filtered_args=""
+
+# Process all arguments with a more compatible approach
+while [ $# -gt 0 ]; do
+ if [ "$1" = "--godot_binary" ] && [ $# -gt 1 ]; then
+ # Get the next argument as the value
+ godot_binary="$2"
+ shift 2
+ else
+ # Keep non-godot_binary arguments for passing to Godot
+ filtered_args="$filtered_args $1"
+ shift
+ fi
+done
+
+# 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_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_binary argument: --godot_binary /path/to/godot"
+ exit 1
+fi
+
+# Check if the Godot binary exists and is executable
+if [ ! -f "$godot_binary" ]; then
+ echo "Error: The specified Godot binary '$godot_binary' does not exist."
+ exit 1
+fi
+
+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_binary" --version)
+if echo "$GODOT_VERSION" | grep -i "mono" > /dev/null; then
+ echo "Godot .NET detected"
+ echo "Compiling c# classes ... Please Wait"
+ dotnet build --debug
+ echo "done $?"
+fi
+
+# Run the tests with the filtered arguments
+"$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_binary" --headless --path . --quiet -s res://addons/gdUnit4/bin/GdUnitCopyLog.gd $filtered_args > /dev/null
+exit_code2=$?
+exit $exit_code