diff options
| author | Emmanuele Bassi <ebassi@gnome.org> | 2017-03-13 13:29:33 +0000 |
|---|---|---|
| committer | Emmanuele Bassi <ebassi@gnome.org> | 2017-03-13 14:26:27 +0000 |
| commit | d21d54f2f157b08bc91679dd0e027c450f8f9f4e (patch) | |
| tree | 2641a485e3a535924a3d25efd9d83b0684614712 /json-glib/tests | |
| parent | 6381587d7cacb42d77aa747707d31cb29b656dc7 (diff) | |
| download | json-glib-d21d54f2f157b08bc91679dd0e027c450f8f9f4e.tar.gz | |
Install tests
We should install our tests in order to get them executed in
environments like GNOME Continuous and other continuous delivery
systems.
Diffstat (limited to 'json-glib/tests')
| -rw-r--r-- | json-glib/tests/gen-installed-test.py | 19 | ||||
| -rw-r--r-- | json-glib/tests/meson.build | 23 |
2 files changed, 41 insertions, 1 deletions
diff --git a/json-glib/tests/gen-installed-test.py b/json-glib/tests/gen-installed-test.py new file mode 100644 index 0000000..8fe4265 --- /dev/null +++ b/json-glib/tests/gen-installed-test.py @@ -0,0 +1,19 @@ +import sys +import os +import argparse + +def write_template(filename, data): + with open(filename, 'w') as f: + f.write(data) + +def build_template(testdir, testname): + return "[Test]\nType=session\nExec={}\n".format(os.path.join(testdir, testname)) + +argparser = argparse.ArgumentParser(description='Generate installed-test data.') +argparser.add_argument('--testdir', metavar='dir', required=True, help='Installed test directory') +argparser.add_argument('--testname', metavar='name', required=True, help='Installed test name') +argparser.add_argument('--outfile', metavar='file', required=True, help='Output file') +argparser.add_argument('--outdir', metavar='dir', required=True, help='Output directory') +args = argparser.parse_args() + +write_template(os.path.join(args.outdir, args.outfile), build_template(args.testdir, args.testname)) diff --git a/json-glib/tests/meson.build b/json-glib/tests/meson.build index 9cab4bc..20c3fea 100644 --- a/json-glib/tests/meson.build +++ b/json-glib/tests/meson.build @@ -16,6 +16,7 @@ tests = [ ] python3 = find_program('python3') +gen_installed_test = join_paths(meson.current_source_dir(), 'gen-installed-test.py') test_data = [ 'stream-load.json', @@ -29,9 +30,29 @@ foreach d: test_data endif endforeach +installed_test_dir = join_paths(json_libexecdir, 'installed-tests', 'json-glib-1.0') + +install_data(test_data, install_dir: installed_test_dir) + foreach t: tests + data = custom_target('@0@.test'.format(t), + output: '@0@.test'.format(t), + command: [ + python3, + gen_installed_test, + '--testdir=@0@'.format(installed_test_dir), + '--testname=@0@.test'.format(t), + '--outdir=@OUTDIR@', + '--outfile=@0@.test'.format(t), + ], + install: true, + install_dir: join_paths(json_datadir, 'installed-tests', 'json-glib-1.0')) + exe = executable(t, '@0@.c'.format(t), c_args: json_c_args, + install: true, + install_dir: installed_test_dir, dependencies: [ json_glib_dep, ]) - test(t, exe) + + test(t, exe, args: [ '--tap', '-k' ]) endforeach |
