tests 0 et 1 ok
This commit is contained in:
parent
15d3ceb7f0
commit
6833b80658
@ -34,10 +34,8 @@ cloning_check(){
|
|||||||
if [ -d "./$REPO_NAME" ]; then
|
if [ -d "./$REPO_NAME" ]; then
|
||||||
echo "$REPO_NAME has been created"
|
echo "$REPO_NAME has been created"
|
||||||
cloning_result=0
|
cloning_result=0
|
||||||
local FILENAMES=("$@")
|
local FILENAMES=$@
|
||||||
echo "--$1--"
|
for FILE in ${FILENAMES[@]}
|
||||||
echo "------------ $FILENAMES -----------------"
|
|
||||||
for FILE in "${FILENAMES[@]}"
|
|
||||||
do
|
do
|
||||||
if [ -f "./$REPO_NAME/$FILE" ]; then
|
if [ -f "./$REPO_NAME/$FILE" ]; then
|
||||||
echo "the file $FILE has correctly been imported"
|
echo "the file $FILE has correctly been imported"
|
||||||
@ -71,9 +69,11 @@ tag_check(){
|
|||||||
run cd $REPO_NAME
|
run cd $REPO_NAME
|
||||||
run git branch > res
|
run git branch > res
|
||||||
if [ $(grep "no branch" res | wc -l) = 1 ];then
|
if [ $(grep "no branch" res | wc -l) = 1 ];then
|
||||||
|
echo "The tag instruction has been respected"
|
||||||
tag_result=0
|
tag_result=0
|
||||||
else
|
else
|
||||||
tag_result=1
|
tag_result=1
|
||||||
|
echo "The tag instruction has not been respected"
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
@ -87,10 +87,9 @@ test0 (){
|
|||||||
fi
|
fi
|
||||||
run ./git_update.sh -d $REPO_NAME $REMOTE
|
run ./git_update.sh -d $REPO_NAME $REMOTE
|
||||||
#checks
|
#checks
|
||||||
cloning_check "${FILENAMES[@]}"
|
cloning_check ${FILENAMES[@]}
|
||||||
history_check
|
history_check
|
||||||
case0=$history_result+$cloning_result
|
case0=$(($history_result+$cloning_result))
|
||||||
echo "case0 $case0"
|
|
||||||
if [ "$case0" = "0" ]; then
|
if [ "$case0" = "0" ]; then
|
||||||
echo "case 0, in a empty directory without history, without tag : OK"
|
echo "case 0, in a empty directory without history, without tag : OK"
|
||||||
else
|
else
|
||||||
@ -105,131 +104,21 @@ test1(){
|
|||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
run rm -rf $REPO_NAME
|
run rm -rf $REPO_NAME
|
||||||
fi
|
fi
|
||||||
run ./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE
|
run ./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE
|
||||||
#checks
|
#checks
|
||||||
cloning_check $FILENAMES_TAG
|
cloning_check $FILENAMES_TAG
|
||||||
history_check
|
history_check
|
||||||
tag_check
|
tag_check
|
||||||
|
|
||||||
case1=$cloning_result+$history_result+$tag_result
|
case1=$(($cloning_result+$history_result+$tag_result))
|
||||||
if [ $case1 = 0 ]; then
|
if [ $case1 = 0 ]; then
|
||||||
echo "case 0, in a empty directory without history, with tag : OK"
|
echo "case 1, in a empty directory without history, with tag : OK"
|
||||||
else
|
else
|
||||||
echo "case 0, in a empty directory without history, with tag : FAIL"
|
echo "case 1, in a empty directory without history, with tag : FAIL"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test2(){
|
test2(){
|
||||||
#case 2 : git cloné dans un dossier git déjà rempli, on souhaite que tout soit écrasé
|
|
||||||
section TEST2.1
|
|
||||||
#sous-test 1 : dossier contenant le même repo dans un état antérieur, on ne garde pas les fichiers hors git
|
|
||||||
REPO_NAMEDst=leRepo2 #destination
|
|
||||||
FILENAMESToOverwrite=("texte" "texteHorsGit")
|
|
||||||
nonGitFILE=texteHorsGit
|
|
||||||
newFILE=main.c
|
|
||||||
|
|
||||||
if [ -d $REPO_NAME ]; then #reste d'un test précédent
|
|
||||||
run rm -rf $REPO_NAME
|
|
||||||
echo "le dossier de test préexistant $REPO_NAME a été supprimé"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d $REPO_NAMEDst ]; then #reste de ce test-ci déjà exécuté
|
|
||||||
run rm -rf $REPO_NAMEDst
|
|
||||||
echo "le dossier de test préexistant $REPO_NAMEDst a été supprimé"
|
|
||||||
fi
|
|
||||||
|
|
||||||
run mkdir $REPO_NAMEDst
|
|
||||||
#on clone notre repo de test dans un état précédent (grâce au tag début quand on aura la fonctionnalité précédente fonctionnelle)
|
|
||||||
run git clone -q --recurse-submodules $REMOTE $REPO_NAMEDst
|
|
||||||
#on ajoute des fichiers hors Git
|
|
||||||
run touch $REPO_NAMEDst/$nonGitFILE
|
|
||||||
case2="true"
|
|
||||||
#on vérifie que l'initialisation est un succès
|
|
||||||
if [ -d "./$REPO_NAMEDst" ]; then
|
|
||||||
for FILE2 in ${FILENAMESToOverwrite[@]}
|
|
||||||
do
|
|
||||||
if [ ! -f "./$REPO_NAMEDst/$FILE2" ]; then
|
|
||||||
echo "Erreur dans l'initialisation du case de test 2"
|
|
||||||
die "Problème à régler dans l'initialisation du case 2 afin de pouvoir conduire le test"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Erreur dans l'initialisation du case de test 2"
|
|
||||||
die "Problème à régler dans l'initialisation du case 2 afin de pouvoir conduire le test"
|
|
||||||
|
|
||||||
fi
|
|
||||||
cd $REPO_NAMEDst
|
|
||||||
#commande de clonage dans un dossier préexistant
|
|
||||||
../git_update.sh -b $nomBranche $REMOTE
|
|
||||||
if [ -f $nonGitFILE ]; then
|
|
||||||
echo "Le fichier déjà présent qui n'était pas considéré par Git n'a pas été supprimé"
|
|
||||||
case2="false"
|
|
||||||
elif [ $(cat ${FILENAMESToOverwrite[0]} | grep $keyword | wc -l) -gt 0 ]; then
|
|
||||||
echo "Le fichier git déjà présent n'a pas été changé pour la nouvelle version"
|
|
||||||
case2="false"
|
|
||||||
elif [ ! -f $newFILE ]; then
|
|
||||||
echo "Un fichier git préalablement absent du folder n'a pas été importé"
|
|
||||||
case2="false"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$case2" = "true" ]; then
|
|
||||||
echo "case de test 2 sous-test 1, dans un dossier préexistant du même repo Git dans un état antérieur, sans tag, sans garder de fichier non git : OK"
|
|
||||||
else
|
|
||||||
echo "case de test 2 sous-test 1, dans un dossier préexistant du même repo Git dans un état antérieur, sans tag, sans garder de fichier non git: ECHEC"
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
#sous-test 2 dossier contenant le même repo dans un état antérieur, on ne garde pas les fichiers hors git
|
|
||||||
section TEST2.2
|
|
||||||
if [ -d $REPO_NAME ]; then #reste d'un test précédent
|
|
||||||
rm -rf $REPO_NAME
|
|
||||||
echo "le dossier de test préexistant $REPO_NAME a été supprimé"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d $REPO_NAMEDst ]; then #reste de ce test-ci déjà exécuté
|
|
||||||
rm -rf $REPO_NAMEDst
|
|
||||||
echo "le dossier de test préexistant $REPO_NAMEDst a été supprimé"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir $REPO_NAMEDst
|
|
||||||
#on clone notre repo de test dans un état précédent (grâce au tag début quand on aura la fonctionnalité précédente fonctionnelle)
|
|
||||||
git clone -q --recurse-submodules $REMOTE $REPO_NAMEDst
|
|
||||||
#on ajoute des fichiers hors Git
|
|
||||||
touch $REPO_NAMEDst/$nonGitFILE
|
|
||||||
case2="true"
|
|
||||||
#on vérifie que l'initialisation est un succès
|
|
||||||
if [ -d "./$REPO_NAMEDst" ]; then
|
|
||||||
for FILE2 in ${FILENAMESToOverwrite[@]}
|
|
||||||
do
|
|
||||||
if [ ! -f "./$REPO_NAMEDst/$FILE2" ]; then
|
|
||||||
echo "Erreur dans l'initialisation du case de test 2"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Erreur dans l'initialisation du case de test 2"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
cd $REPO_NAMEDst
|
|
||||||
#commande de clonage dans un dossier préexistant en gardant les fichiers qui étaient là avant
|
|
||||||
../git_update.sh -N -b $nomBranche $REMOTE
|
|
||||||
if [ ! -f $nonGitFILE ]; then
|
|
||||||
echo "Le fichier déjà présent qui n'était pas considéré par Git a été supprimé"
|
|
||||||
case2="false"
|
|
||||||
elif [ $(cat ${FILENAMESToOverwrite[0]} | grep $keyword | wc -l) -gt 0 ]; then
|
|
||||||
echo "Le fichier git déjà présent n'a pas été changé pour la nouvelle version"
|
|
||||||
case2="false"
|
|
||||||
elif [ ! -f $newFILE ]; then
|
|
||||||
echo "Un fichier git préalablement absent du folder n'a pas été importé"
|
|
||||||
case2="false"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$case2" = "true" ]; then
|
|
||||||
echo "case de test 2 sous-test 2, dans un dossier préexistant du même repo Git dans un état antérieur, en gardant les fichiers non-git, sans tag : OK"
|
|
||||||
else
|
|
||||||
echo "case de test 2 sous-test 2, dans un dossier préexistant du même repo Git dans un état antérieur, en gardant les fichiers non-git, sans tag: ECHEC"
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user