diff --git a/AGENTS.md b/AGENTS.md index 842f66738..3309bb737 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -40,6 +40,7 @@ BAD: `cargo check --package liboxen` ```bash cargo build --workspace # Debug build cargo build --workspace --bins --tests # Debug build that a later `cargo test` reuses +bin/test --build-only # The build bin/test runs, without the tests ``` A `cargo build` that a `cargo test` follows, in a script or a CI job, builds `--bins --tests` with the same packages and features the test command selects, as `bin/test` and the Rust Tests jobs do. Dev-dependencies add features to crates such as `hyper` and `getrandom`, so a plain `cargo build` resolves a different feature set, and the `cargo test` after it compiles a second copy of every dependency above them, DuckDB, RocksDB, polars, and the AWS SDK included. diff --git a/bin/test b/bin/test index 66c675f3d..d98ed61a0 100755 --- a/bin/test +++ b/bin/test @@ -2,9 +2,12 @@ # # Build, configure, and run the Oxen test suite. # -# Usage: bin/test [--ffmpeg] [--keep] [--install-deps] [--no-ramdisk] [--timings] [-p|--python] [extra args...] +# Usage: bin/test [--ffmpeg] [--keep] [--install-deps] [--no-ramdisk] [--timings] [-p|--python] +# [--build-only] [extra args...] # # --ffmpeg Enable the "ffmpeg" cargo feature for build and test commands. +# --build-only Run the build a Rust test run starts with, then exit, leaving test data alone. +# Not with -p. # --keep Do not remove test data (in data/ox and data/test/runs) on cleanup — useful for # debugging failed tests. # --install-deps Check and install prerequisites (install-prereqs) before running tests. @@ -92,9 +95,11 @@ INSTALL_DEPS=false RUN_PYTHON=false USE_RAMDISK=true TIMINGS=false +BUILD_ONLY=false while true; do case "${1:-}" in --ffmpeg) FEATURE_ARGS="-F ffmpeg"; shift ;; + --build-only) BUILD_ONLY=true; shift ;; --keep) KEEP_DATA=true; shift ;; --install-deps) INSTALL_DEPS=true; shift ;; --no-ramdisk) USE_RAMDISK=false; shift ;; @@ -106,6 +111,11 @@ done set -euo pipefail +if [ "$BUILD_ONLY" = true ] && [ "$RUN_PYTHON" = true ]; then + echo "ERROR: --build-only runs the Rust build and cannot be combined with -p." + exit 2 +fi + # On Linux the `ffmpeg` feature links FFmpeg 9 from /opt/ffmpeg (installed by bin/install-prereqs); # point pkg-config at it. macOS gets FFmpeg 9 from Homebrew, already on the default pkg-config path. if [ -n "$FEATURE_ARGS" ] && [ "$(uname)" = "Linux" ]; then @@ -201,7 +211,9 @@ cleanup() { if [ -n "$PYTHON_CONFIG_DIR" ]; then rm -rf "$PYTHON_CONFIG_DIR" fi - if [ "$KEEP_DATA" = false ]; then + if [ "$BUILD_ONLY" = true ]; then + : + elif [ "$KEEP_DATA" = false ]; then echo "==> Removing test data..." rm -rf ./data/ox rm -rf ./data/test/runs @@ -216,7 +228,9 @@ cleanup() { trap cleanup EXIT INT TERM # Set up ramdisk for test data -if [ "$USE_RAMDISK" = true ]; then +if [ "$BUILD_ONLY" = true ]; then + : +elif [ "$USE_RAMDISK" = true ]; then if ! setup_ramdisk; then echo "==> Ramdisk setup failed, using regular filesystem." fi @@ -236,6 +250,10 @@ echo "==> Building oxen (cargo build --workspace --bins --tests $FEATURE_ARGS).. # shellcheck disable=SC2086 cargo build --workspace --bins --tests $FEATURE_ARGS +if [ "$BUILD_ONLY" = true ]; then + exit 0 +fi + phase "Server start" # Verify ulimit