diff --git a/build-rustfs.sh b/build-rustfs.sh index 23dc165e6..dfb33b021 100755 --- a/build-rustfs.sh +++ b/build-rustfs.sh @@ -445,7 +445,9 @@ build_binary() { build_cmd+=" -p rustfs --bins" if [ -n "$FEATURES" ]; then - build_cmd+=" --features $FEATURES" + local quoted_features + printf -v quoted_features '%q' "$FEATURES" + build_cmd+=" --features $quoted_features" fi print_message $BLUE "📦 Executing: $build_cmd" diff --git a/scripts/test_build_rustfs_options.sh b/scripts/test_build_rustfs_options.sh index 9447259b4..fd8f9e782 100755 --- a/scripts/test_build_rustfs_options.sh +++ b/scripts/test_build_rustfs_options.sh @@ -38,6 +38,13 @@ cat >"$BIN_DIR/cargo" <<'STUB' set -euo pipefail printf '%s\n' "$*" >>"${CARGO_LOG:?}" +if [[ -n "${CARGO_ARG_LOG:-}" ]]; then + i=0 + for arg in "$@"; do + printf 'ARG[%d]=<%s>\n' "$i" "$arg" >>"$CARGO_ARG_LOG" + i=$((i + 1)) + done +fi target="" profile="debug" @@ -91,6 +98,37 @@ short_cargo_log="$TMP_DIR/cargo-short.log" grep -q -- "Features: full" "$short_run_log" grep -q -- "--features full" "$short_cargo_log" +multi_run_log="$TMP_DIR/run-multi.log" +multi_cargo_log="$TMP_DIR/cargo-multi.log" +multi_arg_log="$TMP_DIR/cargo-multi-args.log" +( + cd "$PROJECT_DIR" + PATH="$BIN_DIR:$PATH" CARGO_LOG="$multi_cargo_log" CARGO_ARG_LOG="$multi_arg_log" ./build-rustfs.sh \ + --dev \ + --no-console \ + --skip-verification \ + --output-dir "$TMP_DIR/out-multi" \ + --features "webdav full" >"$multi_run_log" +) + +grep -q -- "Features: webdav full" "$multi_run_log" +features_arg_line=$(awk '/^ARG\[[0-9]+\]=<--features>$/ { print NR; exit }' "$multi_arg_log") +if [[ -z "$features_arg_line" ]]; then + echo "Expected cargo argv to include --features" >&2 + exit 1 +fi + +features_value_line=$(sed -n "$((features_arg_line + 1))p" "$multi_arg_log") +if ! grep -q -E '^ARG\[[0-9]+\]=$' <<<"$features_value_line"; then + echo "Expected --features value to remain one cargo argument" >&2 + exit 1 +fi + +if tail -n +"$((features_arg_line + 2))" "$multi_arg_log" | grep -q -E '^ARG\[[0-9]+\]=$'; then + echo "Expected space-separated feature list to remain one cargo argument" >&2 + exit 1 +fi + missing_log="$TMP_DIR/missing.log" if ( cd "$PROJECT_DIR"