llama-stack-mirror/scripts/unit-tests.sh
Ashwin Bharambe 3edfbf163a fix(tests): update coverage source path to src/llama_stack
The unit test script was still using --source=llama_stack for coverage,
which needed to be updated to --source=src/llama_stack after the src/
layout migration.
2025-10-27 11:40:49 -07:00

30 lines
873 B
Bash
Executable file

#!/bin/sh
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
PYTHON_VERSION=${PYTHON_VERSION:-3.12}
set -e
# Always run this at the end, even if something fails
cleanup() {
echo "Generating coverage report..."
uv run --python "$PYTHON_VERSION" coverage html -d htmlcov-$PYTHON_VERSION
}
trap cleanup EXIT
command -v uv >/dev/null 2>&1 || { echo >&2 "uv is required but it's not installed. Exiting."; exit 1; }
uv python find "$PYTHON_VERSION"
FOUND_PYTHON=$?
if [ $FOUND_PYTHON -ne 0 ]; then
uv python install "$PYTHON_VERSION"
fi
# Run unit tests with coverage
uv run --python "$PYTHON_VERSION" --with-editable . --group unit \
coverage run --source=src/llama_stack -m pytest -s -v tests/unit/ "$@"