Add arg --interrup

This commit is contained in:
Maniack Crudelis 2017-03-13 17:32:34 +01:00
parent 3b0fcbbfe2
commit d34e16fbbf
2 changed files with 24 additions and 12 deletions

View file

@ -147,10 +147,11 @@ Il est à noter que les niveaux 4, 8, 9 et 10 ne peuvent être fixés à *auto*
Le script `package_check.sh` accepte 6 arguments en plus du package à tester. Le script `package_check.sh` accepte 6 arguments en plus du package à tester.
- `--bash-mode`: Rend le script autonome. Aucune intervention de l'utilisateur ne sera nécessaire. - `--bash-mode`: Rend le script autonome. Aucune intervention de l'utilisateur ne sera nécessaire.
La valeur de auto_remove est ignorée. La valeur de auto_remove est ignorée.
- `--no-lxc`: N'utilise pas la virtualisation en conteneur LXC. Les tests seront effectué directement sur la machine hôte. - `--branch=nom-de-branche`: Teste une branche du dépôt plutôt que de tester master. Permet de tester les pull request.
- `--build-lxc`: Installe LXC et créer le conteneur debian Yunohost si nécessaire. - `--build-lxc`: Installe LXC et créer le conteneur debian Yunohost si nécessaire.
- `--force-install-ok`: Force la réussite des installations, même si elles échouent. Permet d'effectuer les tests qui suivent même si l'installation a échouée. - `--force-install-ok`: Force la réussite des installations, même si elles échouent. Permet d'effectuer les tests qui suivent même si l'installation a échouée.
- `--branch=nom-de-branche`: Teste une branche du dépôt plutôt que de tester master. Permet de tester les pull request. - `--interrupt`: Force l'option auto_remove à 0, le script marquera une pause avant chaque suppression d'application.
- `--no-lxc`: N'utilise pas la virtualisation en conteneur LXC. Les tests seront effectué directement sur la machine hôte.
- `--help`: Affiche l'aide du script - `--help`: Affiche l'aide du script
--- ---
@ -307,10 +308,11 @@ The level 4, 8, 9 and 10 shouldn't be fixed at *auto*, because they don't be tes
The `package_check.sh` script accept 6 arguments in addition of package to be checked. The `package_check.sh` script accept 6 arguments in addition of package to be checked.
- `--bash-mode`: The script will work without user intervention. - `--bash-mode`: The script will work without user intervention.
auto_remove value is ignored auto_remove value is ignored
- `--no-lxc`: Not use virtualization with LXC container. All tests will perform directly on the hosts machine. - `--branch=branch-name`: Check a branch of the repository instead of master. Allow to check a pull request.
- `--build-lxc`: Install LXC and create the Debian Yunohost container if necessary. - `--build-lxc`: Install LXC and create the Debian Yunohost container if necessary.
- `--force-install-ok`: Force success of installation, even if they fail. Allow to perform following tests even if installation fail. - `--force-install-ok`: Force success of installation, even if they fail. Allow to perform following tests even if installation fail.
- `--branch=branch-name`: Check a branch of the repository instead of master. Allow to check a pull request. - `--interrupt`: Force auto_remove value, break before each remove.
- `--no-lxc`: Not use virtualization with LXC container. All tests will perform directly on the hosts machine.
- `--help`: Display help. - `--help`: Display help.
--- ---

View file

@ -2,10 +2,11 @@
# Arguments du script # Arguments du script
# --bash-mode Mode bash, le script est autonome. Il ignore la valeur de $auto_remove # --bash-mode Mode bash, le script est autonome. Il ignore la valeur de $auto_remove
# --no-lxc N'utilise pas la virtualisation en conteneur lxc. La virtualisation est utilisée par défaut si disponible.
# --build-lxc Installe lxc et créer la machine si nécessaire. # --build-lxc Installe lxc et créer la machine si nécessaire.
# --force-install-ok Force la réussite des installations, même si elles échouent. Permet d'effectuer les tests qui suivent même si l'installation a échouée.
# --branch=nom-de-la-branche Teste une branche du dépôt, plutôt que tester master # --branch=nom-de-la-branche Teste une branche du dépôt, plutôt que tester master
# --force-install-ok Force la réussite des installations, même si elles échouent. Permet d'effectuer les tests qui suivent même si l'installation a échouée.
# --interrupt Force l'option auto_remove à 0.
# --no-lxc N'utilise pas la virtualisation en conteneur lxc. La virtualisation est utilisée par défaut si disponible.
# --help Affiche l'aide du script # --help Affiche l'aide du script
echo "" echo ""
@ -28,6 +29,8 @@ build_lxc=$(echo "$*" | grep -c -e "--build-lxc") # build_lxc vaut 1 si l'argume
force_install_ok=$(echo "$*" | grep -c -e "--force-install-ok") # force-install-ok vaut 1 si l'argument est présent. force_install_ok=$(echo "$*" | grep -c -e "--force-install-ok") # force-install-ok vaut 1 si l'argument est présent.
# --branch= # --branch=
gitbranch=$(echo "$*" | grep -e "--branch") # gitbranch prend l'ensemble des arguments à partir de --branch gitbranch=$(echo "$*" | grep -e "--branch") # gitbranch prend l'ensemble des arguments à partir de --branch
# --interrupt
interrupt=$(echo "$*" | grep -c -e "--interrupt") # interrupt vaut 1 si l'argument est présent.
if test -n "$gitbranch"; then if test -n "$gitbranch"; then
if ! echo "$gitbranch" | grep -q "branch=[[:alnum:]]"; then if ! echo "$gitbranch" | grep -q "branch=[[:alnum:]]"; then
notice=1 # Renvoi vers l'aide si la syntaxe est incorrecte notice=1 # Renvoi vers l'aide si la syntaxe est incorrecte
@ -39,17 +42,18 @@ fi
if [ "$notice" -eq 0 ]; then if [ "$notice" -eq 0 ]; then
notice=$(echo "$*" | grep -c -e "--help") # notice vaut 1 si l'argument est présent. Il affichera alors l'aide. notice=$(echo "$*" | grep -c -e "--help") # notice vaut 1 si l'argument est présent. Il affichera alors l'aide.
fi fi
arg_app=$(echo "$*" | sed 's/--bash-mode\|--no-lxc\|--build-lxc\|--force-install-ok\|--branch=[[:alnum:]-]*//g' | sed 's/^ *\| *$//g') # Supprime les arguments déjà lu pour ne garder que l'app. Et supprime les espaces au début et à la fin arg_app=$(echo "$*" | sed 's/--bash-mode\|--no-lxc\|--build-lxc\|--force-install-ok\|--interrupt\|--branch=[[:alnum:]-]*//g' | sed 's/^ *\| *$//g') # Supprime les arguments déjà lu pour ne garder que l'app. Et supprime les espaces au début et à la fin
# echo "arg_app=$arg_app." # echo "arg_app=$arg_app."
if [ "$notice" -eq 1 ]; then if [ "$notice" -eq 1 ]; then
echo -e "\nUsage:" echo -e "\nUsage:"
echo "package_check.sh [--bash-mode] [--no-lxc] [--build-lxc] [--force-install-ok] [--help] [--branch=] \"package to check\"" echo "package_check.sh [--bash-mode] [--branch=] [--build-lxc] [--force-install-ok] [--no-lxc] [--help] \"package to check\""
echo -e "\n\t--bash-mode\t\tDo not ask for continue check. Ignore auto_remove." echo -e "\n\t--bash-mode\t\tDo not ask for continue check. Ignore auto_remove."
echo -e "\t--no-lxc\t\tDo not use a LXC container. You should use this option only on a test environnement." echo -e "\t--branch=branch-name\tSpecify a branch to check."
echo -e "\t--build-lxc\t\tInstall LXC and build the container if necessary." echo -e "\t--build-lxc\t\tInstall LXC and build the container if necessary."
echo -e "\t--force-install-ok\tForce following test even if all install are failed." echo -e "\t--force-install-ok\tForce following test even if all install are failed."
echo -e "\t--branch=branch-name\tSpecify a branch to check." echo -e "\t--interrupt\tForce auto_remove value, break before each remove."
echo -e "\t--no-lxc\t\tDo not use a LXC container. You should use this option only on a test environnement."
echo -e "\t--help\t\t\tDisplay this notice." echo -e "\t--help\t\t\tDisplay this notice."
exit 0 exit 0
fi fi
@ -605,7 +609,11 @@ INIT_VAR() {
IN_PROCESS=0 IN_PROCESS=0
MANIFEST=0 MANIFEST=0
CHECKS=0 CHECKS=0
if [ $interrupt -eq 1 ]; then
auto_remove=0
else
auto_remove=1 auto_remove=1
fi
install_pass=0 install_pass=0
note=0 note=0
tnote=0 tnote=0
@ -690,8 +698,10 @@ then # Si le fichier check_process est trouvé
continue continue
fi fi
if echo "$LIGNE" | grep -q "^auto_remove="; then # Indication d'auto remove if echo "$LIGNE" | grep -q "^auto_remove="; then # Indication d'auto remove
if [ $interrupt -eq 0 ]; then # Si interrupt est à 1, la valeur du check_process est ignorée.
auto_remove=$(echo "$LIGNE" | cut -d '=' -f2) auto_remove=$(echo "$LIGNE" | cut -d '=' -f2)
fi fi
fi
if echo "$LIGNE" | grep -q "^;;" && ! echo "$LIGNE" | grep -q "^;;;"; then # Début d'un scénario de test if echo "$LIGNE" | grep -q "^;;" && ! echo "$LIGNE" | grep -q "^;;;"; then # Début d'un scénario de test
if [ "$IN_PROCESS" -eq 1 ]; then # Un scénario est déjà en cours. Donc on a atteind la fin du scénario. if [ "$IN_PROCESS" -eq 1 ]; then # Un scénario est déjà en cours. Donc on a atteind la fin du scénario.
TESTING_PROCESS TESTING_PROCESS