mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-04-26 10:52:09 +08:00
65 lines
1.6 KiB
Text
65 lines
1.6 KiB
Text
# shell library to help executing tests
|
|
|
|
if [ -z "$TERM" ] ; then
|
|
export TERM=xterm-256color
|
|
fi
|
|
|
|
check() {
|
|
RET=$?
|
|
if [ $RET -ne 0 ] ; then
|
|
exit $RET
|
|
fi
|
|
}
|
|
|
|
run_coverage() {
|
|
python -m coverage run --source . --append "$@"
|
|
}
|
|
|
|
get_mysql_args() {
|
|
args="--host=$CI_DB_HOST --user=root"
|
|
if [ -n "$CI_DB_PORT" ] ; then
|
|
args="$args --port=$CI_DB_PORT"
|
|
fi
|
|
echo $args
|
|
}
|
|
|
|
cleanup_database() {
|
|
rm -f weblate.db
|
|
|
|
if [ $CI_DATABASE = "mysql" -o $CI_DATABASE = 'mariadb' ] ; then
|
|
if [ -n "$CI_DB_PASSWORD" ] ; then
|
|
export MYSQL_PWD="$CI_DB_PASSWORD"
|
|
fi
|
|
mysql $(get_mysql_args) -e 'SET GLOBAL character_set_server=utf8mb4'
|
|
mysql $(get_mysql_args) -e 'SET GLOBAL collation_server=utf8mb4_general_ci'
|
|
mysql $(get_mysql_args) -e 'DROP DATABASE IF EXISTS weblate;'
|
|
mysql $(get_mysql_args) -e 'CREATE DATABASE weblate CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;'
|
|
fi
|
|
|
|
if [ $CI_DATABASE = "postgresql" ] ; then
|
|
if [ -n "$CI_DB_PASSWORD" ] ; then
|
|
export PGPASSWORD="$CI_DB_PASSWORD"
|
|
fi
|
|
if [ -n "$CI_DB_PORT" ] ; then
|
|
export PGPORT="$CI_DB_PORT"
|
|
fi
|
|
psql --host=$CI_DB_HOST -c 'DROP DATABASE IF EXISTS weblate;' -U postgres
|
|
psql --host=$CI_DB_HOST -c 'CREATE DATABASE weblate;' -U postgres
|
|
fi
|
|
}
|
|
|
|
print_step() {
|
|
tput setaf 2
|
|
echo "$@"
|
|
tput sgr0
|
|
}
|
|
|
|
print_version() {
|
|
for cmd in "$@" ; do
|
|
if command -v $cmd ; then
|
|
$cmd --version
|
|
return
|
|
fi
|
|
done
|
|
echo "not found..."
|
|
}
|