diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2017-05-19 14:15:35 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2017-05-19 17:32:28 +0100 |
commit | 386939f9d576e8ac956f88fd85f87d1fba76e9ed (patch) | |
tree | 5eec82eaab7e3547741630daf9d944e627186a62 /tests | |
parent | 09623d50ac8afd9b246e571372972142af5daaa3 (diff) | |
download | pango-386939f9d576e8ac956f88fd85f87d1fba76e9ed.tar.gz |
meson: Install tests and additional data
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gen-all-unicode.py | 34 | ||||
-rw-r--r-- | tests/gen-installed-test.py | 23 | ||||
-rw-r--r-- | tests/meson.build | 74 |
3 files changed, 130 insertions, 1 deletions
diff --git a/tests/gen-all-unicode.py b/tests/gen-all-unicode.py new file mode 100644 index 00000000..011ab9d2 --- /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 00000000..794ea107 --- /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 d69a0d0d..a4df3bc0 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 |