mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
build: add a gen-scanner-test target
This adds a command to re-generate the test data. This needs to be done when either an XML source file or the scanner's output is changed. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
6626d4d98c
commit
0e139cfbc7
3 changed files with 38 additions and 6 deletions
3
tests/data/README.md
Normal file
3
tests/data/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
To re-generate the test data, run:
|
||||
|
||||
ninja -C build/ gen-scanner-test
|
||||
|
|
@ -75,15 +75,23 @@ endif
|
|||
sed_path = find_program('sed').full_path()
|
||||
|
||||
if get_option('scanner')
|
||||
scanner_test_env = [
|
||||
'TEST_DATA_DIR=@0@/data'.format(meson.current_source_dir()),
|
||||
'TEST_OUTPUT_DIR=@0@/output'.format(meson.current_build_dir()),
|
||||
'SED=@0@'.format(sed_path),
|
||||
'WAYLAND_SCANNER=@0@'.format(wayland_scanner.full_path()),
|
||||
]
|
||||
|
||||
test(
|
||||
'scanner-test',
|
||||
find_program('scanner-test.sh'),
|
||||
env: [
|
||||
'TEST_DATA_DIR=@0@/data'.format(meson.current_source_dir()),
|
||||
'TEST_OUTPUT_DIR=@0@/output'.format(meson.current_build_dir()),
|
||||
'SED=@0@'.format(sed_path),
|
||||
'WAYLAND_SCANNER=@0@'.format(wayland_scanner.full_path()),
|
||||
],
|
||||
env: scanner_test_env,
|
||||
)
|
||||
|
||||
run_target(
|
||||
'gen-scanner-test',
|
||||
command: find_program('scanner-test-gen.sh'),
|
||||
env: scanner_test_env,
|
||||
)
|
||||
endif
|
||||
|
||||
|
|
|
|||
21
tests/scanner-test-gen.sh
Executable file
21
tests/scanner-test-gen.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh -eu
|
||||
|
||||
generate() {
|
||||
"$WAYLAND_SCANNER" $1 < "$TEST_DATA_DIR/$2" > "$TEST_DATA_DIR/$3"
|
||||
"$SED" -i -e 's/Generated by wayland-scanner [0-9.]*/SCANNER TEST/' \
|
||||
"$TEST_DATA_DIR/$3"
|
||||
}
|
||||
|
||||
generate "code" "example.xml" "example-code.c"
|
||||
generate "client-header" "example.xml" "example-client.h"
|
||||
generate "server-header" "example.xml" "example-server.h"
|
||||
|
||||
generate "code" "small.xml" "small-code.c"
|
||||
generate "client-header" "small.xml" "small-client.h"
|
||||
generate "server-header" "small.xml" "small-server.h"
|
||||
|
||||
generate "-c code" "small.xml" "small-code-core.c"
|
||||
generate "-c client-header" "small.xml" "small-client-core.h"
|
||||
generate "-c server-header" "small.xml" "small-server-core.h"
|
||||
|
||||
generate "private-code" "small.xml" "small-private-code.c"
|
||||
Loading…
Add table
Add a link
Reference in a new issue