From 360a44d608f59df92fe409db5057311e955c5d12 Mon Sep 17 00:00:00 2001 From: John Turner Date: Thu, 20 Nov 2025 23:47:54 +0000 Subject: [PATCH] port check.sh to use only meson --- check.sh | 28 +++++++++++++++------------- meson.build | 4 ++++ meson.options | 1 + 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/check.sh b/check.sh index 3abe597..0608a59 100755 --- a/check.sh +++ b/check.sh @@ -2,25 +2,27 @@ source /etc/profile -export CC=clang CXX=clang++ +export PATH="${HOME}/.local/bin:${PATH}" CC=clang CXX=clang++ -cargo fmt --check || exit $? +if command -v ldd; then + export LDFLAGS=-fuse-ld=lld +fi -cargo clippy || exit $? +for file in $(find src -type f -name '*.rs'); do + rustfmt --edition 2024 --check ${file} || exit $? +done -cargo test -r || exit $? +if [[ ! -d build ]]; then + meson setup -Dtests=enabled build || exit $? +fi -cargo build --all --all-features || exit $? +meson compile -C build || exit $? -build=$(mktemp -d) +ninja clippy -C build || exit $? -meson setup ${build} || exit $? - -meson compile -C ${build} || exit $? - -meson test -C ${build} || exit $? - -rm -rf ${build} +for test in unittests; do + meson test -v ${test} -C build || exit $? +done # hack to make sure we use the system meson, since meson format from git is broken /usr/bin/meson format --recursive --check-only || exit $? diff --git a/meson.build b/meson.build index c415bf4..d671ba5 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,10 @@ gentoo_utils = static_library( link_with: [thiserror], ) +if get_option('test').enabled() + rust.test('unittests', gentoo_utils) +endif + if get_option('fuzz').enabled() subdir('fuzz') endif diff --git a/meson.options b/meson.options index 4d0ae09..02fa153 100644 --- a/meson.options +++ b/meson.options @@ -1 +1,2 @@ option('fuzz', type: 'feature', value: 'disabled') +option('test', type: 'feature', value: 'disabled') \ No newline at end of file