Commit 5d954996 authored by Christian BUFFIN's avatar Christian BUFFIN
Browse files

Amélioration deu script cake_utils.sh pour permettre de filtrer les cas de...

Amélioration deu script cake_utils.sh pour permettre de filtrer les cas de test unitaires et de ne générer la couverture de code qu'à la demande.
parent 666aeb7c
......@@ -71,9 +71,13 @@ trap "__trap_exit__" EXIT
# ----------------------------------------------------------------------------------------------------------------------
__APP__="${__ROOT__}/app"
__COVERAGE__=0
__FILTER__=""
__PLUGIN__CAKETEST__="${__APP__}/Plugin/CakeTest"
__TMP__="${__APP__}/tmp"
__OUT__="${__TMP__}/out"
__REPORT__=0
__SESSIONS__="/var/lib/php/sessions"
# Usage function
......@@ -99,6 +103,9 @@ __usage__()
printf " tests\t\tNettoie le cache (commande clear) et effectue les tests unitaires\n"
printf "\nOPTIONS\n"
printf " -h\tAffiche cette aide\n"
printf " --coverage\tGénère les fichiers de rapport de couverture de code pour les tests unitaires PHPUnit.\n"
printf " --filter\tOption filter passée aux tests unitaires PHPUnit.\n"
printf " --report\tGénère le fichier de rapport XML xUnit pour les tests unitaires PHPUnit.\n"
printf " -x|--xtrace\tMode debug, affiche chaque commande avant de l'exécuter (set -o xtrace)\n"
printf "\nEXEMPLES\n"
printf " %s -h\n" "$__SCRIPT__"
......@@ -177,18 +184,33 @@ tests()
local file="${2}"
local dest="${__OUT__}/phpunit/${category}"
if [ ${__COVERAGE__} -eq 1 ] ; then
__COVERAGE__="--coverage-clover ${dest}/phpunit.coverage.xml --coverage-html ${dest}/coverage/"
else
__COVERAGE__=""
fi
if [ ${__REPORT__} -eq 1 ] ; then
__REPORT__="--log-junit ${dest}/phpunit.xml"
else
__REPORT__=""
fi
rm -rf "${dest}" \
&& mkdir -p "${dest}" \
&& touch "${dest}/empty" \
&& chmod -R g+rw,a+rw "${dest}" \
&& mkdir -p "${__SESSIONS__}" \
&& touch "${__SESSIONS__}/sess_00000000000000000000000000" \
&& chown -R www-data: "${__SESSIONS__}" \
&& "`cake2_dir`/Console/cake" \
test ${category} ${file} \
-app app \
--configuration "${__ROOT__}/phpunit.xml" \
--coverage-clover "${dest}/phpunit.coverage.xml" \
--coverage-html "${dest}/coverage/" \
${__COVERAGE__} \
--debug \
--log-junit "${dest}/phpunit.xml" \
${__FILTER__} \
${__REPORT__} \
--stderr \
--strict \
--verbose
......@@ -323,14 +345,27 @@ pre_commit()
__main__()
{
(
opts=`getopt --longoptions help,xtrace -- hx "$@"` || ( >&2 __usage__ ; exit 1 )
opts=`getopt --longoptions coverage,filter:,help,report,xtrace -- hx "$@"` || ( >&2 __usage__ ; exit 1 )
eval set -- "$opts"
while true ; do
case "$1" in
--coverage)
__COVERAGE__=1
shift
;;
-h|--help)
__usage__
exit 0
;;
--filter)
__FILTER__="${__FILTER__} --filter ${2}"
echo "${__FILTER__}"
shift 2
;;
--report)
__REPORT__=1
shift
;;
-x|--xtrace)
shift
;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment