testsuite: Add tests for gtk4-builder-tool validate

This commit is contained in:
Matthias Clasen 2020-11-01 14:47:02 -05:00
parent 44b36b6321
commit 403a70ca89
14 changed files with 70 additions and 1 deletions

View File

@ -5,7 +5,7 @@ bash = find_program('bash', required : false)
if bash.found()
test_env = environment()
foreach t : ['simplify', 'simplify-3to4', 'settings']
foreach t : ['simplify', 'simplify-3to4', 'validate', 'settings']
if get_option('install-tests')
configure_file(output: t,
input: '@0@.in'.format(t),
@ -44,4 +44,5 @@ if get_option('install-tests')
install_subdir('simplify-data', install_dir: testexecdir)
install_subdir('simplify-data-3to4', install_dir: testexecdir)
install_subdir('validate-data', install_dir: testexecdir)
endif

View File

@ -0,0 +1 @@
invalid1.ui:3:1 <child> is not a valid tag here

View File

@ -0,0 +1,5 @@
<interface>
<child>
<object class="GtkLabel"/>
</child>
</interface>

View File

@ -0,0 +1 @@
invalid2.ui:4:1 <object> is not a valid tag here

View File

@ -0,0 +1,6 @@
<interface>
<object class="GtkBox">
<object class="GtkButton">
</object>
</object>
</interface>

View File

@ -0,0 +1 @@
invalid3.ui:3:1 <object> requires attribute 'class'

View File

@ -0,0 +1,4 @@
<interface>
<object>
</object>
</interface>

View File

@ -0,0 +1 @@
Gtk-WARNING: Failed to find accessible property “text”: Could not parse enum: 'text'

View File

@ -0,0 +1,7 @@
<interface>
<object class="GtkBox">
<accessibility>
<property name="text">Download</property>
</accessibility>
</object>
</interface>

View File

@ -0,0 +1,3 @@
<interface>
<object class="GtkLabel"/>
</interface>

View File

@ -0,0 +1,4 @@
<interface>
<template class="GtkEmojiChooser" parent="GtkPopover">
</template>
</interface>

35
testsuite/tools/validate.in Executable file
View File

@ -0,0 +1,35 @@
#! /bin/bash
GTK_BUILDER_TOOL=${GTK_BUILDER_TOOL:-gtk4-builder-tool}
TEST_DATA_DIR=${G_TEST_SRCDIR:-.}/validate-data
TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
shopt -s nullglob
TESTS=( "$TEST_DATA_DIR"/*.ui )
echo "1..${#TESTS[*]}"
I=1
for t in ${TESTS[*]}; do
name=$(basename $t .ui)
expected="$TEST_DATA_DIR/$name.expected"
result="$TEST_RESULT_DIR/$name.out"
diff="$TEST_RESULT_DIR/$name.diff"
ref="$TEST_RESULT_DIR/$name.ref"
cd $TEST_DATA_DIR
$GTK_BUILDER_TOOL validate $(basename $t) 2>$result
cd $OLDPWD
if diff -u "$expected" "$result" > "$diff"; then
echo "ok $I $name"
rm "$diff"
else
echo "not ok $I $name"
cp "$expected" "$ref"
fi
I=$((I+1))
done