I have the following function in a shell script:
test_handler(){
FOLDER_NAME=$1
echo "running tests in: ${FOLDER_NAME} package"
cd ${SOURCE_CODE_FOLDER}/${FOLDER_NAME}
pipenv install --dev
#need to run this with pipenv run to get the install dependencies.
pipenv run run-tests
EXIT_CODE=$?
if [ ${EXIT_CODE} != 0 ];then
echo "error, Exit code=${EXIT_CODE} in ${FOLDER_NAME}'s tests." >> /home/logs.txt;
exit 1;
fi;
echo "${FOLDER_NAME}'s tests succeeded." >> /home/logs.txt;
}
The function is working fine. It is called twice in the script with two different folder names, such that each of them has a "test" package with pytests inside.
The line pipenv run run-tests is running the following script:
#!/bin/bash
python3.7 -m pytest -s --cov-append --junitxml=/home/algobot-packer/tests.xml $PWD/tests/
EXIT_CODE=$?
exit ${EXIT_CODE}
Eventually it generates a tests.xml file. The only problem is that the second function call is overriding the first one.
Is there a way to generate one xml file that holds the results of running the tests script twice (appending the results instead of rewriting the file)?
I've tried looking at the docs and pytest --help but couldn't find my answer.