Newer
Older
NewLang / env.sh
# SPDX-License-Identifier: LGPL-2.1-only
# Copyright 2022 Jookia <contact@jookia.org>

activate() { . venv/bin/activate; }

die() {
  rm -r venv
  echo "$1"
}

setup() {
  echo "No venv found, creating..."
  if ! python3 -m venv venv ; then die "Unable to create venv"; return; fi
  echo "Activating venv..."
  activate
  echo "Updating pip..."
  if ! pip -q install -U pip ; then die "Unable to update pip"; return; fi
  echo "Installing requirements..."
  if ! pip -q install -r requirements.txt ; then die "Unable to install requirements"; return; fi
  touch venv/.stamp
  echo "All done!"
}
 
if test -e venv/.stamp; then activate; else setup; fi

unset -f activate die setup

resetenv() { rm -r venv; . ./env.sh; }
dotidy() { black src tests build.py; }
dolint() { flake8 src tests build.py; }
dotest() { pytest -q -n auto -x -l --sw --hypothesis-profile=dev $@; }
dotest_dev() { pytest -vv -n 0 -x -l --sw --hypothesis-profile=dev $@; }
dotest_ci() { pytest -q -n auto --hypothesis-profile=ci; }
dotest_long() { pytest -q -n auto --hypothesis-profile=long; }
docheck() { dotidy && dolint && dotest; }
_envsh_domut() { mutmut run --paths-to-mutate "src/token.py,src/tokenize.py,src/parse.py,src/i18n.py" $@; }
domut() { _envsh_domut; }
domut_ci() { _envsh_domut --no-progress || (mutmut results; exit 1); }
dobuild() { python build.py; }