refactor(test): remove old tests
This commit is contained in:
parent
a2f746d7f6
commit
211e3702a3
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
source ./utils.sh
|
||||
|
||||
nb_tests=0
|
||||
TEST_SUITE_NAME="add/directory/"
|
||||
|
||||
add_test_no_env() {
|
||||
touch $2
|
||||
$exe add $3
|
||||
status_cmp "$1" "$4"
|
||||
}
|
||||
|
||||
add_test() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
add_test_no_env "$1" "$2" "$3" "$4"
|
||||
}
|
||||
|
||||
add_dir() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
$exe add "dir"
|
||||
res=$($exe status --nostyle)
|
||||
status_cmp "dir" "new: dir"
|
||||
}
|
||||
|
||||
add_subdir() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir foo foo/bar
|
||||
$exe add "foo"
|
||||
res=$($exe status --nostyle)
|
||||
status_cmp "dir" "new: foo/bar\nnew: foo"
|
||||
}
|
||||
|
||||
add_dir
|
||||
add_subdir
|
||||
|
||||
echo $nb_tests
|
||||
exit 0
|
@ -1,114 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
source ./utils.sh
|
||||
|
||||
nb_tests=0
|
||||
TEST_SUITE_NAME="add/file/"
|
||||
|
||||
add_test_no_env() {
|
||||
touch $2
|
||||
$exe add $3
|
||||
status_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'
|
||||
$exe add 'to to'
|
||||
res=$($exe status --nostyle)
|
||||
status_cmp "space" "new: to to"
|
||||
}
|
||||
|
||||
add_multiple() {
|
||||
add_test "multiple" "titi riri" "titi riri" "new: titi\nnew: riri"
|
||||
}
|
||||
|
||||
add_regex() {
|
||||
add_test "regex" "titi riri" "./*" "new: riri\nnew: titi"
|
||||
}
|
||||
|
||||
add_file_subdir() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
touch dir/toto
|
||||
$exe add "./dir/toto"
|
||||
res=$($exe status --nostyle)
|
||||
status_cmp "file_subdir" "new: dir/toto"
|
||||
}
|
||||
|
||||
add_whole_subdir() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
touch dir/toto
|
||||
touch dir/roro
|
||||
$exe add "dir"
|
||||
res=$($exe status --nostyle)
|
||||
status_cmp "whole_subdir" "new: dir/roro\nnew: dir/toto\nnew: dir"
|
||||
}
|
||||
|
||||
add_subdir_regex() {
|
||||
nb_tests=$((nb_tests + 1))
|
||||
setup_env
|
||||
$exe init
|
||||
mkdir dir
|
||||
touch dir/toto dir/roro
|
||||
$exe add "./dir/*"
|
||||
res=$($exe status --nostyle)
|
||||
status_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)
|
||||
status_cmp "all" "new: .nextsyncignore\nnew: dir/roro\nnew: dir/toto\nnew: dir\nnew: lolo"
|
||||
}
|
||||
|
||||
#test add file without changes
|
||||
|
||||
add_basics
|
||||
add_space
|
||||
add_multiple
|
||||
add_regex
|
||||
add_file_subdir
|
||||
add_whole_subdir
|
||||
add_subdir_regex
|
||||
add_duplication
|
||||
add_duplication_subdir
|
||||
add_all
|
||||
|
||||
echo $nb_tests
|
||||
exit 0
|
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
source ./utils.sh
|
||||
|
||||
# Getting all tests
|
||||
TESTS=$(find -mindepth 2 -name "*.sh")
|
||||
if [ $# -ne 0 ]; then
|
||||
TESTS=$(find -mindepth 2 -path "*$1*")
|
||||
fi
|
||||
|
||||
# Executing tests
|
||||
nb_tests=0
|
||||
nb_success=0
|
||||
for test in $TESTS; do
|
||||
#nb_tests=$((nb_tests + 1))
|
||||
|
||||
# run file
|
||||
tmp_stderr=$(mktf)
|
||||
nb_tests_tmp=$($test 2>"$tmp_stderr")
|
||||
exit_code=$?
|
||||
capture_stderr=$(<"$tmp_stderr")
|
||||
[ "$capture_stderr" != "" ] && echo -e "$capture_stderr"
|
||||
rm $tmp_stderr
|
||||
|
||||
# add nb_tests from executed test_suite to global nb_test
|
||||
[ "$nb_tests_tmp" != "" ] &&
|
||||
[ $nb_tests_tmp -gt 0 ] &&
|
||||
nb_tests=$((nb_tests + nb_tests_tmp))
|
||||
|
||||
# deal with the result of the test
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
nb_success=$((nb_success + nb_tests_tmp))
|
||||
echo "$test ran successfully"
|
||||
elif [ $exit_code -eq 4 ]; then
|
||||
# not executable (nextsync) found, not need to try other tests
|
||||
exit 1
|
||||
else
|
||||
nb_success=$((nb_success + nb_tests_tmp - 1))
|
||||
echo "$test failed with exit code $exit_code"
|
||||
fi
|
||||
done;
|
||||
|
||||
rm -rf /tmp/*_nextsync
|
||||
|
||||
echo -e "\nRan $nb_tests tests ($((nb_tests - nb_success)) Failed)"
|
@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
mktd()
|
||||
{
|
||||
echo $(mktemp -d --suffix=_nextsync)
|
||||
}
|
||||
|
||||
mktf()
|
||||
{
|
||||
echo $(mktemp --suffix=_nextsync)
|
||||
}
|
||||
|
||||
get_exe() {
|
||||
exe=$(pwd)
|
||||
exe+="/../target/debug/nextsync"
|
||||
if [ ! -f $exe ]; then
|
||||
echo "No executable found, try to compile first" >&2
|
||||
exit 4
|
||||
fi
|
||||
}
|
||||
setup_env() {
|
||||
[ ! -v exe ] && get_exe
|
||||
path=$(mktd)
|
||||
cd $path
|
||||
}
|
||||
|
||||
# test_name expected_output
|
||||
status_cmp() {
|
||||
res=$($exe status --nostyle)
|
||||
diff <(echo -e "$2" ) <(echo -e "$res") 2> /dev/null > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user