Skip to content

Commit

Permalink
Fix test_installed_version to work in the mypy_mypyc CI (#5955)
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan authored Nov 27, 2018
1 parent 6402851 commit 783297c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions misc/test_installed_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,34 @@
# it annoying to test an installed version of mypy. If somebody has a
# better way please let me know.

function abspath {
python3 -c "import os.path; print(os.path.abspath('$1'))"
}

TO_INSTALL="${1-.}"
PYTHON="${2-python3}"
VENV="$(mktemp -d -t mypy-test-venv.XXXXXXXXXX)"
trap "rm -rf '$VENV'" EXIT

"$PYTHON" -m venv "$VENV"
"$PYTHON" -m virtualenv "$VENV"
source "$VENV/bin/activate"

pip install -r test-requirements.txt
ROOT="$PWD"
TO_INSTALL="$(abspath "$TO_INSTALL")"

# Change directory so we can't pick up any of the stuff in the root.
# We need to do this before installing things too because I was having
# the current mypy directory getting picked up as satisfying the
# requirement (argh!)
cd "$VENV"

pip install -r "$ROOT/test-requirements.txt"
pip install $TO_INSTALL

# pytest looks for configuration files in the parent directories of
# where the tests live. Since we are trying to run the tests from
# their installed location, we copy those into the venv. Ew ew ew.
cp pytest.ini conftest.py "$VENV/"

ROOT="$PWD"

# Change directory so we can't pick up any of the stuff in the root
cd "$VENV"
cp "$ROOT/pytest.ini" "$ROOT/conftest.py" "$VENV/"

# Find the directory that mypy tests were installed into
MYPY_TEST_DIR="$(python3 -c 'import mypy.test; print(mypy.test.__path__[0])')"
Expand Down

0 comments on commit 783297c

Please sign in to comment.