diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 62142851a1..737039b348 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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 diff --git a/meson.build b/meson.build index ced6a1b54a..fc95275796 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/meson.options b/meson.options index d0342f83b2..b45d572315 100644 --- a/meson.options +++ b/meson.options @@ -15,3 +15,7 @@ option('enable-debug-checks', type: 'boolean', value: false, description: 'enable run-time assertions') + +option('build-test', + type: 'boolean', value: false, + description: 'Build unit test')