jusqu'au test 7
This commit is contained in:
parent
0c87c46c18
commit
639bd07ee3
@ -74,8 +74,8 @@ run cd "$dst"
|
|||||||
if [ -d .git ] ; then
|
if [ -d .git ] ; then
|
||||||
|
|
||||||
run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
|
run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
|
||||||
run git fetch --tags --depth=1 --prune --prune-tags origin $ref &> /dev/null
|
run git fetch --tags --depth=1 --prune --prune-tags origin $ref #&> /dev/null
|
||||||
run git reset --hard FETCH_HEAD &> /dev/null
|
run git reset --hard FETCH_HEAD #&> /dev/null
|
||||||
git reflog expire --expire=now --all &> /dev/null
|
git reflog expire --expire=now --all &> /dev/null
|
||||||
if "$be_aggressive" ; then
|
if "$be_aggressive" ; then
|
||||||
git gc --prune=now --aggressive &> /dev/null
|
git gc --prune=now --aggressive &> /dev/null
|
||||||
@ -83,8 +83,8 @@ if [ -d .git ] ; then
|
|||||||
git gc --prune=now &> /dev/null
|
git gc --prune=now &> /dev/null
|
||||||
fi
|
fi
|
||||||
# Preserve existing files in some cases
|
# Preserve existing files in some cases
|
||||||
if ! "$nonempty_target" ; then #so we keep uncommitted files when not in -N
|
if ! "$nonempty_target" ; then #we keep uncommitted files when in -N mode
|
||||||
git clean -qffdx
|
git clean -qfdx
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -7,11 +7,14 @@ REPO_NAME=performance_testing
|
|||||||
REMOTE=ssh://git@git.jean-cloud.net:22529/eleonore/performance_testing.git
|
REMOTE=ssh://git@git.jean-cloud.net:22529/eleonore/performance_testing.git
|
||||||
WITH_SUBMODULE="true"
|
WITH_SUBMODULE="true"
|
||||||
FILENAMES=("sample0" "sample1 sample3") #we do not check for all files
|
FILENAMES=("sample0" "sample1 sample3") #we do not check for all files
|
||||||
FILENAMES_TAG=("sample0")
|
FILENAMES_TAG=("sample0 sample1 sample4")
|
||||||
FILENAMES_BRANCH=("sample0 sample1 sample2") #we do not check for all files, especially not those specific to the branch.
|
FILENAMES_BRANCH=("sample0 sample1 sample2") #we do not check for all files, especially not those specific to the branch.
|
||||||
FILE_ON_BRANCH_ONLY=sample2
|
FILE_ON_BRANCH_ONLY=sample2
|
||||||
|
FILE_ON_TAG_ONLY=sample4
|
||||||
FILE_ON_MAIN_ONLY=sample3
|
FILE_ON_MAIN_ONLY=sample3
|
||||||
TAG_NAME=start
|
FILE_TO_BE_DELETED=sample0
|
||||||
|
FILE_TO_BE_CREATED=new_file
|
||||||
|
TAG_NAME=tagging_point
|
||||||
BRANCH_NAME=secondary
|
BRANCH_NAME=secondary
|
||||||
TEMP_CLONE_DIR="temp_local_clone"
|
TEMP_CLONE_DIR="temp_local_clone"
|
||||||
|
|
||||||
@ -67,10 +70,10 @@ history_check(){
|
|||||||
local repo_name=$1
|
local repo_name=$1
|
||||||
cd $repo_name
|
cd $repo_name
|
||||||
history_result=0
|
history_result=0
|
||||||
if [ $(git log | grep "commit" | wc -l) -gt 1 ]; then
|
if [ $(git log | grep "Date" | wc -l) -gt 1 ]; then
|
||||||
echo "Several commits have been saved"
|
echo "Several commits have been saved"
|
||||||
history_result=1
|
history_result=1
|
||||||
elif [ $(git log | grep "commit" | wc -l) = 1 ]; then
|
elif [ $(git log | grep "Date" | wc -l) = 1 ]; then
|
||||||
echo "Only the last commit has been saved"
|
echo "Only the last commit has been saved"
|
||||||
else
|
else
|
||||||
history_result=1
|
history_result=1
|
||||||
@ -115,13 +118,12 @@ make_temporary_clone(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
modification_remote(){
|
modification_remote(){
|
||||||
local filenames=("$@")
|
|
||||||
run cd $TEMP_CLONE_DIR
|
run cd $TEMP_CLONE_DIR
|
||||||
run touch new_file
|
run touch $FILE_TO_BE_CREATED
|
||||||
echo "new text" > new_file
|
echo "new text" > $FILE_TO_BE_CREATED
|
||||||
run rm ${filenames[0]}
|
run rm $FILE_TO_BE_DELETED
|
||||||
run git add new_file ${filenames[0]}
|
run git add $FILE_TO_BE_CREATED $FILE_TO_BE_DELETED
|
||||||
run git commit -m "new_file created and ${filenames[0]} deleted" &> /dev/null
|
run git commit -m "$FILE_TO_BE_CREATED created and $FILE_TO_BE_DELETED deleted" &> /dev/null
|
||||||
run git push &> /dev/null
|
run git push &> /dev/null
|
||||||
run cd ..
|
run cd ..
|
||||||
}
|
}
|
||||||
@ -133,9 +135,17 @@ undo_modification_remote(){
|
|||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modification_local(){
|
||||||
|
cd $REPO_NAME
|
||||||
|
touch $FILE_TO_BE_CREATED
|
||||||
|
echo "different text" > $FILE_TO_BE_CREATED
|
||||||
|
git add $FILE_TO_BE_CREATED
|
||||||
|
git commit -m "$FILE_TO_BE_CREATED added"
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
modification_check(){
|
modification_check(){
|
||||||
local filenames=("$@")
|
if [ -f $FILE_TO_BE_CREATED ]; then
|
||||||
if [ -f "new_file" ]; then
|
|
||||||
echo "The new file has been imported."
|
echo "The new file has been imported."
|
||||||
modification_result=0
|
modification_result=0
|
||||||
|
|
||||||
@ -143,11 +153,11 @@ modification_check(){
|
|||||||
echo "The new file has not been imported."
|
echo "The new file has not been imported."
|
||||||
modification_result="1"
|
modification_result="1"
|
||||||
fi
|
fi
|
||||||
if [ -f "${filenames[0]}" ]; then
|
if [ -f "$FILE_TO_BE_DELETED" ]; then
|
||||||
echo "${filenames[0]} has not been deleted."
|
echo "$FILE_TO_BE_DELETED has not been deleted."
|
||||||
modification_result="1"
|
modification_result="1"
|
||||||
else
|
else
|
||||||
echo "${filenames[0]} has been deleted."
|
echo "$FILE_TO_BE_DELETED has been deleted."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,16 +165,44 @@ changing_branch_check(){
|
|||||||
if [ -f $FILE_ON_BRANCH_ONLY ]; then
|
if [ -f $FILE_ON_BRANCH_ONLY ]; then
|
||||||
echo "The files of the branch $BRANCH_NAME are present."
|
echo "The files of the branch $BRANCH_NAME are present."
|
||||||
branch_changing_result=0
|
branch_changing_result=0
|
||||||
|
if [ -f $FILE_ON_MAIN_ONLY ]; then
|
||||||
|
echo "The files of the branch main are present."
|
||||||
|
branch_changing_result=1
|
||||||
|
else
|
||||||
|
echo "The files of the branch main are absent."
|
||||||
|
branch_changing_result=0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "The files of the branch $BRANCH_NAME are absent."
|
echo "The files of the branch $BRANCH_NAME are absent."
|
||||||
branch_changing_result=1
|
branch_changing_result=1
|
||||||
fi
|
fi
|
||||||
if [ -f $FILE_ON_MAIN_ONLY ]; then
|
|
||||||
echo "The files of the branch main are present."
|
}
|
||||||
branch_changing_result=1
|
|
||||||
|
changing_tag_check(){
|
||||||
|
if [ -f $FILE_ON_TAG_ONLY ]; then
|
||||||
|
echo "The files of the tag $TAG_NAME are present."
|
||||||
|
tag_changing_result=0
|
||||||
|
if [ -f $FILE_ON_MAIN_ONLY ]; then
|
||||||
|
echo "The files of the last commit on main are present."
|
||||||
|
tag_changing_result=1
|
||||||
|
else
|
||||||
|
echo "The files of the last commit in main are absent."
|
||||||
|
tag_changing_result=0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "The files of the branch main are absent."
|
echo "The files of the tag $TAG_NAME are absent."
|
||||||
branch_changing_result=0
|
tag_changing_result=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
conflict_check(){
|
||||||
|
if [[ $(grep "new" $FILE_TO_BE_CREATED | wc -l) > 0 && $(grep "different" $FILE_TO_BE_CREATED | wc -l) = 0 ]]; then
|
||||||
|
echo "The remote version has overwritten the local version."
|
||||||
|
conflict_result=0
|
||||||
|
else
|
||||||
|
echo "The remote version has not overwritten the local version."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +217,7 @@ test0 (){
|
|||||||
#checks
|
#checks
|
||||||
cloning_check $REPO_NAME ${FILENAMES[@]}
|
cloning_check $REPO_NAME ${FILENAMES[@]}
|
||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
case0=$(($history_result+$cloning_result))
|
case0=$((history_result+cloning_result))
|
||||||
if [ "$case0" = "0" ]; then
|
if [ "$case0" = "0" ]; then
|
||||||
echo "case 0, in a empty directory: OK"
|
echo "case 0, in a empty directory: OK"
|
||||||
else
|
else
|
||||||
@ -200,7 +238,7 @@ test1(){
|
|||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
tag_check $REPO_NAME
|
tag_check $REPO_NAME
|
||||||
|
|
||||||
case1=$(($cloning_result+$history_result+$tag_result))
|
case1=$((cloning_result+history_result+tag_result))
|
||||||
if [ $case1 = 0 ]; then
|
if [ $case1 = 0 ]; then
|
||||||
echo "case 1, in a empty directory, with tag: OK"
|
echo "case 1, in a empty directory, with tag: OK"
|
||||||
else
|
else
|
||||||
@ -221,7 +259,7 @@ test2(){
|
|||||||
history_check $REPO_NAME
|
history_check $REPO_NAME
|
||||||
branch_check $REPO_NAME
|
branch_check $REPO_NAME
|
||||||
|
|
||||||
case2=$(($cloning_result+$history_result+$branch_result))
|
case2=$((cloning_result+history_result+branch_result))
|
||||||
if [ $case2 = 0 ]; then
|
if [ $case2 = 0 ]; then
|
||||||
echo "case 2, in a empty directory, with branch: OK"
|
echo "case 2, in a empty directory, with branch: OK"
|
||||||
else
|
else
|
||||||
@ -263,8 +301,9 @@ test3(){
|
|||||||
existing_result=1
|
existing_result=1
|
||||||
fi
|
fi
|
||||||
run cd ..
|
run cd ..
|
||||||
run rm -rf tmp_dir
|
#run rm -rf tmp_dir
|
||||||
case3=$(($cloning_result+$history_result+$existing_result))
|
|
||||||
|
case3=$((cloning_result+history_result+existing_result))
|
||||||
if [ $case3 = 0 ]; then
|
if [ $case3 = 0 ]; then
|
||||||
echo "case 3, in a non-empty directory : OK"
|
echo "case 3, in a non-empty directory : OK"
|
||||||
else
|
else
|
||||||
@ -274,7 +313,7 @@ test3(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
test4(){
|
test4(){
|
||||||
#CASE 4: git updated fast-forward
|
#CASE 4: git updated fast-forward on main
|
||||||
section TEST4
|
section TEST4
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
@ -283,25 +322,27 @@ test4(){
|
|||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#modify the remote from elsewhere
|
#modify the remote from elsewhere
|
||||||
modification_remote ${FILENAMES[@]}
|
modification_remote
|
||||||
#make git_update.sh update the repository
|
#make git_update.sh update the repository
|
||||||
run cd $REPO_NAME
|
run cd $REPO_NAME
|
||||||
run ../git_update.sh $REMOTE
|
run ../git_update.sh $REMOTE
|
||||||
#checks
|
#checks
|
||||||
run modification_check ${FILENAMES[@]}
|
modification_check
|
||||||
#cleaning
|
|
||||||
run cd ..
|
run cd ..
|
||||||
|
history_check $REPO_NAME
|
||||||
|
#cleaning
|
||||||
undo_modification_remote
|
undo_modification_remote
|
||||||
case4=$modification_result
|
|
||||||
|
case4=$((modification_result+history_result))
|
||||||
if [ "$case4" = "0" ]; then
|
if [ "$case4" = "0" ]; then
|
||||||
echo "case 4, fast-forward update: OK"
|
echo "case 4, fast-forward update on main: OK"
|
||||||
else
|
else
|
||||||
echo "case 4, fast-forward update: FAIL"
|
echo "case 4, fast-forward update on main: FAIL"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test5(){
|
test5(){
|
||||||
#CASE 5: git updated, changing to another branch, deleting and adding files in the process
|
#CASE 5: git updated with underlying conflict on main
|
||||||
section TEST5
|
section TEST5
|
||||||
#if it exists, delete the directory
|
#if it exists, delete the directory
|
||||||
if [ -d $REPO_NAME ]; then
|
if [ -d $REPO_NAME ]; then
|
||||||
@ -309,18 +350,76 @@ test5(){
|
|||||||
fi
|
fi
|
||||||
#clone the repo in its last state
|
#clone the repo in its last state
|
||||||
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
|
#modify the local repo
|
||||||
|
modification_local
|
||||||
|
#modify the remote from elsewhere
|
||||||
|
modification_remote
|
||||||
|
#make git_update.sh update the local repository
|
||||||
|
run cd $REPO_NAME
|
||||||
|
run ../git_update.sh $REMOTE
|
||||||
|
#checks
|
||||||
|
run conflict_check ${FILENAMES[@]}
|
||||||
|
#cleaning
|
||||||
|
run cd ..
|
||||||
|
undo_modification_remote
|
||||||
|
|
||||||
|
case5=$((conflict_result+history_result))
|
||||||
|
if [ "$case5" = "0" ]; then
|
||||||
|
echo "case 5, update with underlying conflict: OK"
|
||||||
|
else
|
||||||
|
echo "case 5, update with underlying conflict: FAIL"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
test6(){
|
||||||
|
#CASE 6: git updated, switching to another branch, deleting and adding files in the process
|
||||||
|
section TEST6
|
||||||
|
#if it exists, delete the directory
|
||||||
|
if [ -d $REPO_NAME ]; then
|
||||||
|
run rm -rf $REPO_NAME
|
||||||
|
fi
|
||||||
|
#clone the repo in its last state
|
||||||
|
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
#call git update with another branch
|
#call git update with another branch
|
||||||
cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
../git_update.sh -r $BRANCH_NAME $REMOTE
|
../git_update.sh -r $BRANCH_NAME $REMOTE
|
||||||
#checks
|
#checks
|
||||||
changing_branch_check
|
changing_branch_check
|
||||||
case5=$branch_changing_result
|
cd ..
|
||||||
if [ "$case5" = "0" ]; then
|
history_check $REPO_NAME
|
||||||
echo "case 5, branch-changing update: OK"
|
case6=$((branch_changing_result+history_result))
|
||||||
|
if [ "$case6" = "0" ]; then
|
||||||
|
echo "case 6, branch-changing update: OK"
|
||||||
else
|
else
|
||||||
echo "case 5, branch-changing update: FAIL"
|
echo "case 6, branch-changing update: FAIL"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test7(){
|
||||||
|
#CASE 7: git updated, switching to a tag, deleting and adding files in the process
|
||||||
|
section TEST7
|
||||||
|
#if it exists, delete the directory
|
||||||
|
if [ -d $REPO_NAME ]; then
|
||||||
|
run rm -rf $REPO_NAME
|
||||||
|
fi
|
||||||
|
#clone the repo in its last state
|
||||||
|
run git clone --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="ssh" $REMOTE &> /dev/null
|
||||||
|
#call git update with another branch
|
||||||
|
cd $REPO_NAME
|
||||||
|
../git_update.sh -r $TAG_NAME $REMOTE
|
||||||
|
#checks
|
||||||
|
changing_tag_check
|
||||||
|
run cd ..
|
||||||
|
history_check $REPO_NAME
|
||||||
|
case7=$((tag_changing_result+history_result))
|
||||||
|
if [ "$case7" = "0" ]; then
|
||||||
|
echo "case 7, branch-changing update: OK"
|
||||||
|
else
|
||||||
|
echo "case 7, branch-changing update: FAIL"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#not ff
|
#not ff
|
||||||
#ref changed
|
#ref changed
|
||||||
|
|
||||||
@ -356,7 +455,7 @@ if [ "$ALL_TESTS" = "true" ]; then
|
|||||||
test9
|
test9
|
||||||
|
|
||||||
elif [ -n "$TEST_NUM" ]; then
|
elif [ -n "$TEST_NUM" ]; then
|
||||||
if [ "$TEST_NUM" = 4 ];then
|
if [[ "$TEST_NUM" = 4 || "$TEST_NUM" = 5 ]];then
|
||||||
make_temporary_clone
|
make_temporary_clone
|
||||||
fi
|
fi
|
||||||
case $TEST_NUM in
|
case $TEST_NUM in
|
||||||
|
Loading…
Reference in New Issue
Block a user