@@ -95,9 +95,49 @@ ensure_macos_sdk_env() {
9595 fi
9696}
9797
98+ # Ensure Apple SDK frameworks are linkable (important inside Nix shells).
99+ # In some environments, the compiler picks up headers from the Apple SDK but
100+ # fails to locate the corresponding frameworks at link time.
101+ ensure_macos_frameworks_ldflags () {
102+ if [ " $( uname -s) " != " Darwin" ]; then
103+ return 0
104+ fi
105+
106+ if [ -z " ${SDKROOT:- } " ] || [ ! -d " ${SDKROOT} " ]; then
107+ # Best-effort attempt to populate SDKROOT.
108+ ensure_macos_sdk_env || true
109+ fi
110+
111+ if [ -z " ${SDKROOT:- } " ] || [ ! -d " ${SDKROOT} " ]; then
112+ return 0
113+ fi
114+
115+ local frameworks_dir
116+ frameworks_dir=" ${SDKROOT} /System/Library/Frameworks"
117+ if [ ! -d " ${frameworks_dir} " ]; then
118+ return 0
119+ fi
120+
121+ local fw_ldflags
122+ fw_ldflags=" -F${frameworks_dir} -Wl,-F,${frameworks_dir} "
123+
124+ if [ -n " ${LDFLAGS:- } " ]; then
125+ export LDFLAGS=" ${fw_ldflags} ${LDFLAGS} "
126+ else
127+ export LDFLAGS=" ${fw_ldflags} "
128+ fi
129+
130+ if [ -n " ${RUSTFLAGS:- } " ]; then
131+ export RUSTFLAGS=" -C link-arg=-F${frameworks_dir} -C link-arg=-Wl,-F,${frameworks_dir} ${RUSTFLAGS} "
132+ else
133+ export RUSTFLAGS=" -C link-arg=-F${frameworks_dir} -C link-arg=-Wl,-F,${frameworks_dir} "
134+ fi
135+ }
136+
98137# Unified nixpkgs pin (used by all scripts)
99138# Keep a single source of truth for the pinned nixpkgs URL.
100- export PIN_URL=" https://github.com/NixOS/nixpkgs/archive/24.05.tar.gz"
139+ # Pin nixpkgs for a stable toolchain; Linux builds target GLIBC <= 2.34.
140+ export PIN_URL=" https://github.com/NixOS/nixpkgs/archive/24.11.tar.gz"
101141# Backward-compatible alias used by some scripts
102142export PINNED_NIXPKGS_URL=" $PIN_URL "
103143
@@ -206,6 +246,7 @@ init_build_env() {
206246 fi
207247
208248 ensure_macos_sdk_env
249+ ensure_macos_frameworks_ldflags
209250 export VARIANT VARIANT_NAME BUILD_PROFILE RELEASE_FLAG LINK
210251}
211252
@@ -320,22 +361,42 @@ _run_workspace_tests() {
320361 ;;
321362 esac
322363
323- # shellcheck disable=SC2086
324- cargo test --workspace --lib $RELEASE_FLAG ${FEATURES_FLAG[@]+" ${FEATURES_FLAG[@]} " } -- $test_args $test_filter
325-
326- # For database backends (postgresql, mysql, redis), also run the regular non-ignored tests
327- # For sqlite, skip this step since all non-ignored tests already ran above
328- if [ " $KMS_TEST_DB " != " sqlite" ]; then
329- # shellcheck disable=SC2086
330- cargo test --workspace --lib $RELEASE_FLAG ${FEATURES_FLAG[@]+" ${FEATURES_FLAG[@]} " } --
364+ local -a cargo_test_args
365+ cargo_test_args=(--workspace --lib)
366+ if [ -n " ${RELEASE_FLAG:- } " ]; then
367+ cargo_test_args+=(" $RELEASE_FLAG " )
331368 fi
332- cargo test --workspace --lib $RELEASE_FLAG ${FEATURES_FLAG[@]+" ${FEATURES_FLAG[@]} " } -- $test_args $test_filter
369+ if [ ${# FEATURES_FLAG[@]} -gt 0 ]; then
370+ cargo_test_args+=(" ${FEATURES_FLAG[@]} " )
371+ fi
372+ cargo_test_args+=(--)
373+ cargo_test_args+=(--nocapture)
374+ case " $KMS_TEST_DB " in
375+ postgresql | mysql | redis-findex)
376+ cargo_test_args+=(--ignored)
377+ ;;
378+ esac
379+ if [ -n " ${test_filter:- } " ]; then
380+ # Split filter into tokens (Rust test name filters are space-separated here by design)
381+ read -r -a _test_filter_tokens <<< " $test_filter"
382+ cargo_test_args+=(" ${_test_filter_tokens[@]} " )
383+ fi
384+
385+ cargo test " ${cargo_test_args[@]} "
333386
334387 # For database backends (postgresql, mysql, redis), also run the regular non-ignored tests
335388 # For sqlite, skip this step since all non-ignored tests already ran above
336389 if [ " $KMS_TEST_DB " != " sqlite" ]; then
337- # shellcheck disable=SC2086
338- cargo test --workspace --lib $RELEASE_FLAG ${FEATURES_FLAG[@]+" ${FEATURES_FLAG[@]} " } --
390+ local -a cargo_test_non_ignored_args
391+ cargo_test_non_ignored_args=(--workspace --lib)
392+ if [ -n " ${RELEASE_FLAG:- } " ]; then
393+ cargo_test_non_ignored_args+=(" $RELEASE_FLAG " )
394+ fi
395+ if [ ${# FEATURES_FLAG[@]} -gt 0 ]; then
396+ cargo_test_non_ignored_args+=(" ${FEATURES_FLAG[@]} " )
397+ fi
398+ cargo_test_non_ignored_args+=(--)
399+ cargo test " ${cargo_test_non_ignored_args[@]} "
339400 fi
340401}
341402
0 commit comments