From 0c66fc39952bc1a9ba68d986bf4fb5161bd131f9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 20 Jan 2020 18:18:58 -0500 Subject: [PATCH] Wrote the python script to generate the list of test cases and integrated it into meson.build. This should be fun. --- test/meson.build | 36 ++++++++++++++++++++++++++++++++++++ test/testlist.py | 11 +++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/testlist.py diff --git a/test/meson.build b/test/meson.build index 7860091e..b69d87dc 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1 +1,37 @@ # 19 january 2020 + +libui_test_sources = [ + 'main.c', +] + +libui_test_sources_without_cases = [] +if libui_OS == 'windows' + libui_test_sources_without_cases += [ + windows.compile_resources('resources_' + libui_mode + '.rc', + args: libui_manifest_args, + depend_files: ['test_' + libui_mode + '.manifest']), + ] +endif + +# TODO once we upgrade to 0.49.0, add pie: true +# TODO once we upgrade to 0.50.0, add protocol: 'exitcode' +libui_testparent = executable('testparent', libui_test_sources + libui_test_sources_without_cases, + dependencies: libui_binary_deps, + link_with: libui_libui, + gui_app: false, + install: false) + +pymod = import('python') +python = pymod.find_installation() +# Using files() is the cleanest way to ensure the python script gets the right filenames regardless of how meson sandboxes the command it's running. +runresult = run_command(python, files(['testlist.py'] + libui_test_sources)) +if runresult.returncode() != 0 + error('testlist.py failed; cannot compute list of test cases. Exit code @0@; stderr:\n@1@'.format(runresult.returncode(), runresult.stderr())) +endif +# TODO make sure this works properly on Windows +foreach casename : runresult.stdout().split() + test(casename, libui_tester, + args: [casename], + is_parallel: false, + should_fail: false) +endforeach diff --git a/test/testlist.py b/test/testlist.py new file mode 100644 index 00000000..cb41ed54 --- /dev/null +++ b/test/testlist.py @@ -0,0 +1,11 @@ +# 20 january 2020 +# note: python 3 + +import fileinput +import re + +r = re.compile('^Test\(([A-Za-z0-9_]+)\)$') +for line in fileinput.input(): + match = r.match(line) + if match is not None: + print('Test' + match.group(1))