[gtk/matthiasc/for-master] testsuite: Add tests for gtk4-builder-tool validate
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] testsuite: Add tests for gtk4-builder-tool validate
- Date: Sun, 1 Nov 2020 19:55:07 +0000 (UTC)
commit ae3e2019eca9bfba8cd7d62491ed936971bad5d1
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Nov 1 14:47:02 2020 -0500
testsuite: Add tests for gtk4-builder-tool validate
testsuite/tools/meson.build | 3 ++-
testsuite/tools/validate-data/invalid1.expected | 1 +
testsuite/tools/validate-data/invalid1.ui | 5 ++++
testsuite/tools/validate-data/invalid2.expected | 1 +
testsuite/tools/validate-data/invalid2.ui | 6 +++++
testsuite/tools/validate-data/invalid3.expected | 1 +
testsuite/tools/validate-data/invalid3.ui | 4 +++
testsuite/tools/validate-data/invalid4.expected | 2 ++
testsuite/tools/validate-data/invalid4.ui | 7 +++++
testsuite/tools/validate-data/valid1.expected | 0
testsuite/tools/validate-data/valid1.ui | 3 +++
testsuite/tools/validate.in | 35 +++++++++++++++++++++++++
12 files changed, 67 insertions(+), 1 deletion(-)
---
diff --git a/testsuite/tools/meson.build b/testsuite/tools/meson.build
index 1369ccfedc..54b9312e7a 100644
--- a/testsuite/tools/meson.build
+++ b/testsuite/tools/meson.build
@@ -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
diff --git a/testsuite/tools/validate-data/invalid1.expected b/testsuite/tools/validate-data/invalid1.expected
new file mode 100644
index 0000000000..77c70ce0dc
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid1.expected
@@ -0,0 +1 @@
+invalid1.ui:3:1 <child> is not a valid tag here
diff --git a/testsuite/tools/validate-data/invalid1.ui b/testsuite/tools/validate-data/invalid1.ui
new file mode 100644
index 0000000000..0b969c34d8
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid1.ui
@@ -0,0 +1,5 @@
+<interface>
+ <child>
+ <object class="GtkLabel"/>
+ </child>
+</interface>
diff --git a/testsuite/tools/validate-data/invalid2.expected b/testsuite/tools/validate-data/invalid2.expected
new file mode 100644
index 0000000000..c05e26fece
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid2.expected
@@ -0,0 +1 @@
+invalid2.ui:4:1 <object> is not a valid tag here
diff --git a/testsuite/tools/validate-data/invalid2.ui b/testsuite/tools/validate-data/invalid2.ui
new file mode 100644
index 0000000000..887b3bcd4b
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid2.ui
@@ -0,0 +1,6 @@
+<interface>
+ <object class="GtkBox">
+ <object class="GtkButton">
+ </object>
+ </object>
+</interface>
diff --git a/testsuite/tools/validate-data/invalid3.expected b/testsuite/tools/validate-data/invalid3.expected
new file mode 100644
index 0000000000..824ce933e6
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid3.expected
@@ -0,0 +1 @@
+invalid3.ui:3:1 <object> requires attribute 'class'
diff --git a/testsuite/tools/validate-data/invalid3.ui b/testsuite/tools/validate-data/invalid3.ui
new file mode 100644
index 0000000000..9deb45b268
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid3.ui
@@ -0,0 +1,4 @@
+<interface>
+ <object>
+ </object>
+</interface>
diff --git a/testsuite/tools/validate-data/invalid4.expected b/testsuite/tools/validate-data/invalid4.expected
new file mode 100644
index 0000000000..ad77b57771
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid4.expected
@@ -0,0 +1,2 @@
+
+(gtk-builder-tool:2094810): Gtk-WARNING **: 14:53:37.697: Failed to find accessible property “text”: Could
not parse enum: 'text'
diff --git a/testsuite/tools/validate-data/invalid4.ui b/testsuite/tools/validate-data/invalid4.ui
new file mode 100644
index 0000000000..21e3248b73
--- /dev/null
+++ b/testsuite/tools/validate-data/invalid4.ui
@@ -0,0 +1,7 @@
+<interface>
+ <object class="GtkBox">
+ <accessibility>
+ <property name="text">Download</property>
+ </accessibility>
+ </object>
+</interface>
diff --git a/testsuite/tools/validate-data/valid1.expected b/testsuite/tools/validate-data/valid1.expected
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/testsuite/tools/validate-data/valid1.ui b/testsuite/tools/validate-data/valid1.ui
new file mode 100644
index 0000000000..2a9a3f594c
--- /dev/null
+++ b/testsuite/tools/validate-data/valid1.ui
@@ -0,0 +1,3 @@
+<interface>
+ <object class="GtkLabel"/>
+</interface>
diff --git a/testsuite/tools/validate.in b/testsuite/tools/validate.in
new file mode 100755
index 0000000000..82de80e31d
--- /dev/null
+++ b/testsuite/tools/validate.in
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]