From f03d1ea44d78e88b326d72198024226d95752682 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 30 Nov 2022 10:17:49 +0100 Subject: [PATCH] [meson] Do not build test programs by default If you want run tests, pass -Dtest=true to meson and run "meson test" at the end. --- meson_options.txt | 1 + src/cookies/meson.build | 14 ++++++++------ src/document/html/meson.build | 4 +++- src/dom/meson.build | 5 ++++- src/dom/test/meson.build | 1 + src/mime/backend/meson.build | 2 +- src/network/ssl/meson.build | 4 +++- src/protocol/ftp/meson.build | 14 ++++++++------ src/protocol/meson.build | 4 +++- 9 files changed, 32 insertions(+), 17 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 6a1ce41c5..3e4106306 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -72,3 +72,4 @@ option('source-date-epoch', type: 'string', value: '', description: 'source date option('dgi', type: 'boolean', value: false, description: 'DOS Gateway Interface support') option('mujs', type: 'boolean', value: false, description: 'use mujs library') option('codepoint', type: 'boolean', value: true, description: 'whether check codepoints on Linux console') +option('test', type: 'boolean', value: false, description: 'whether build test programs') diff --git a/src/cookies/meson.build b/src/cookies/meson.build index b17b1d172..84ad017a7 100644 --- a/src/cookies/meson.build +++ b/src/cookies/meson.build @@ -1,10 +1,12 @@ srcs += files('cookies.c', 'dialogs.c', 'path.c', 'parser.c') -exe = executable('cookies-t', 'cookies-t.c', 'path.c', include_directories:['..'], build_by_default:false) -test_lib = environment({'TEST_LIB': meson.source_root()+'/test/libtest.sh'}) -t = find_program('test-cookies-t') -test('cookies', t, depends:[exe], env:test_lib, workdir:meson.current_build_dir()) +if get_option('test') + exe = executable('cookies-t', 'cookies-t.c', 'path.c', include_directories:['..'], build_by_default:false) + test_lib = environment({'TEST_LIB': meson.source_root()+'/test/libtest.sh'}) + t = find_program('test-cookies-t') + test('cookies', t, depends:[exe], env:test_lib, workdir:meson.current_build_dir()) -parsetstdeps = files('parser.c', 'parsetst.c') + parsetstdeps = files('parser.c', 'parsetst.c') -executable('parsetst', parsetstdeps, testdeps, dependencies:[iconvdeps], c_args:['-DHAVE_CONFIG_H'], include_directories:['.', '..', '../..']) + executable('parsetst', parsetstdeps, testdeps, dependencies:[iconvdeps], c_args:['-DHAVE_CONFIG_H'], include_directories:['.', '..', '../..']) +endif diff --git a/src/document/html/meson.build b/src/document/html/meson.build index 069a7dc01..ab68c0373 100644 --- a/src/document/html/meson.build +++ b/src/document/html/meson.build @@ -1,3 +1,5 @@ subdir('parser') -subdir('test') +if get_option('test') + subdir('test') +endif srcs += files('frames.c', 'iframes.c', 'parse-meta-refresh.c', 'parser.c', 'renderer.c', 'tables.c') diff --git a/src/dom/meson.build b/src/dom/meson.build index 3ba774f7a..21c8d6fd0 100644 --- a/src/dom/meson.build +++ b/src/dom/meson.build @@ -1,4 +1,7 @@ subdir('css') subdir('sgml') srcs += files('configuration.c', 'node.c', 'select.c', 'stack.c', 'scanner.c') -subdir('test') + +if get_option('test') + subdir('test') +endif diff --git a/src/dom/test/meson.build b/src/dom/test/meson.build index 6f8a86421..55b2120c8 100644 --- a/src/dom/test/meson.build +++ b/src/dom/test/meson.build @@ -28,6 +28,7 @@ meson.source_root()+'/src/dom/sgml/xbel/xbel.c', testdeps, c_args:['-DHAVE_CONFIG_H'], cpp_args:['-DHAVE_CONFIG_H'], include_directories:['.', '../..', '../../..'], build_by_default:false) +endif test_lib = environment({'TEST_LIB': meson.source_root()+'/test/libtest.sh'}) diff --git a/src/mime/backend/meson.build b/src/mime/backend/meson.build index 3f6d451fb..99a68c035 100644 --- a/src/mime/backend/meson.build +++ b/src/mime/backend/meson.build @@ -10,7 +10,7 @@ endif srcs += files('common.c', 'default.c') -if conf_data.get('CONFIG_MAILCAP') +if conf_data.get('CONFIG_MAILCAP') and get_option('test') mailcap_cache_files = files('common.c', 'mailcap.c', meson.source_root()+'/src/osdep/osdep.c') if conf_data.get('CONFIG_NLS') and not conf_data.get('CONFIG_GETTEXT') diff --git a/src/network/ssl/meson.build b/src/network/ssl/meson.build index 12e587048..f59768c3a 100644 --- a/src/network/ssl/meson.build +++ b/src/network/ssl/meson.build @@ -1,2 +1,4 @@ srcs += files('match-hostname.c', 'ssl.c', 'socket.c') -subdir('test') +if get_option('test') + subdir('test') +endif diff --git a/src/protocol/ftp/meson.build b/src/protocol/ftp/meson.build index ca9773d79..8445a4b40 100644 --- a/src/protocol/ftp/meson.build +++ b/src/protocol/ftp/meson.build @@ -1,9 +1,11 @@ srcs += files('ftp.c', 'parse.c') -exe = executable('ftp-parser', 'ftp-parser.c', 'parse.c', meson.source_root()+'/src/protocol/date.c', testdeps, dependencies:[iconvdeps], -c_args:['-DHAVE_CONFIG_H'], cpp_args:['-DHAVE_CONFIG_H'], include_directories:['.','../..','../../..'], -build_by_default:false) +if get_option('test') + exe = executable('ftp-parser', 'ftp-parser.c', 'parse.c', meson.source_root()+'/src/protocol/date.c', testdeps, dependencies:[iconvdeps], + c_args:['-DHAVE_CONFIG_H'], cpp_args:['-DHAVE_CONFIG_H'], include_directories:['.','../..','../../..'], + build_by_default:false) -test_lib = environment({'TEST_LIB': meson.source_root()+'/test/libtest.sh'}) -t = find_program('test-ftp-parser') -test('ftp-parser', t, depends:[exe], env:test_lib, workdir:meson.current_build_dir(), is_parallel:false) + test_lib = environment({'TEST_LIB': meson.source_root()+'/test/libtest.sh'}) + t = find_program('test-ftp-parser') + test('ftp-parser', t, depends:[exe], env:test_lib, workdir:meson.current_build_dir(), is_parallel:false) +endif diff --git a/src/protocol/meson.build b/src/protocol/meson.build index 9479a9c0b..8d091972f 100644 --- a/src/protocol/meson.build +++ b/src/protocol/meson.build @@ -34,4 +34,6 @@ if conf_data.get('CONFIG_DATA') endif srcs += files('about.c', 'common.c', 'date.c', 'header.c', 'protocol.cpp', 'proxy.c', 'uri.c', 'user.c') -subdir('test') +if get_option('test') + subdir('test') +endif