Something went wrong on our end
-
Vincent Hatakeyama authored
Bump version: 21.15.0 → 21.15.1
Vincent Hatakeyama authoredBump version: 21.15.0 → 21.15.1
run_tests 3.01 KiB
#!/bin/zsh
# vim: set shiftwidth=4 softtabstop=4:
#
# This script is used to run tests on a database with demo data installed.
#
# Either provide the name of the database (first argument) or it will default to <project>_test
# The DB user can be overridden by setting ODOO_SCRIPTS_DB_USER.
# The environment variable “odoo_scripts_run_tests_logfile” can be set to be used to include the output of the tests
#
# COVERAGE_SOURCE can be set to indicate modules or path to check coverage of.
# See https://coverage.readthedocs.io/en/7.6.4/source.html
# If set to empty, no source is given to coverage. (changed in 21.15.1, previous versions considered empty as unset)
# If not set, compute the value from the tested modules
#
# Version 21.15.1
here=$(dirname $0)
source $here/odoo_scripts_common
tested_modules=${ODOO_SCRIPTS_MODULE_LIST_TESTS-$(read_odoo_scripts_expandable_configuration_key module_list_tests)}
if [[ "$tested_modules" != "" ]];
then
update="-i $tested_modules"
if [[ -v COVERAGE_SOURCE ]];
then
# Source already set
else
if type python3 > /dev/null;
then
COVERAGE_SOURCE="$(python3 -B -c "print(f','.join(f'odoo.addons.{name}' for name in '$tested_modules'.split(',')))")"
else
COVERAGE_SOURCE="$(python2 -B -c "print(','.join('odoo.addons.{}'.format(name) for name in '$tested_modules'.split(',')))")"
fi
fi
fi
dbname=$1
if [[ -z "$dbname" ]];
then
dbname=$(basename $(readlink -f $project_home))_test
else
shift
fi
echo "$INFO Using database $dbname for tests"
if [[ -n "$ODOO_SCRIPTS_DB_USER" ]]
then
echo "$INFO Using db user $ODOO_SCRIPTS_DB_USER"
db_user_param="--db_user $ODOO_SCRIPTS_DB_USER"
fi
if [ "$ODOO_TYPE" = "odoo8" ];
then
loglevel="--log-level=info"
else
loglevel="--log-level=test"
fi
if [[ -z "$odoo_scripts_run_tests_logfile" ]];
then
logfile=$(mktemp --suffix=.log)
function clean_logfile() {
rm $logfile
}
trap clean_logfile INT TERM
else
logfile=$odoo_scripts_run_tests_logfile
fi
if [[ -v COVERAGE_SOURCE ]];
then
if [[ -z "$COVERAGE_SOURCE" ]];
then
__coverage_source_command=""
else
__coverage_source_command="--source=$COVERAGE_SOURCE"
fi
else
__coverage_source_command="--source=$project_home"
fi
if [ "$ODOO_TYPE" = "odoo7" ] || [ "$ODOO_TYPE" = "odoo8" ] || [ "$ODOO_TYPE" = "odoo9" ] || [ "$ODOO_TYPE" = "odoo10" ] ;
then
# no coverage in those old versions
else
export PRE_ODOO_BIN="coverage run --omit='**/__manifest__.py' $__coverage_source_command --branch "
fi
# Catch both stdout & stderr here as Odoo 10 uses stderr, unlike previous Odoo versions.
env odoo_scripts_start_logfile=$logfile $here/start $update -d $dbname $db_user_param --test-enable $loglevel --max-cron=0 --workers=0 --stop-after-init $* 2>&1 | colorize
start_status=$pipestatus[1]
analyze $logfile && return_code=0 || return_code=$?
echo ''
if [[ $start_status -ne 0 ]];
then
echo "$FATAL Tests failed (exit ${start_status})"
exit $start_status
fi
exit $return_code