[gtk/simplify-tests: 2/5] testsuite: Add tests for ui file rewriting



commit 82eee65334c124ffcc1094aca49f85e82fd0d5c7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 5 15:23:59 2019 +0000

    testsuite: Add tests for ui file rewriting
    
    Add a test script that runs
    gtk4-builder-tool simplify --3to4.
    No actual tests yet.

 testsuite/tools/meson.build      |  3 ++-
 testsuite/tools/simplify-3to4.in | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/testsuite/tools/meson.build b/testsuite/tools/meson.build
index 74a79901a9..4e6a605056 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', 'settings']
+  foreach t : ['simplify', 'simplify-3to4', 'settings']
     if get_option('install-tests')
       configure_file(output: t,
                      input: '@0@.in'.format(t),
@@ -44,4 +44,5 @@ if get_option('install-tests')
   endforeach
 
   install_subdir('simplify-data', install_dir: testexecdir)
+  install_subdir('simplify-data-3to4', install_dir: testexecdir)
 endif
diff --git a/testsuite/tools/simplify-3to4.in b/testsuite/tools/simplify-3to4.in
new file mode 100755
index 0000000000..3c0a515762
--- /dev/null
+++ b/testsuite/tools/simplify-3to4.in
@@ -0,0 +1,31 @@
+#! /bin/bash
+
+GTK_BUILDER_TOOL=${GTK_BUILDER_TOOL:-gtk-builder-tool}
+TEST_DATA_DIR=${TEST_DATA_DIR:-./simplify-data-3to4}
+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"
+
+  $GTK_BUILDER_TOOL simplify --3to4 $t 2>/dev/null >$result
+
+  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]