summaryrefslogtreecommitdiff
path: root/tests/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'tests/meson.build')
-rw-r--r--tests/meson.build128
1 files changed, 128 insertions, 0 deletions
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..42c442e
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,128 @@
+thread_dep = dependency('threads')
+dl_dep = cc.find_library('dl', required: false)
+python = find_program('python3', native: true, version: '>=3.10')
+bash = find_program('bash', native: true)
+
+# The tests check their steps with assert, so NDEBUG must stay off.
+test_c_args = ['-UNDEBUG']
+
+# The host terminal may preload a library into every child. Keep it out.
+test_env = environment()
+test_env.set('LD_PRELOAD', '')
+test_env.set('DYLD_INSERT_LIBRARIES', '')
+
+# [name, sources, dependencies, suites]
+term_tests = [
+ ['unicode-test', files('unicode/unicode_test.c'), [], []],
+ ['term-input-test', files('input_test.c'), [], []],
+ ['term-test', files('term_test.c'), [thread_dep], ['isa']],
+ ['write-fuzz-test', files('write_fuzz_test.c'), [], ['isa']],
+ ['spec-test', files('spec_test.c'), [], []],
+ ['model-test', files('model_test.c', 'model.c'), [], ['isa']],
+ ['model-row-test', files('model_row_test.c', 'model.c'), [], []],
+ ['gstore-test', files('gstore_test.c'), [], []],
+ ['hist-test', files('hist_test.c'), [], []],
+ ['history-text-test', files('history_text_test.c'), [thread_dep], []],
+ ['view-test', files('view_test.c'), [], []],
+ ['resize-property-test', files('resize_property_test.c'), [], []],
+ ['term-resize-failure-test', files('resize_failure_test.c'), [dl_dep], ['extlib']],
+ ['dcs-test', files('dcs_test.c'), [], []],
+ ['osc-test', files('osc_test.c'), [], []],
+]
+test_helpers_inc = include_directories('helpers')
+
+term_test_exes = {}
+foreach entry : term_tests
+ exe = executable(entry[0], entry[1],
+ c_args: test_c_args,
+ include_directories: test_helpers_inc,
+ dependencies: [term_internal_dep] + entry[2],
+ )
+ term_test_exes += {entry[0]: exe}
+ test(entry[0], exe,
+ args: entry[0] == 'write-fuzz-test' ? [get_option('write_fuzz_seeds').to_string()] : [],
+ env: test_env,
+ suite: ['unit'] + entry[3],
+ timeout: 180,
+ )
+endforeach
+
+# Without -march, the core runs the best kernels the CPU supports. Run the
+# tests again on the lower levels, so each one is covered.
+if host_machine.cpu_family() == 'x86_64' and cc.get_argument_syntax() == 'gcc' and \
+ cc.get_define('__AVX2__', args: get_option('arch_flag') != '' ? [get_option('arch_flag')] : []) == ''
+ foreach level : ['base', 'avx2']
+ level_env = test_env
+ level_env.set('TERM_HEADLESS_ISA', level)
+ foreach name : ['term-test', 'spec-test', 'model-test', 'view-test', 'term-input-test',
+ 'hist-test', 'history-text-test']
+ test(name + '-' + level, term_test_exes[name], env: level_env,
+ suite: ['unit', 'isa'], timeout: 180)
+ endforeach
+ endforeach
+endif
+
+# The amalgamation is the core as one term.c, the way a host builds it. The
+# tests that use only term.h run again against it.
+term_amalgamation = custom_target(
+ 'term-amalgamation',
+ output: ['term.c', 'term.h'],
+ depfile: 'term-amalgamation.d',
+ command: [python, files('../tools/amalgamate.py'),
+ meson.project_source_root(), '@OUTDIR@', '@DEPFILE@'],
+)
+term_amalgamation_lib = static_library(
+ 'term-amalgamation',
+ term_amalgamation[0],
+ dependencies: [m_dep],
+ override_options: ['c_std=c11', 'warning_level=3', 'werror=true'],
+ build_by_default: false,
+)
+foreach entry : term_tests
+ if entry[0] in ['term-test', 'spec-test', 'view-test', 'dcs-test', 'osc-test',
+ 'history-text-test', 'term-input-test', 'model-test', 'model-row-test',
+ 'resize-property-test']
+ test(entry[0] + '-amalgamation',
+ executable(entry[0] + '-amalgamation', entry[1],
+ c_args: test_c_args,
+ include_directories: [term_inc, test_helpers_inc],
+ link_with: term_amalgamation_lib,
+ dependencies: [m_dep] + entry[2],
+ build_by_default: false),
+ env: test_env, suite: ['unit', 'amalgamation'], timeout: 180)
+ endif
+endforeach
+
+test('term-symbols-test', bash,
+ args: [files('symbols_test.sh'), term_headless_lib.get_static_lib(),
+ meson.project_source_root() / 'include' / 'term',
+ term_headless_lib.get_shared_lib()],
+ suite: 'unit',
+)
+test('term-header-test', bash,
+ args: [files('header_test.sh'), meson.project_source_root()],
+ suite: 'unit',
+)
+test('term-cross-test', bash,
+ args: [files('cross_test.sh'), meson.project_source_root()],
+ suite: 'portability',
+ timeout: 600,
+)
+
+if get_option('kitty_tests')
+ if host_machine.system() != 'linux' or get_option('b_sanitize') != 'none'
+ error('Kitty tests require an unsanitized Linux build')
+ endif
+ kitty_bridge = shared_library('term', 'extern/kitty/screen_bridge.c',
+ dependencies: term_internal_dep,
+ )
+ kitty_env = environment()
+ kitty_env.set('WSAP_KITTY_LIB', kitty_bridge.full_path())
+ test('kitty-test', python,
+ args: files('extern/kitty/parser.py'),
+ depends: kitty_bridge,
+ env: kitty_env,
+ suite: 'kitty',
+ is_parallel: false,
+ )
+endif