summaryrefslogtreecommitdiffstats
path: root/scripts/test.sh
blob: 51655126a6eb4aeddb95ecf074c7d4d5287eec8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
set -e

PYTHON_VERSION=""

main() {
  parse_args "$@"
  if [ -n "$PYTHON_VERSION" ]; then
    uv python install "$PYTHON_VERSION"
    uv python pin "$PYTHON_VERSION"
  fi
  uv sync --group test
  uv run pytest tests/ --cov=lirc/ -v --cov-report term-missing
}

usage() {
  echo "Usage: $0 [-h|--help] [-p|--python VERSION]"
  echo ""
  echo "Options:"
  echo "  -h, --help    Show this help message and exit"
  echo "  -p, --python  Specific python version to install and use for the test run"
}

parse_args() {
  while [ $# -gt 0 ]; do
    case "$1" in
    -h | --help)
      usage
      exit 0
      ;;
    -p | --python)
      PYTHON_VERSION="$2"
      shift 2
      ;;
    *)
      usage
      exit 1
      ;;
    esac
  done
}

main "$@"