view pretxncommit.sh @ 6:d885fce5e4e7

try to reduce warnings about leaked sessions
author drewp@bigasterisk.com
date Sat, 16 Mar 2024 12:25:20 -0700
parents ddf021c87083
children d98cb018fad7
line wrap: on
line source

#!/bin/zsh -e

# e2e test including lib installs and test suite


echo node = $HG_NODE
SRC_DIR=`pwd`

WORK_DIR=/tmp/rdferry_pretxncommit_$$
mkdir $WORK_DIR

TRAPZERR() {
  rm -r $WORK_DIR
}


# If you're running pretxnsubmit.sh outside of a commit...
if [[ -z $HG_NODE ]]; then
    echo "using src and test code from $SRC_DIR"
    STAGE_DIR=$SRC_DIR
else
    echo "using pre-commit code from -r $HG_NODE"
    STAGE_DIR=$WORK_DIR/stage
    hg clone -r $HG_NODE $SRC_DIR $STAGE_DIR
fi

# TEST_PROJECT depends on rdferry being installed 
# from STAGE_DIR.
TEST_PROJECT_DIR=$WORK_DIR/test_project
mkdir $TEST_PROJECT_DIR
cd $TEST_PROJECT_DIR
pdm config --local venv.in_project True
pdm init --non-interactive
pdm add $STAGE_DIR pytest pytest-asyncio aiohttp
pdm run python -c 'import rdferry; print(f"using {rdferry}")'

# Pretend the example code is test project's code.
cp -a $STAGE_DIR/examples .
pdm run pytest examples

rm -r $WORK_DIR
exit 0