Files
llgo/compiler/_lldb/runtest.sh

70 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
2024-09-21 10:03:49 +08:00
# Source common functions and variables
2024-09-21 21:10:06 +08:00
# shellcheck source=./_lldb/common.sh
2024-09-24 22:08:15 +08:00
# shellcheck disable=SC1091
source "$(dirname "$0")/common.sh" || exit 1
2024-09-21 10:03:49 +08:00
# Parse command-line arguments
package_path="$DEFAULT_PACKAGE_PATH"
verbose=False
interactive=False
plugin_path=None
while [[ $# -gt 0 ]]; do
case $1 in
-v|--verbose)
verbose=True
shift
;;
-i|--interactive)
interactive=True
shift
;;
-p|--plugin)
plugin_path="\"$2\""
shift 2
;;
*)
package_path="$1"
shift
;;
esac
done
# Build the project
2024-09-24 22:08:15 +08:00
build_project "$package_path" || exit 1
2024-09-21 10:03:49 +08:00
# Set up the result file path
result_file="/tmp/lldb_exit_code"
2024-09-30 16:35:12 +08:00
# Prepare LLDB commands
lldb_commands=(
2025-01-08 21:47:22 +08:00
"command script import ../llgo_plugin.py"
"command script import ../test.py"
"script test.run_tests_with_result('./debug.out', ['main.go'], $verbose, $interactive, $plugin_path, '$result_file')"
2024-09-30 16:35:12 +08:00
"quit"
)
2025-01-08 21:47:22 +08:00
# Run LLDB with prepared commands
2024-09-30 16:35:12 +08:00
lldb_command_string=""
for cmd in "${lldb_commands[@]}"; do
lldb_command_string+=" -o \"$cmd\""
done
2025-01-08 21:47:22 +08:00
cd "$package_path"
# Run LLDB with the test script
2024-09-30 16:35:12 +08:00
eval "$LLDB_PATH $lldb_command_string"
# Read the exit code from the result file
if [ -f "$result_file" ]; then
exit_code=$(cat "$result_file")
rm "$result_file"
exit "$exit_code"
else
echo "Error: Could not find exit code file"
exit 1
2024-09-21 10:03:49 +08:00
fi