diff options
| author | Manuel Stoeckl <code@mstoeckl.com> | 2019-04-13 18:33:06 -0400 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2019-05-02 17:42:59 +0000 |
| commit | 6db761d16229084e576848967402d30b656e2dbf (patch) | |
| tree | 50cc136688ac2fe8475171c307f0c522a7e3a847 /tests/scanner-test.sh | |
| parent | scanner: error when element names will not compile (diff) | |
| download | wayland-6db761d16229084e576848967402d30b656e2dbf.tar wayland-6db761d16229084e576848967402d30b656e2dbf.tar.gz wayland-6db761d16229084e576848967402d30b656e2dbf.tar.bz2 wayland-6db761d16229084e576848967402d30b656e2dbf.tar.lz wayland-6db761d16229084e576848967402d30b656e2dbf.tar.xz wayland-6db761d16229084e576848967402d30b656e2dbf.tar.zst wayland-6db761d16229084e576848967402d30b656e2dbf.zip | |
tests: Verify that wayland_scanner can catch bad identifiers
The test runs wayland_scanner on a set of XML protocol files which
have malformed element names, and confirms that an error is produced
and indicates the correct line.
Copyright notifications are not included in the test files, as
they are not code; of course, the project license still applies.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
Diffstat (limited to 'tests/scanner-test.sh')
| -rwxr-xr-x | tests/scanner-test.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/scanner-test.sh b/tests/scanner-test.sh index ff25089..35ba047 100755 --- a/tests/scanner-test.sh +++ b/tests/scanner-test.sh @@ -36,6 +36,20 @@ generate_and_compare() { fail "$2 -> $3" } +verify_error() { + echo + echo "Checking that reading $1 gives an error on line $3" + + [ -f "$TEST_DATA_DIR/$1" ] || hard_fail "$1 not present" + + # Confirm failure error code + "$WAYLAND_SCANNER" server-header < "$TEST_DATA_DIR/$1" >/dev/null 2>"$TEST_OUTPUT_DIR/$2" && \ + fail "$1 return code check" + + # Verify that an error is produced at the correct line + grep -q "<stdin>:$3: error:" "$TEST_OUTPUT_DIR/$2" && echo "$1 PASS" || fail "$1 line number check" +} + generate_and_compare "code" "example.xml" "example-code.c" generate_and_compare "client-header" "example.xml" "example-client.h" generate_and_compare "server-header" "example.xml" "example-server.h" @@ -52,4 +66,13 @@ generate_and_compare "-c server-header" "small.xml" "small-server-core.h" generate_and_compare "code" "small.xml" "small-code.c" generate_and_compare "public-code" "small.xml" "small-code.c" generate_and_compare "private-code" "small.xml" "small-private-code.c" + +verify_error "bad-identifier-arg.xml" "bad-identifier-arg.log" 7 +verify_error "bad-identifier-entry.xml" "bad-identifier-entry.log" 8 +verify_error "bad-identifier-enum.xml" "bad-identifier-enum.log" 6 +verify_error "bad-identifier-event.xml" "bad-identifier-event.log" 6 +verify_error "bad-identifier-interface.xml" "bad-identifier-interface.log" 3 +verify_error "bad-identifier-protocol.xml" "bad-identifier-protocol.log" 2 +verify_error "bad-identifier-request.xml" "bad-identifier-request.log" 6 + exit $RETCODE |
