Progress on tests definition, init. and clean
Update test result output mainly -o and integrated -oo into it
This commit is contained in:
@@ -1,65 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
########## Competition Block ##########
|
||||
|
||||
# tc = test compete
|
||||
_tc_tmp="${test_dir:-"/tmp"}/tmp_compete"
|
||||
|
||||
# Each competition link is given to both tools
|
||||
# and the output is compared
|
||||
#
|
||||
# Array format:
|
||||
# [0] = Title
|
||||
# [1] = path for competition
|
||||
# [2] = path for competition
|
||||
# ...
|
||||
compete_links=( "Test - Valid links"
|
||||
"/dev/stdin"
|
||||
"$test_dir/tmp/a"*
|
||||
"$test_dir/tmp/a 3"
|
||||
"/bin/adb"
|
||||
)
|
||||
|
||||
# Compete test suites (arrays)
|
||||
compete_canonicalize=(
|
||||
"Canonicalize invalid path"
|
||||
"///tmp//./b"
|
||||
"//tmp//./b/.."
|
||||
"//tmp//./b/."
|
||||
)
|
||||
|
||||
compete_all=( "Test - everything starting from /"
|
||||
/**/*
|
||||
)
|
||||
|
||||
|
||||
tocompete_init() {
|
||||
# TODO initialize custom test structure
|
||||
# initialize custom test structure
|
||||
{
|
||||
mkdir -p "${_tc_tmp}"
|
||||
# compete_links
|
||||
touch "${_tc_tmp}/a"
|
||||
ln -s "${_tc_tmp}/a" "${_tc_tmp}/a 2"
|
||||
ln -s "${_tc_tmp}/a 2" "${_tc_tmp}/a 3"
|
||||
}
|
||||
|
||||
# Base directory for the test
|
||||
cd "${_tc_tmp}"
|
||||
|
||||
# Compete test arrays with "dynamic" cases need to be inside the init function
|
||||
# e.g. "$(cd ../test && pwd)/file" - base directory must be set first
|
||||
# e.g. "${_tc_tmp}/"* - _tc_tmp must be populated first
|
||||
compete_links=( "Test - Valid links"
|
||||
"${_tc_tmp}/a 3" # slink chain a3 -> a2 -> a
|
||||
"${_tc_tmp}/a"*
|
||||
"/dev/stdin"
|
||||
"/bin/adb"
|
||||
)
|
||||
|
||||
# Add tests to global test array from test_rdlink
|
||||
tocompete+=(
|
||||
compete_links
|
||||
compete_canonicalize
|
||||
#compete_all
|
||||
)
|
||||
}
|
||||
|
||||
tocompete_clean() {
|
||||
# TODO clean custom test structure
|
||||
echo "tocompete_clean"
|
||||
rm -rf "${_tc_tmp}"
|
||||
}
|
||||
|
||||
tocompete_init
|
||||
|
||||
########## Assertion Block ##########
|
||||
# Assertion string compare test
|
||||
|
||||
# ta = test assert
|
||||
_ta_tmp="${test_dir:-"/tmp"}/tmp_assert"
|
||||
|
||||
# Assertion string compare test arrays
|
||||
#
|
||||
# Array format
|
||||
# [0] = Title
|
||||
# [1] expected == [2] input
|
||||
# [3] expected == [4] input
|
||||
# [1] input == [2] expected
|
||||
# [3] input == [4] expected
|
||||
# ...
|
||||
assert_string=( "Assert - invalid files"
|
||||
"/opt/rdlink/test/a" "a"
|
||||
"/opt/rdlink/test/b" "b"
|
||||
"/opt/rdlink/test/c" "c"
|
||||
)
|
||||
|
||||
toassert_init() {
|
||||
# TODO initilaize custom test structure
|
||||
{
|
||||
mkdir -p "${_ta_tmp}"
|
||||
}
|
||||
|
||||
# Base directory for the test
|
||||
cd "${_ta_tmp}"
|
||||
|
||||
# Assert test arrays with "dynamic" cases need to be inside the init function
|
||||
# e.g. "$(cd ../test && pwd)/file" - base directory must be set first
|
||||
# e.g. "${_tc_tmp}/"* - _tc_tmp must be populated first
|
||||
assert_invalid_files=( "Assert - invalid files"
|
||||
"${_ta_tmp}/missing_file" "${_ta_tmp}/missing_file"
|
||||
"${_ta_tmp}/missd/missf" "${_ta_tmp}/missd/missf"
|
||||
"${_ta_tmp}/miss c" "${_ta_tmp}/miss c"
|
||||
"rel_a" "${_ta_tmp}/rel_a"
|
||||
"../rel_b" "$(cd ".." && pwd)/rel_b"
|
||||
"/a/very/long/path/whthMustExceed/fourtyfive/character" "a"
|
||||
)
|
||||
|
||||
# Add test arrays to global test array from test_rdlink
|
||||
toassert+=(
|
||||
assert_string
|
||||
assert_invalid_files
|
||||
)
|
||||
}
|
||||
|
||||
toassert_clean() {
|
||||
# TODO clean
|
||||
echo "toassert_clean"
|
||||
rm -rf "${_ta_tmp}"
|
||||
}
|
||||
|
||||
toassert_init
|
||||
|
||||
|
||||
########## Clean custom test data ##########
|
||||
#
|
||||
totest_cleanall() {
|
||||
echo
|
||||
tocompete_clean
|
||||
@@ -67,4 +122,3 @@ totest_cleanall() {
|
||||
}
|
||||
trap totest_cleanall EXIT
|
||||
|
||||
toassert_init
|
||||
|
Reference in New Issue
Block a user