summaryrefslogtreecommitdiffstats
path: root/misc/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'misc/scripts')
-rwxr-xr-xmisc/scripts/validate_extension_api.sh33
1 files changed, 28 insertions, 5 deletions
diff --git a/misc/scripts/validate_extension_api.sh b/misc/scripts/validate_extension_api.sh
index f2f7c28e70..75f03a7086 100755
--- a/misc/scripts/validate_extension_api.sh
+++ b/misc/scripts/validate_extension_api.sh
@@ -10,7 +10,12 @@ if [ $# != 1 ]; then
echo "Usage: @0 <path-to-godot-executable>"
fi
+api_validation_dir="$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/"
+
has_problems=0
+warn_extra=0
+reference_tag=""
+expected_errors=""
make_annotation()
{
@@ -27,26 +32,44 @@ make_annotation()
fi
}
+get_expected_output()
+{
+ local parts=()
+ IFS='_' read -ra parts <<< "$(basename -s .expected "$1")"
+
+ if [[ "${#parts[@]}" == "2" ]]; then
+ cat "$1" >> "$expected_errors"
+ get_expected_output "$(find "$api_validation_dir" -name "${parts[1]}*.expected")"
+ reference_tag="${parts[0]}"
+ warn_extra=0
+ else
+ cat "$1" >> "$expected_errors"
+ reference_tag="${parts[0]}"
+ warn_extra=1
+ fi
+}
+
while read -r file; do
reference_file="$(mktemp)"
validate="$(mktemp)"
validation_output="$(mktemp)"
allowed_errors="$(mktemp)"
+ expected_errors="$(mktemp)"
+ get_expected_output "$file"
# Download the reference extension_api.json
- reference_tag="$(basename -s .expected "$file")"
wget -qcO "$reference_file" "https://raw.githubusercontent.com/godotengine/godot-cpp/godot-$reference_tag/gdextension/extension_api.json"
# Validate the current API against the reference
"$1" --headless --validate-extension-api "$reference_file" 2>&1 | tee "$validate" | awk '!/^Validate extension JSON:/' - || true
# Collect the expected and actual validation errors
awk '/^Validate extension JSON:/' - < "$validate" | sort > "$validation_output"
- awk '/^Validate extension JSON:/' - < "$file" | sort > "$allowed_errors"
+ awk '/^Validate extension JSON:/' - < "$expected_errors" | sort > "$allowed_errors"
# Differences between the expected and actual errors
new_validation_error="$(comm -23 "$validation_output" "$allowed_errors")"
obsolete_validation_error="$(comm -13 "$validation_output" "$allowed_errors")"
- if [ -n "$obsolete_validation_error" ]; then
+ if [ -n "$obsolete_validation_error" ] && [ "$warn_extra" = "1" ]; then
make_annotation "The following validation errors no longer occur (compared to $reference_tag):" "$obsolete_validation_error" warning "$file"
fi
if [ -n "$new_validation_error" ]; then
@@ -54,7 +77,7 @@ while read -r file; do
has_problems=1
fi
- rm -f "$reference_file" "$validate" "$validation_output" "$allowed_errors"
-done <<< "$(find "$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/" -name "*.expected")"
+ rm -f "$reference_file" "$validate" "$validation_output" "$allowed_errors" "$expected_errors"
+done <<< "$(find "$api_validation_dir" -name "*.expected")"
exit $has_problems