add multiple test for the add command
This commit is contained in:
parent
0c925bc4f4
commit
22b9351862
@ -1,10 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
nb_tests=0
|
||||
TEST_SUITE_NAME="add/file/"
|
||||
|
||||
get_exe() {
|
||||
exe=$(pwd)
|
||||
exe+="/../target/debug/nextsync"
|
||||
if [ ! -f $exe ]; then
|
||||
echo "No executable found, try to compile first"
|
||||
echo "No executable found, try to compile first" >&2
|
||||
exit 4
|
||||
fi
|
||||
}
|
||||
@ -16,28 +19,35 @@ setup_env() {
|
||||
|
||||
add_cmp() {
|
||||
res=$($exe status --nostyle)
|
||||
diff <(echo -e "$2" ) <(echo -e "$res") 2> /dev/null > /dev/null
|
||||
diff <(echo -e "$2" ) <(echo -e "$res") 2> /dev/null > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "$1: Output differ:"
|
||||
diff <(echo -e "$2" ) <(echo -e "$res")
|
||||
echo $path
|
||||
echo -e "$TEST_SUITE_NAME$1: Output differ:" >&2
|
||||
diff -u <(echo -e "$2" ) <(echo -e "$res") | grep "^[-\+\ ][^-\+]" >&2
|
||||
echo -e "\nMore in $path" >&2
|
||||
echo $nb_tests
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
add_test() {
|
||||
setup_env
|
||||
$exe init
|
||||
add_test_no_env() {
|
||||
touch $2
|
||||
$exe add $3
|
||||
add_cmp "$1" "$4"
|
||||
}
|
||||
|
||||
add_test() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
add_test_no_env "$1" "$2" "$3" "$4"
|
||||
}
|
||||
|
||||
add_basics() {
|
||||
add_test "basic" "toto" "toto" "new: toto"
|
||||
}
|
||||
|
||||
add_space() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
touch 'to to'
|
||||
@ -55,6 +65,7 @@ add_regex() {
|
||||
}
|
||||
|
||||
add_subdir() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
@ -65,6 +76,7 @@ add_subdir() {
|
||||
}
|
||||
|
||||
add_subdir_regex() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
@ -74,11 +86,44 @@ add_subdir_regex() {
|
||||
add_cmp "subdir_regex" "new: dir/roro\nnew: dir/toto"
|
||||
}
|
||||
|
||||
add_duplication() {
|
||||
add_test "duplication" "toto" "toto toto" "new: toto"
|
||||
}
|
||||
|
||||
add_duplication_subdir() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
add_test_no_env "duplication_subdir" "dir/toto" "dir/toto dir/toto" "new: dir/toto"
|
||||
}
|
||||
|
||||
add_all() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
touch dir/toto dir/roro lolo
|
||||
$exe add -A
|
||||
res=$($exe status --nostyle)
|
||||
add/file/all: Output differ:
|
||||
add_cmp "all" "new: dir/roro\nnew: dir/toto\nnew: lolo\nnew: .nextsyncignore"
|
||||
}
|
||||
|
||||
#test nextsyncignore
|
||||
#test inside folder
|
||||
#test -A duplication
|
||||
#test add file without changes
|
||||
|
||||
add_basics
|
||||
add_space
|
||||
add_multiple
|
||||
add_regex
|
||||
add_subdir
|
||||
#add_subdir_regex
|
||||
add_subdir_regex
|
||||
add_duplication
|
||||
add_duplication_subdir
|
||||
add_all
|
||||
|
||||
echo $nb_tests
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user