Mentions légales du service

Skip to content
Snippets Groups Projects
Commit fa70918b authored by hhakim's avatar hhakim
Browse files

Externalize pyfaust_test_code_coverage ci job into pyfaust_coverage.sh script...

Externalize pyfaust_test_code_coverage ci job into pyfaust_coverage.sh script + run more tests (more dtypes and GPU tests if CUDA available).
parent c2244f90
Branches
Tags
No related merge requests found
Pipeline #851480 passed
...@@ -243,27 +243,7 @@ pyfaust_test_code_coverage: ...@@ -243,27 +243,7 @@ pyfaust_test_code_coverage:
stage: code_cov stage: code_cov
coverage: '/Coverage:.*\%/' coverage: '/Coverage:.*\%/'
script: script:
# use conda rather than venv because python built on VM has not been - misc/continuous_integration/jobs/linux/pyfaust_coverage.sh
# built with --enable-loadable-sqlite-extensions (and sqlite-devel)
# but it is a need of coverave python package
# so we use py3.10 from conda
- cmake -P misc/download_unzip_faust_misc_data.cmake # tests need data
- conda create -n test_coverage_pyfaust python==3.10
- conda activate test_coverage_pyfaust
# install pyfaust with pip
- pip install $(find ./ -name "*pyfaust*whl")
- conda install -c conda-forge -y coverage
- coverage erase # just in case
- 'PYFAUST_DIR=$(dirname $(python -c "import pyfaust as pf; print(pf.__file__)"))'
- coverage run --source $PYFAUST_DIR misc/test/src/Python/test_FaustPy.py
- coverage run -a --source $PYFAUST_DIR $PYFAUST_DIR/tests/run.py
# take doctest into account
- for MOD in factparams proj poly tools fact demo;do PY=$(python -c "import doctest;import pyfaust as pf;from os.path import dirname;fn = dirname(pf.__file__)+'/${MOD}.py';print(fn)"); echo -e '\nif __name__ == "__main__":\n import doctest;\n doctest.testmod()' >> $PY;done
- for MOD in factparams proj poly tools fact demo;do coverage run -a --source $PYFAUST_DIR $PYFAUST_DIR/$MOD.py;done
- coverage report $(find $PYFAUST_DIR -name "*.py" | grep -v -w tests) | tee /tmp/pyfaust_cov_report
- 'echo Coverage: $(tail -1 /tmp/pyfaust_cov_report | awk "{print \$4}")'
- coverage html $(find $PYFAUST_DIR -name "*.py" | grep -v -w tests)
- conda deactivate
after_script: after_script:
- conda-env remove -n test_coverage_pyfaust - conda-env remove -n test_coverage_pyfaust
except: except:
......
#!/usr/bin/env bash
# This script outputs a test coverage report for pyfaust
#set -euo pipefail
#[[ -z "$NUX_PY_VER" ]] && echo "I need NUX_PY_VER variable to be set" && exit 1
cmake -P $(dirname $0)/../../../../misc/download_unzip_faust_misc_data.cmake # tests need data
# use conda rather than venv because python built on VM has not been
# built with --enable-loadable-sqlite-extensions (and sqlite-devel)
# but it is a need of coverave python package
# so we use py3.10 from conda
CONDA_ENV=test_coverage_pyfaust
conda create -y -n $CONDA_ENV python==3.10 # using py3.10 and not 3.11 because pkg_linux_purepy_rev generates py3.10 whl pkg (cf. .gitlab-ci.yml)
#conda activate test_coverage_pyfaust
shopt -s expand_aliases
# ease execution of command in $CONDA_ENV
alias CE="conda run -n $CONDA_ENV"
# install pyfaust with pip
if [[ $# -ge 1 ]]
then
[[ ! "$1" =~ ^.*/?pyfaust.*whl$ ]] && echo "First arg. must be a filepath of a pyfaust whl package" >&2 && exit 1
CE pip install $1
else
CE pip install $(find ./ -name "*pyfaust*whl")
fi
CE conda install -c conda-forge -y coverage
CE coverage erase # just in case
PYFAUST_DIR=$(dirname $(CE python -c "import pyfaust as pf; print(pf.__file__)"))
CE coverage run --source $PYFAUST_DIR misc/test/src/Python/test_FaustPy.py
#coverage run -a --source $PYFAUST_DIR $PYFAUST_DIR/tests/run.py # only real and cpu, all tests are ran below
# take doctest into account
for MOD in factparams proj poly tools fact demo;do PY=$(CE python -c "import doctest;import pyfaust as pf;from os.path import dirname;fn = dirname(pf.__file__)+'/${MOD}.py';print(fn)"); echo -e '\nif __name__ == "__main__":\n import doctest;\n doctest.testmod()' >> $PY;done
for MOD in factparams proj poly tools fact demo;do CE coverage run -a --source $PYFAUST_DIR $PYFAUST_DIR/$MOD.py;done
echo > test_mod.py
for T in real complex float32
do
echo "import pyfaust.tests; pyfaust.tests.run_tests('cpu', '"$T"')" >> test_mod.py
if echo $CI_RUNNER_TAGS | grep -w cuda
then
echo "import pyfaust.tests; pyfaust.tests.run_tests('gpu', '"$T"')" >> test_mod.py
fi
done
CE coverage run -a --source $PYFAUST_DIR test_mod.py
CE coverage report $(find $PYFAUST_DIR -name "*.py" | grep -v -w tests) | tee /tmp/pyfaust_cov_report
COV=$(sed -e '/^$/d' /tmp/pyfaust_cov_report | tail -1 | sed -e 's/.*\s\+//')
[[ ! $COV =~ ^[[:digit:]]+%$ ]] && echo "Failed to get total coverage" && exit 2
echo Coverage: $COV
CE coverage html $(find $PYFAUST_DIR -name "*.py" | grep -v -w tests)
#conda deactivate
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment