Skip to content

Commit 62aa391

Browse files
committed
Add CI checks for required error messages.
1 parent c4a37f2 commit 62aa391

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

.github/composite/godot/action.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,27 @@ runs:
6262
cd test;
6363
mkdir -p ./project/lib;
6464
cp ../target/debug/libgdnative_test.so ./project/lib/;
65-
${GODOT_BIN} --path ./project/ > >(tee "${{ runner.temp }}/stdout.log");
66-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
65+
${GODOT_BIN} --path ./project/ > >(tee "${{ runner.temp }}/stdout.log") 2> >(tee "${{ runner.temp }}/stderr.log");
66+
bash ../tools/check-test-output.sh "${{ runner.temp }}/stdout.log" "${{ runner.temp }}/stderr.log";
67+
if [[ $? -ne 0 ]]; then
6768
exit 1;
6869
fi;
69-
${GODOT_BIN} -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log");
70-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
70+
${GODOT_BIN} -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log") 2> >(tee "${{ runner.temp }}/stderr.log");
71+
bash ../tools/check-test-output.sh "${{ runner.temp }}/stdout.log" "${{ runner.temp }}/stderr.log";
72+
if [[ $? -ne 0 ]]; then
7173
exit 1;
7274
fi;
7375
cargo build --features type-tag-fallback ${{ inputs.rust_extra_args }}
7476
mkdir -p ./project/lib;
7577
cp ../target/debug/libgdnative_test.so ./project/lib/;
76-
${GODOT_BIN} --path ./project/ > >(tee "${{ runner.temp }}/stdout.log");
77-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
78+
${GODOT_BIN} --path ./project/ > >(tee "${{ runner.temp }}/stdout.log") 2> >(tee "${{ runner.temp }}/stderr.log");
79+
bash ../tools/check-test-output.sh "${{ runner.temp }}/stdout.log" "${{ runner.temp }}/stderr.log";
80+
if [[ $? -ne 0 ]]; then
7881
exit 1;
7982
fi;
80-
${GODOT_BIN} -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log");
81-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
83+
${GODOT_BIN} -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log") 2> >(tee "${{ runner.temp }}/stderr.log");
84+
bash ../tools/check-test-output.sh "${{ runner.temp }}/stdout.log" "${{ runner.temp }}/stderr.log";
85+
if [[ $? -ne 0 ]]; then
8286
exit 1;
8387
fi;
8488
shell: bash

tools/check-test-output.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/bash
2+
3+
# Look for required error messages and leaked instances in the outputs of the integration test
4+
# Usage: check-test-output.sh stdout.log stderr.log
5+
6+
FAIL=0
7+
8+
while read COUNT && read PATTERN; do
9+
ACTUAL="$(grep -c "$PATTERN" "$2")"
10+
if [[ $? -ne 0 ]]; then
11+
ACTUAL=0
12+
fi
13+
if [[ COUNT -ne ACTUAL ]]; then
14+
FAIL=1
15+
echo "Found ${ACTUAL} out of ${COUNT} expected instances of message ${PATTERN}"
16+
fi
17+
done < <(sed -e 's/^#.*//' -e '/^$/d' -e 's/^\([0-9]\+\),/\1\n/' -e 's/\\/\\\\/g' "${BASH_SOURCE%/*}/required-errors.txt")
18+
19+
if grep -q "Leaked instance" "$1"; then
20+
echo Leaked instances found.
21+
FAIL=1
22+
fi
23+
24+
exit $FAIL

tools/required-errors.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Error messages that must be found in the output of the integration test, in the format:
2+
# <copies>,<grep pattern>
3+
4+
# Empty lines or lines that start with '#' are ignored.
5+
6+
# test_array_debug
7+
4,thread '[^']*' panicked at 'Index 3 out of bounds (len 3)'
8+
9+
# test_derive_nativeclass_property_with_only_getter
10+
1,ERROR: \(<unset>: \)\?property size on native class MyVec does not have a setter
11+
12+
# _test_optional_args
13+
1,ERROR: \(OptionalArgs :: opt_sum: \)\?missing non-optional parameter `b` (#1)
14+
1,ERROR: \(OptionalArgs :: opt_sum: \)\?an excessive argument is given: I64(6)

0 commit comments

Comments
 (0)