# SPDX-License-Identifier: LGPL-2.1-only # Copyright 2022 Jookia <contact@jookia.org> # Set up UTF-8 support for PowerShell pipes [System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8; $env:PYTHONIOENCODING = "utf-8"; 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..." python -m pip -q install -U pip || Die "Unable to update pip" Write-Output "Installing requirements..." python -m 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 } # NOTE: PowerShell functions always return success even if the commands inside # failed. This makes it infeasible to do proper error checking. # See https://github.com/PowerShell/PowerShell/issues/12218 Function Global:dotidy { black src tests build.py } Function Global:dolint { flake8 src tests build.py } Function Global:dotest { pytest -q -n auto -x -l --sw --hypothesis-profile=dev $args } Function Global:dotest_dev { pytest -vv -n 0 -x -l --sw --hypothesis-profile=dev $args } 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:_envps1_domut { mutmut run --paths-to-mutate "src/token.py,src/tokenize.py,src/parse.py" $args } Function Global:domut { _envps1_domut } Function Global:domut_ci { _envps1_domut --no-progress || mutmut results } Function Global:dobuild { python build.py }