Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 21 additions & 3 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ;;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading