Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add build-test option #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Run tests
run: >-
meson setup --cross-file meson.cross.x86_64-w64-mingw32
-Denable-debug-checks=true build_ci
-Denable-debug-checks=true -Dbuild-test=true build_ci
&& meson test -j4 -t8 -Cbuild_ci

linaro-ubuntu-arm64:
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
run: >-
export PATH=$(pwd)/llvm-mingw-20240308-ucrt-ubuntu-20.04-x86_64/bin:$PATH;
meson setup --cross-file meson.cross.aarch64-w64-mingw32
-Denable-debug-checks=true build_ci
-Denable-debug-checks=true -Dbuild-test=true build_ci
&& meson test -j2 -t12 -Cbuild_ci

msys2-ucrt64:
Expand All @@ -90,7 +90,7 @@ jobs:

- name: Run tests
run: >-
meson setup -Denable-debug-checks=true build_ci
meson setup -Denable-debug-checks=true -Dbuild-test=true build_ci
&& meson test -j4 -t2 -Cbuild_ci

msys2-mingw32:
Expand All @@ -115,7 +115,7 @@ jobs:

- name: Run tests
run: >-
meson setup -Denable-debug-checks=true build_ci
meson setup -Denable-debug-checks=true -Dbuild-test=true build_ci
&& meson test -j4 -t2 -Cbuild_ci

msys2-clang64:
Expand All @@ -141,5 +141,5 @@ jobs:
- name: Run tests
run: >-
export CC=clang CXX=clang++;
meson setup -Denable-debug-checks=true build_ci
meson setup -Denable-debug-checks=true -Dbuild-test=true build_ci
&& meson test -j4 -t2 -Cbuild_ci
68 changes: 35 additions & 33 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -336,44 +336,46 @@ import('pkgconfig').generate(lib_mcfgthread_dll,
#===========================================================
# Rules for tests
#===========================================================
foreach src: test_src
test_c_args = []
test_cpp_args = []
test_dependencies = []
test_link_with = lib_mcfgthread_dll
if get_option('build-test')
foreach src: test_src
test_c_args = []
test_cpp_args = []
test_dependencies = []
test_link_with = lib_mcfgthread_dll

if src == 'test/win8.c' or src == 'test/win10.c'
test_link_with = lib_mcfgthread_a
endif
if src == 'test/win8.c' or src == 'test/win10.c'
test_link_with = lib_mcfgthread_a
endif

if src == 'test/memory.c'
test_dependencies = [ dep_advapi32, dep_ntdll ]
endif
if src == 'test/memory.c'
test_dependencies = [ dep_advapi32, dep_ntdll ]
endif

if src == 'test/gthr_c89_pedantic.c'
test_c_args = [ '-std=c89', '-Wpedantic', '-Wno-variadic-macros',
'-Wno-long-long', '-Werror=declaration-after-statement' ]
endif
if src == 'test/gthr_c89_pedantic.c'
test_c_args = [ '-std=c89', '-Wpedantic', '-Wno-variadic-macros',
'-Wno-long-long', '-Werror=declaration-after-statement' ]
endif

if src == 'test/c11_c99_pedantic.c'
test_c_args = [ '-std=c99', '-Wpedantic' ]
endif
if src == 'test/c11_c99_pedantic.c'
test_c_args = [ '-std=c99', '-Wpedantic' ]
endif

if src == 'test/cxx11_no_exceptions.cpp'
test_cpp_args = [ '-std=c++11', '-fno-rtti', '-fno-exceptions' ]
endif
if src == 'test/cxx11_no_exceptions.cpp'
test_cpp_args = [ '-std=c++11', '-fno-rtti', '-fno-exceptions' ]
endif

if src == 'test/cxx11_pedantic.cpp'
test_cpp_args = [ '-std=c++11', '-Wpedantic' ]
endif
if src == 'test/cxx11_pedantic.cpp'
test_cpp_args = [ '-std=c++11', '-Wpedantic' ]
endif

test_exe = executable(src.underscorify(), src,
c_args: test_c_args,
cpp_args: test_cpp_args,
link_args: [ '-static-libgcc', '-static-libstdc++' ],
dependencies: test_dependencies,
link_with: test_link_with,
install: false)
test_exe = executable(src.underscorify(), src,
c_args: test_c_args,
cpp_args: test_cpp_args,
link_args: [ '-static-libgcc', '-static-libstdc++' ],
dependencies: test_dependencies,
link_with: test_link_with,
install: false)

test('..' / src, test_exe)
endforeach
test('..' / src, test_exe)
endforeach
endif
4 changes: 4 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
option('enable-debug-checks',
type: 'boolean', value: false,
description: 'enable run-time assertions')

option('build-test',
type: 'boolean', value: false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option should be named enable-tests, and should have a default value of true.

description: 'Build unit test')