« Auto-éditer un wikilivre/Annexer (Version internationalisée)/src/header.inc.sh » : différence entre les versions

Contenu supprimé Contenu ajouté
Correction du contenu du bandeau
m →‎tests/header.inc/test_header.inc.sh : Ajout de codes pour les tests
Ligne 234 :
</syntaxhighlight>
 
== tests/header.inc/test_headertests_header.inc.shbash ==
;{{orange|Exemple de fichier de commande d'un test dans le répertoire ~/Add_appendix/tests/header.inc/.}}
# <syntaxhighlight lang="bash">
#! /bin/bash
#P file : tests_header.inc.bash
# File test_header.inc.sh in ~/Add_appendix/tests/header.inc/.
#P Syntax ./tests_header.inc.bash
#D
Version=210401
 
VERSION=210519
#O nettoyer l'écran
clear
 
#O Clean screen
#O Initialisation de la variable Workdir
clear
Workdir=~/Add_appendix
 
echo "Espace de travail = $Workdir"
#P Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O Download global variables
#O Vérifier que la syntaxe est respectée :
source $Workdir/vars/installdir.var
echo "Syntax : header.inc [ <book-name> | ? ] [ -v ] [ -pb | -pc ]"
echo "----"
#P Print test_header.inc.bash version
$Workdir/bin/header.inc
echo "Test sans paramètretest-header.inc.bash Code de retourversion = $?VERSION"
sleep 52
#T echo "----"
#P Print command $Workdir/bin/header.inc.sh ?version
#T echo "TestCommand avec le paramètre '?'header.inc.sh Code--v deto retourveriy =header.inc $?version"
sleep./header.inc.sh 5--v
echo;echo "---- wait for 2 sec"
sleep 2; echo "----"
$Workdir/bin/header.inc LivreTestInexistant
echo "Test avec paramètre avec paramètre 'LivreTestInexistant'. Code de retour = $?"
sleep 5
echo "----"
#O Control if the test header.inc.sh file is clean
if [ -d "$Workdir/LivreTest" ]
echo -e "\033[1;33m Control header.inc.sh in the local test directory \033[0m" > text-control.txt
then
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
$Workdir/bin/header.inc LivreTest
echo -e "\033[1;33m ---- \033[0m"
echo "Test avec le paramètre 'LivreTest'. Code de retour = $?"
grep -n -e "#T\|#O\|#P" header.inc.sh >> text-control.txt
else
more text-control.txt
echo "Test avec le paramètre 'LivreTest' :"
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
echo "Le répertoire de projet LivreTest n'est pas trouvé"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
echo "La commande n'a pas été exécutée."
#T fi echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
 
#T test header.inc.sh in test-mode
echo "Command ./header.inc.sh - --t to verify environnement variables"
echo " in test mode with first param empty"
./header.inc.sh - --t
echo;echo " wait for 2 sec"
sleep 5; echo "----"
 
#T test with first param empty
echo "Command ./header.inc.sh without parameter"
./header.inc.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
 
#T Test, all with option --t
echo " All tests whith parameter --t"
#P List fullurl books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./header.inc.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./header.inc.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./header.inc.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./header.inc.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./header.inc.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./header.inc.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./header.inc.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./header.inc.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs
elif [ "$Inkey" = "9" ]; then ./header.inc.sh LivreTest --t
else echo "$inkey full url of site not found"; exit 0
fi
done
#O End tests_header.inc.bash
</syntaxhighlight>
 
== List to tests header.inc ==
sitelist.sh
<syntaxhighlight lang="bash">
#!/bin/bash
#H File sitelist to test with 'test_preannex.bash in preannex.sh tests directory
#H Application for source ~/Add_appendix/datas/sitelist in 'test_preannex.bash'
#H or ./sitelist in datas directory in executable mode
#H Create 14/05/2021 by GC
#H Updated 16/05/2021 by GC
#P Make sitelist.txt : ./sitelist > sitelist.txt in datas directory
#
echo "sitelist to test annex programs"
echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo " 1 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t"
echo " 2 - https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t"
echo " 3 - https://en.wikibooks.org/wiki/User:Goelette_Cardabela/sandbox/TestBook/Content --t"
echo " 4 - https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t"
# echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo -e "\033[47m \033[1;32m Collections \033[0m"
echo " 5 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t"
echo -e "\033[1;31m Same book second title \033[0m"
echo " 6 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t"
echo " 7 - https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t"
echo " 8 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacit%C3%A9_des_batteries_d%27accumulateurs"
echo " 9 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t"
# echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo -e "\033[47m \033[1;32m Atypical variants \033[0m"
echo -e "\033[1;31m Copy the line (Ctrl-Shift-C) and execute in terminal (Ctrl-Shift-V) \033[0m"
echo " xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé"
echo " xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé&action=edit"
</syntaxhighlight>
=== text list for test ===
#{{AutoCat}}
Sitelist.txt
<pre>
sitelist to test annex programs
�[47m �[1;32m Books with Contents or Summary �[0m
1 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t
2 - https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t
3 - https://en.wikibooks.org/wiki/User:Goelette_Cardabela/sandbox/TestBook/Content --t
4 - https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t
�[47m �[1;32m Collections �[0m
5 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t
�[1;31m Same book second title �[0m
6 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t
7 - https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t
8 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacit%C3%A9_des_batteries_d%27accumulateurs
9 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t
�[47m �[1;32m Atypical variants �[0m
�[1;31m Copy the line (Ctrl-Shift-C) and execute in terminal (Ctrl-Shift-V) �[0m
xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé
xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé&action=edit
</pre>
{{AutoCat}}