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

Function Activate { .\venv\Scripts\Activate.ps1 }

Function Die {
    Param ( $Message )
    Remove-Item -Recurse venv
    Write-Output $Message
    Exit 1
}

Function Setup {
    Write-Output "No venv found, creating..."
    python -m venv venv || Die "Unable to create venv"
    Write-Output "Activating venv..."
    Activate
    Write-Output "Updating pip..."
    pip -q install -U pip || Die "Unable to update pip"
    Write-Output "Installing requirements..."
    pip -q install -r requirements.txt || Die "Unable to install requirements"
    New-Item venv\.stamp | Out-Null
    Write-Output "All done!"
}

If (Test-Path -Path venv\.stamp) { Activate } Else { Setup }

Function Global:dotidy { black src tests }
Function Global:dolint { flake8 src tests }
Function Global:dotest { pytest -q -n auto --hypothesis-profile=dev }
Function Global:dotest_ci { pytest -q -n auto --hypothesis-profile=ci }
Function Global:dotest_long { pytest -q -n auto --hypothesis-profile=long }
Function Global:docheck { dotidy && dolint && dotest }
Function Global:domut { mutmut run --paths-to-mutate "src/syntax.py src/tokenize.py src/parse.py" }