[gtk+] Install tools tests



commit f8f94ab329b1deb8d315cdb8689203c7bb4d1906
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Oct 18 10:41:57 2017 +0800

    Install tools tests
    
    At the same time, update the expected test output to match
    the current tools output, and write diff and ref files in /tmp.

 testsuite/tools/meson.build                        |   47 +++++++++++---------
 testsuite/tools/{test-settings.in => settings.in}  |    0
 .../{simplify => simplify-data}/test1.expected     |    0
 .../tools/{simplify => simplify-data}/test1.ui     |    0
 .../{simplify => simplify-data}/test2.expected     |    2 +-
 .../tools/{simplify => simplify-data}/test2.ui     |    0
 .../{simplify => simplify-data}/test3.expected     |    2 +-
 .../tools/{simplify => simplify-data}/test3.ui     |    0
 .../{simplify => simplify-data}/test4.expected     |    2 +-
 .../tools/{simplify => simplify-data}/test4.ui     |    0
 .../{simplify => simplify-data}/test5.expected     |    0
 .../tools/{simplify => simplify-data}/test5.ui     |    0
 .../{simplify => simplify-data}/test6.expected     |    0
 .../tools/{simplify => simplify-data}/test6.ui     |    0
 .../{simplify => simplify-data}/test7.expected     |    0
 .../tools/{simplify => simplify-data}/test7.ui     |    0
 .../{simplify => simplify-data}/test8.expected     |    2 +-
 .../tools/{simplify => simplify-data}/test8.ui     |    0
 testsuite/tools/{test-simplify.in => simplify.in}  |    8 +++-
 testsuite/tools/tools.test.in                      |    4 ++
 20 files changed, 40 insertions(+), 27 deletions(-)
---
diff --git a/testsuite/tools/meson.build b/testsuite/tools/meson.build
index 2515aa5..64724d2 100644
--- a/testsuite/tools/meson.build
+++ b/testsuite/tools/meson.build
@@ -1,3 +1,6 @@
+testexecdir = join_paths(installed_test_bindir, 'tools')
+testdatadir = join_paths(installed_test_datadir, 'tools')
+
 bash = find_program('bash', required : false)
 if bash.found()
   test_env = environment()
@@ -5,28 +8,30 @@ if bash.found()
   test_env.set('GTK_QUERY_SETTINGS', get_variable('gtk4_query_settings').full_path())
 
   foreach t : ['simplify', 'settings']
-    configure_file(output : 'test-@0@'.format(t),
-      input : 'test-@0@.in'.format(t),
-      configuration : configuration_data())
-
+    configure_file(output: t,
+                   input: '@0@.in'.format(t),
+                   configuration: configuration_data(),
+                   install: get_option('install-tests'),
+                   install_dir: testexecdir)
     test(t, bash,
-      args : 'test-@0@'.format(t),
-      workdir : meson.current_build_dir(),
-      env : test_env,
-      suite: 'tools')
+         args: 'test-@0@'.format(t),
+         workdir: meson.current_build_dir(),
+         env: test_env,
+         suite: 'tools')
   endforeach
-endif # bash found
+endif
 
-# Installed data
+if get_option('install-tests')
+  foreach t : ['simplify', 'settings']
+    test_conf = configuration_data()
+    test_conf.set('testexecdir', testexecdir)
+    test_conf.set('test', t)
+    configure_file(output: '@0@.test'.format(t),
+                   input: 'tools.test.in',
+                   configuration: test_conf,
+                   install: true,
+                   install_dir: testdatadir)
+  endforeach
 
-test_simplify_data = [
-  'simplify/test1.ui', 'simplify/test1.expected',
-  'simplify/test2.ui', 'simplify/test2.expected',
-  'simplify/test3.ui', 'simplify/test3.expected',
-  'simplify/test4.ui', 'simplify/test4.expected',
-  'simplify/test5.ui', 'simplify/test5.expected',
-  'simplify/test6.ui', 'simplify/test6.expected',
-  'simplify/test7.ui', 'simplify/test7.expected',
-  'simplify/test8.ui', 'simplify/test8.expected',
-]
-# TODO: install in case of installed tests - install_data()
+  install_subdir('simplify-data', install_dir: testexecdir)
+endif
diff --git a/testsuite/tools/test-settings.in b/testsuite/tools/settings.in
similarity index 100%
rename from testsuite/tools/test-settings.in
rename to testsuite/tools/settings.in
diff --git a/testsuite/tools/simplify/test1.expected b/testsuite/tools/simplify-data/test1.expected
similarity index 100%
rename from testsuite/tools/simplify/test1.expected
rename to testsuite/tools/simplify-data/test1.expected
diff --git a/testsuite/tools/simplify/test1.ui b/testsuite/tools/simplify-data/test1.ui
similarity index 100%
rename from testsuite/tools/simplify/test1.ui
rename to testsuite/tools/simplify-data/test1.ui
diff --git a/testsuite/tools/simplify/test2.expected b/testsuite/tools/simplify-data/test2.expected
similarity index 70%
rename from testsuite/tools/simplify/test2.expected
rename to testsuite/tools/simplify-data/test2.expected
index 20ffe8d..99fefb9 100644
--- a/testsuite/tools/simplify/test2.expected
+++ b/testsuite/tools/simplify-data/test2.expected
@@ -1,6 +1,6 @@
 <!-- non-default property not stripped -->
 <interface>
   <object class="GtkWindow">
-    <property name="visible">True</property>
+    <property name="visible">1</property>
   </object>
 </interface>
diff --git a/testsuite/tools/simplify/test2.ui b/testsuite/tools/simplify-data/test2.ui
similarity index 100%
rename from testsuite/tools/simplify/test2.ui
rename to testsuite/tools/simplify-data/test2.ui
diff --git a/testsuite/tools/simplify/test3.expected b/testsuite/tools/simplify-data/test3.expected
similarity index 62%
rename from testsuite/tools/simplify/test3.expected
rename to testsuite/tools/simplify-data/test3.expected
index 2490e79..6b9c07f 100644
--- a/testsuite/tools/simplify/test3.expected
+++ b/testsuite/tools/simplify-data/test3.expected
@@ -1,6 +1,6 @@
 <!-- translatable property not stripped -->
 <interface>
   <object class="GtkWindow">
-    <property name="visible" translatable="yes">False</property>
+    <property name="visible" translatable="yes">0</property>
   </object>
 </interface>
diff --git a/testsuite/tools/simplify/test3.ui b/testsuite/tools/simplify-data/test3.ui
similarity index 100%
rename from testsuite/tools/simplify/test3.ui
rename to testsuite/tools/simplify-data/test3.ui
diff --git a/testsuite/tools/simplify/test4.expected b/testsuite/tools/simplify-data/test4.expected
similarity index 72%
rename from testsuite/tools/simplify/test4.expected
rename to testsuite/tools/simplify-data/test4.expected
index 41d8ecc..286f106 100644
--- a/testsuite/tools/simplify/test4.expected
+++ b/testsuite/tools/simplify-data/test4.expected
@@ -1,6 +1,6 @@
 <!-- irrelevant comments and context are stripped -->
 <interface>
   <object class="GtkWindow">
-    <property name="visible">True</property>
+    <property name="visible">1</property>
   </object>
 </interface>
diff --git a/testsuite/tools/simplify/test4.ui b/testsuite/tools/simplify-data/test4.ui
similarity index 100%
rename from testsuite/tools/simplify/test4.ui
rename to testsuite/tools/simplify-data/test4.ui
diff --git a/testsuite/tools/simplify/test5.expected b/testsuite/tools/simplify-data/test5.expected
similarity index 100%
rename from testsuite/tools/simplify/test5.expected
rename to testsuite/tools/simplify-data/test5.expected
diff --git a/testsuite/tools/simplify/test5.ui b/testsuite/tools/simplify-data/test5.ui
similarity index 100%
rename from testsuite/tools/simplify/test5.ui
rename to testsuite/tools/simplify-data/test5.ui
diff --git a/testsuite/tools/simplify/test6.expected b/testsuite/tools/simplify-data/test6.expected
similarity index 100%
rename from testsuite/tools/simplify/test6.expected
rename to testsuite/tools/simplify-data/test6.expected
diff --git a/testsuite/tools/simplify/test6.ui b/testsuite/tools/simplify-data/test6.ui
similarity index 100%
rename from testsuite/tools/simplify/test6.ui
rename to testsuite/tools/simplify-data/test6.ui
diff --git a/testsuite/tools/simplify/test7.expected b/testsuite/tools/simplify-data/test7.expected
similarity index 100%
rename from testsuite/tools/simplify/test7.expected
rename to testsuite/tools/simplify-data/test7.expected
diff --git a/testsuite/tools/simplify/test7.ui b/testsuite/tools/simplify-data/test7.ui
similarity index 100%
rename from testsuite/tools/simplify/test7.ui
rename to testsuite/tools/simplify-data/test7.ui
diff --git a/testsuite/tools/simplify/test8.expected b/testsuite/tools/simplify-data/test8.expected
similarity index 80%
rename from testsuite/tools/simplify/test8.expected
rename to testsuite/tools/simplify-data/test8.expected
index d5b6825..df3c407 100644
--- a/testsuite/tools/simplify/test8.expected
+++ b/testsuite/tools/simplify-data/test8.expected
@@ -4,7 +4,7 @@
     <child>
       <object class="GtkLabel"/>
       <packing>
-        <property name="expand">True</property>
+        <property name="expand">1</property>
       </packing>
     </child>
   </object>
diff --git a/testsuite/tools/simplify/test8.ui b/testsuite/tools/simplify-data/test8.ui
similarity index 100%
rename from testsuite/tools/simplify/test8.ui
rename to testsuite/tools/simplify-data/test8.ui
diff --git a/testsuite/tools/test-simplify.in b/testsuite/tools/simplify.in
similarity index 68%
rename from testsuite/tools/test-simplify.in
rename to testsuite/tools/simplify.in
index 6b4f2e8..642b50f 100755
--- a/testsuite/tools/test-simplify.in
+++ b/testsuite/tools/simplify.in
@@ -1,7 +1,7 @@
 #! /bin/bash
 
 GTK_BUILDER_TOOL=${GTK_BUILDER_TOOL:-gtk-builder-tool}
-TEST_DATA_DIR=${TEST_DATA_DIR:-./simplify}
+TEST_DATA_DIR=${TEST_DATA_DIR:-./simplify-data}
 TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
 
 shopt -s nullglob
@@ -14,13 +14,17 @@ 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 $t 2>/dev/null >$result
 
-  if diff "$expected" "$result" > /dev/null; then
+  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))
diff --git a/testsuite/tools/tools.test.in b/testsuite/tools/tools.test.in
new file mode 100644
index 0000000..24c47ce
--- /dev/null
+++ b/testsuite/tools/tools.test.in
@@ -0,0 +1,4 @@
+[Test]
+Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 TEST_DATA_DIR=@testexecdir@/@test@-data @testexecdir@/@test@"
+Type=session
+Output=TAP


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]