[pango/wip/meson: 6/7] meson: Install tests and additional data



commit 386939f9d576e8ac956f88fd85f87d1fba76e9ed
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri May 19 14:15:35 2017 +0100

    meson: Install tests and additional data

 meson.build                 |    1 +
 tests/gen-all-unicode.py    |   34 +++++++++++++++++++
 tests/gen-installed-test.py |   23 +++++++++++++
 tests/meson.build           |   74 ++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 131 insertions(+), 1 deletions(-)
---
diff --git a/meson.build b/meson.build
index 2bac3b5..c0f943e 100644
--- a/meson.build
+++ b/meson.build
@@ -15,6 +15,7 @@ pango_libdir = join_paths(pango_prefix, get_option('libdir'))
 pango_sysconfdir = join_paths(pango_prefix, get_option('sysconfdir'))
 pango_includedir = join_paths(pango_prefix, get_option('includedir'))
 pango_datadir = join_paths(pango_prefix, get_option('datadir'))
+pango_libexecdir = join_paths(pango_prefix, get_option('libexecdir'))
 
 version = meson.project_version().split('.')
 pango_major_version = version[0].to_int()
diff --git a/tests/gen-all-unicode.py b/tests/gen-all-unicode.py
new file mode 100644
index 0000000..011ab9d
--- /dev/null
+++ b/tests/gen-all-unicode.py
@@ -0,0 +1,34 @@
+import sys
+
+# From glib/gutf8.c:
+#
+#define UNICODE_VALID(Char) \
+#    ((Char) < 0x110000 && (((Char) & 0xFFFFF800) != 0xD800))
+
+def is_valid_unicode(ch):
+    if ch < 0x110000 and (ch & 0xFFFFF800) != 0xD800:
+        return True
+
+    return False
+
+if __name__ == '__main__':
+    if len(sys.argv) < 2:
+        sys.exit('Usage: gen-all-unicode.py OUTFILE')
+
+    with open(sys.argv[1], 'wb') as f:
+        for j in range(0, 2):
+            for i in range(0, 65536):
+                if is_valid_unicode(i):
+                    f.write(chr(i).encode('utf-8', 'surrogatepass'))
+
+                if j == 1:
+                    f.write(b' ')
+
+                if j == 0:
+                    if i % 40 == 0 and i != 0:
+                        f.write(b'\n')
+                else:
+                    if i % 20 == 0 and i != 0:
+                        f.write(b'\n')
+
+        f.write(b'\n')
diff --git a/tests/gen-installed-test.py b/tests/gen-installed-test.py
new file mode 100644
index 0000000..794ea10
--- /dev/null
+++ b/tests/gen-installed-test.py
@@ -0,0 +1,23 @@
+import sys
+import argparse
+import os
+
+template = '''[Test]
+Type=session
+Exec={}
+'''
+
+def build_template(test_dir, test_name):
+    return template.format(os.path.join(test_dir, test_name))
+
+if __name__ == '__main__':
+    argparser = argparse.ArgumentParser(description='Generate installed-test description file')
+    argparser.add_argument('installed_test_dir', help='Path for installed test binaries')
+    argparser.add_argument('test_name', help='Name of the test unit')
+    argparser.add_argument('out_dir', help='Path for the output')
+
+    args = argparser.parse_args()
+
+    outfile = os.path.join(args.out_dir, args.test_name + '.test')
+    with open(outfile, 'w') as f:
+        f.write(build_template(args.installed_test_dir, args.test_name))
diff --git a/tests/meson.build b/tests/meson.build
index d69a0d0..a4df3bc 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -43,15 +43,87 @@ if cairo_dep.found()
   ]
 endif
 
+installed_test_data = [
+  'boundaries.utf8',
+  'GraphemeBreakTest.txt',
+]
+
+test_layouts_data = [
+  'layouts/valid-1',
+  'layouts/valid-2',
+]
+
+test_markups_data = [
+  'markups/fail-1',
+  'markups/fail-2',
+  'markups/fail-3',
+  'markups/fail-4',
+  'markups/fail-5',
+  'markups/valid-1',
+  'markups/valid-2',
+  'markups/valid-3',
+  'markups/valid-4',
+  'markups/valid-5',
+  'markups/valid-6',
+  'markups/valid-7',
+  'markups/valid-8',
+  'markups/valid-9',
+]
+
+installed_test_layouts_data = []
+foreach d: test_layouts_data
+  installed_test_layouts_data += d + '.markup'
+  installed_test_layouts_data += d + '.expected'
+endforeach
+
+installed_test_markups_data = []
+foreach d: test_markups_data
+  installed_test_markups_data += d + '.markup'
+  installed_test_markups_data += d + '.expected'
+endforeach
+
+installed_test_datadir = join_paths(pango_datadir, 'installed-tests', 'pango')
+installed_test_bindir = join_paths(pango_libexecdir, 'installed-tests', 'pango')
+
+install_data(installed_test_data, install_dir: installed_test_bindir)
+install_data(installed_test_layouts_data, install_dir: join_paths(installed_test_bindir, 'layouts'))
+install_data(installed_test_markups_data, install_dir: join_paths(installed_test_bindir, 'markups'))
+
+python = import('python3').find_python()
+gen_installed_test = files([ 'gen-installed-test.py' ])
+gen_all_unicode = files([ 'gen-all-unicode.py' ])
+
+custom_target('all-unicode',
+              output: 'all-unicode.txt',
+              command: [
+                python, gen_all_unicode, '@OUTPUT@'
+              ],
+              install: true,
+              install_dir: installed_test_bindir)
+
 foreach t: tests
   name = t[0]
   src = t.get(1, [ '@0@.c'.format(name) ])
   deps = t.get(2, [ libpango_dep ])
 
+  custom_target(name + '.test',
+                output: name + '.test',
+                command: [
+                  python, gen_installed_test,
+                  installed_test_bindir,
+                  name,
+                  '@OUTDIR@',
+                ],
+                install: true,
+                install_dir: installed_test_datadir)
+
   bin = executable(name, src,
                    dependencies: deps,
                    include_directories: root_inc,
                    c_args: common_cflags + pango_debug_cflags + test_cflags,
-                   cpp_args: common_cppflags + pango_debug_cflags + test_cflags)
+                   cpp_args: common_cppflags + pango_debug_cflags + test_cflags,
+                   install: true,
+                   install_dir: installed_test_bindir)
+
   test(name, bin, env: test_env)
 endforeach


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