diff options
author | Jan Janssen <medhefgo@web.de> | 2023-01-25 17:19:52 +0100 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2023-02-21 15:10:26 +0100 |
commit | 822cd3ff2579d6de8acd45d85d2b9d5f44048d5c (patch) | |
tree | 570148c87a6ea6f4cfcbe2b4db525684f3af9534 /meson.build | |
parent | c12e10d785bfe70359a3ec4ae4666957c570c538 (diff) | |
download | systemd-822cd3ff2579d6de8acd45d85d2b9d5f44048d5c.tar.gz |
meson: Use dicts for test definitions
Although this slightly more verbose it makes it much easier to reason
about. The code that produces the tests heavily benefits from this.
Test lists are also now sorted by test name.
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 76 |
1 files changed, 33 insertions, 43 deletions
diff --git a/meson.build b/meson.build index 8a397e7c4d..d8ab43ba6c 100644 --- a/meson.build +++ b/meson.build @@ -4078,60 +4078,50 @@ if '-O2' in c_args and '-flto=auto' in c_args endif foreach test : simple_tests - tests += [ [[test]] ] + tests += { 'sources' : [test] } endforeach -foreach tuple : tests - sources = tuple[0] - link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared] - dependencies = tuple.length() > 2 ? tuple[2] : [] - incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes - condition = tuple.length() > 4 ? tuple[4] : '' - type = tuple.length() > 5 ? tuple[5] : '' - defs = tuple.length() > 6 ? tuple[6] : [] - defs += test_cflags - parallel = tuple.length() > 7 ? tuple[7] : true - timeout = 30 +foreach test : tests + sources = test.get('sources') + condition = test.get('condition', '') + type = test.get('type', '') + base = test.get('base', {}) # FIXME: Use fs.stem() with meson >= 0.54.0 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0] - if type.startswith('timeout=') - timeout = type.split('=')[1].to_int() - type = '' - endif suite = fs.name(fs.parent('@0@'.format(sources[0]))) # FIXME: Use str.replace() with meson >= 0.58.0 suite = suite.split('sd-')[-1] - if condition == '' or conf.get(condition) == 1 - exe = executable( - name, - sources, - include_directories : incs, - link_with : link_with, - dependencies : [versiondep, - dependencies], - c_args : defs, - build_by_default : want_tests != 'false', - install_rpath : rootpkglibdir, - install : install_tests, - install_dir : testsdir / type, - link_depends : runtest_env) - - if type == 'manual' - message('@0@ is a manual test'.format(name)) - elif type == 'unsafe' and want_tests != 'unsafe' - message('@0@ is an unsafe test'.format(name)) - elif want_tests != 'false' - test(name, exe, - env : test_env, - timeout : timeout, - suite : suite, - is_parallel : parallel) - endif - else + if condition != '' and conf.get(condition) == 0 message('Not compiling @0@ because @1@ is not true'.format(name, condition)) + continue + endif + + exe = executable( + name, + sources, + include_directories : [base.get('includes', []), test.get('includes', includes)], + link_with : [base.get('link_with', []), test.get('link_with', libshared)], + dependencies : [versiondep, base.get('dependencies', []), test.get('dependencies', [])], + c_args : [test_cflags, test.get('c_args', [])], + build_by_default : want_tests != 'false', + install_rpath : rootpkglibdir, + install : install_tests, + install_dir : testsdir / type, + link_depends : runtest_env) + + if type == 'manual' + message('@0@ is a manual test'.format(name)) + elif type == 'unsafe' and want_tests != 'unsafe' + message('@0@ is an unsafe test'.format(name)) + elif want_tests != 'false' + test(name, exe, + env : test_env, + timeout : test.get('timeout', 30), + suite : suite, + is_parallel : test.get('parallel', true)) endif endforeach |