Run tests as regular user

For this to work, we run the smoke test from a temporary directory,
on the CI /var/str/smoke is not writable by non-root.
This commit is contained in:
Miro Hrončok 2022-06-09 11:43:20 +02:00
commit 18de9ca2b3
2 changed files with 27 additions and 19 deletions

View file

@ -11,8 +11,9 @@ TOX=${TOX:-true}
CYTHON=${CYTHON:-true} CYTHON=${CYTHON:-true}
INSTALL_OR_SKIP=${INSTALL_OR_SKIP:-false} INSTALL_OR_SKIP=${INSTALL_OR_SKIP:-false}
# clean from possible older runs # Work from a custom directory
rm -rf venv .tox __pycache__ .pytest* test_*.py *.pyx *.c *.so ensurepiptestroot || : workdir="$(mktemp --directory)"
cd "$workdir"
if [ "$INSTALL_OR_SKIP" == "true" ] && [ ! -f "/usr/bin/$PYTHON" ]; then if [ "$INSTALL_OR_SKIP" == "true" ] && [ ! -f "/usr/bin/$PYTHON" ]; then
dnf -y install "/usr/bin/$PYTHON" || : dnf -y install "/usr/bin/$PYTHON" || :
@ -130,3 +131,7 @@ EOF
# A more complex example with pytest # A more complex example with pytest
tox tox
# Clean up if everything else went well
cd -
rm -rf "$workdir"

View file

@ -6,6 +6,8 @@
- dnf: - dnf:
name: "*" name: "*"
state: latest state: latest
- ansible.builtin.user:
name: testuser
- hosts: localhost - hosts: localhost
roles: roles:
@ -15,56 +17,57 @@
tests: tests:
- smoke_default: - smoke_default:
dir: smoke dir: smoke
run: ./venv.sh run: runuser testuser -c './venv.sh'
- smoke27: - smoke27:
dir: smoke dir: smoke
run: VERSION=2.7 METHOD=virtualenv ./venv.sh run: runuser testuser -c 'VERSION=2.7 METHOD=virtualenv ./venv.sh'
- smoke27_seeder_pip: - smoke27_seeder_pip:
dir: smoke dir: smoke
run: VERSION=2.7 METHOD=virtualenv-seeder-pip ./venv.sh run: runuser testuser -c 'VERSION=2.7 METHOD=virtualenv-seeder-pip ./venv.sh'
- smoke35: - smoke35:
dir: smoke dir: smoke
run: VERSION=3.5 METHOD=virtualenv-no-download INSTALL_OR_SKIP=true ./venv.sh run: runuser testuser -c 'VERSION=3.5 METHOD=virtualenv-no-download INSTALL_OR_SKIP=true ./venv.sh'
- smoke36: - smoke36:
dir: smoke dir: smoke
run: VERSION=3.6 METHOD=venv TOX=false ./venv.sh run: runuser testuser -c 'VERSION=3.6 METHOD=venv TOX=false ./venv.sh'
- smoke37: - smoke37:
dir: smoke dir: smoke
run: VERSION=3.7 METHOD=venv ./venv.sh run: runuser testuser -c 'VERSION=3.7 METHOD=venv ./venv.sh'
- smoke38: - smoke38:
dir: smoke dir: smoke
run: VERSION=3.8 METHOD=venv ./venv.sh run: runuser testuser -c 'VERSION=3.8 METHOD=venv ./venv.sh'
- smoke39: - smoke39:
dir: smoke dir: smoke
run: VERSION=3.9 METHOD=venv ./venv.sh run: runuser testuser -c 'VERSION=3.9 METHOD=venv ./venv.sh'
- smoke311: - smoke311:
dir: smoke dir: smoke
run: VERSION=3.11 METHOD=venv CYTHON=false ./venv.sh run: runuser testuser -c 'VERSION=3.11 METHOD=venv CYTHON=false ./venv.sh'
- smoke39_seeder_pip: - smoke39_seeder_pip:
dir: smoke dir: smoke
run: VERSION=3.9 METHOD=virtualenv-seeder-pip ./venv.sh run: runuser testuser -c 'VERSION=3.9 METHOD=virtualenv-seeder-pip ./venv.sh'
- smoke34_optional: - smoke34_optional:
dir: smoke dir: smoke
run: VERSION=3.4 METHOD=venv INSTALL_OR_SKIP=true ./venv.sh run: runuser testuser -c 'VERSION=3.4 METHOD=venv INSTALL_OR_SKIP=true ./venv.sh'
- smokepypy: - smokepypy:
dir: smoke dir: smoke
run: VERSION=2.7 METHOD=virtualenv PYTHON=pypy ./venv.sh run: runuser testuser -c 'VERSION=2.7 METHOD=virtualenv PYTHON=pypy ./venv.sh'
- smokepypy38: - smokepypy38:
dir: smoke dir: smoke
run: VERSION=3.8 METHOD=venv PYTHON=pypy3.8 ./venv.sh run: runuser testuser -c 'VERSION=3.8 METHOD=venv PYTHON=pypy3.8 ./venv.sh'
- selftest37: - selftest37:
dir: selftest dir: selftest
run: VERSION=3.7 X="-x test_socket -x test_asyncgen -x test_asyncio -x test_compile -x test_concurrent_futures -x test_itertools -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_shutil -x test_time -x test_multiprocessing_spawn -x test_threading -x test_wsgiref" ./parallel.sh run: runuser testuser -c 'VERSION=3.7 X="-x test_socket -x test_asyncgen -x test_asyncio -x test_compile -x test_concurrent_futures -x test_itertools -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_shutil -x test_time -x test_multiprocessing_spawn -x test_threading -x test_wsgiref" ./parallel.sh'
- debugtest38: - debugtest38:
dir: selftest dir: selftest
run: VERSION=3.8 PYTHON="python3-debug" X="test_ssl" ./parallel.sh run: runuser testuser -c 'VERSION=3.8 PYTHON="python3-debug" X="test_ssl" ./parallel.sh'
- debugflags: - debugflags:
dir: flags dir: flags
run: python3-debug ./assertflags.py -O0 run: runuser testuser -c 'python3-debug ./assertflags.py -O0'
- marshalparser_compatibility: - marshalparser_compatibility:
dir: marshalparser dir: marshalparser
run: SAMPLE=10 test_marshalparser_compatibility.sh run: runuser testuser -c 'SAMPLE=10 test_marshalparser_compatibility.sh'
required_packages: required_packages:
- util-linux # for runuser
- dnf - dnf
- gcc - gcc
- gcc-c++ - gcc-c++