1
0
Fork 0
mirror of synced 2024-12-21 22:21:08 -05:00

Create tests for class support in alt-links (#21)

This commit is contained in:
Tim Byrne 2017-01-20 00:13:56 -06:00
parent 3b4c405d7f
commit d7abc7ff41
No known key found for this signature in database
GPG key ID: 6CBE24C2FD8CF76E
3 changed files with 319 additions and 143 deletions

View file

@ -3,6 +3,7 @@ load_fixtures
status=;output=; #; populated by bats run()
IN_REPO=(alt* "dir one")
export TEST_TREE_WITH_ALT=1
function create_encrypt() {
for efile in "encrypted-base##" "encrypted-system##$T_SYS" "encrypted-host##$T_SYS.$T_HOST" "encrypted-user##$T_SYS.$T_HOST.$T_USER"; do

View file

@ -3,6 +3,7 @@ load_fixtures
status=;output=; #; populated by bats run()
IN_REPO=(wild*)
export TEST_TREE_WITH_WILD=1
setup() {
destroy_tmp
@ -63,6 +64,27 @@ function test_alt() {
done
}
@test "Command 'alt' (wild class)" {
echo "
When the command 'alt' is provided
and file matches only ##CLASS
with possible wildcards
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
local match="${c_base}##${WILD_C}"
echo test_alt "$c_base" "$match"
test_alt "$c_base" "$match"
done
}
@test "Command 'alt' (wild host)" {
echo "
When the command 'alt' is provided
@ -86,6 +108,31 @@ function test_alt() {
done
}
@test "Command 'alt' (wild class-system)" {
echo "
When the command 'alt' is provided
and file matches only ##CLASS.SYSTEM
with possible wildcards
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-system-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
for WILD_S in 'local' 'wild'; do
local s_base="${c_base}-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
local match="${s_base}##${WILD_C}.${WILD_S}"
echo test_alt "$s_base" "$match"
test_alt "$s_base" "$match"
done
done
}
@test "Command 'alt' (wild user)" {
echo "
When the command 'alt' is provided
@ -112,3 +159,65 @@ function test_alt() {
done
done
}
@test "Command 'alt' (wild class-system-host)" {
echo "
When the command 'alt' is provided
and file matches only ##CLASS.SYSTEM.HOST
with possible wildcards
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-system-host-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
for WILD_S in 'local' 'wild'; do
local s_base="${c_base}-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
local match="${h_base}##${WILD_C}.${WILD_S}.${WILD_H}"
echo test_alt "$h_base" "$match"
test_alt "$h_base" "$match"
done
done
done
}
@test "Command 'alt' (wild class-system-host-user)" {
echo "
When the command 'alt' is provided
and file matches only ##CLASS.SYSTEM.HOST.USER
with possible wildcards
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-system-host-user-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
for WILD_S in 'local' 'wild'; do
local s_base="${c_base}-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
for WILD_U in 'local' 'wild'; do
local u_base="${h_base}-$WILD_U"
case $WILD_U in local) WILD_U="$T_USER";; wild) WILD_U="%";; esac
local match="${u_base}##${WILD_C}.${WILD_S}.${WILD_H}.${WILD_U}"
echo test_alt "$u_base" "$match"
test_alt "$u_base" "$match"
done
done
done
done
}

View file

@ -81,107 +81,216 @@ function create_worktree() {
rm -rf "$DIR_WORKTREE"
#; create some standard files
if [ ! -z "$TEST_TREE_WITH_ALT" ] ; then
for f in \
"alt-none##S" \
"alt-none##S.H" \
"alt-none##S.H.U" \
"alt-base##" \
"alt-base##S" \
"alt-base##S.H" \
"alt-base##S.H.U" \
"alt-system##" \
"alt-system##S" \
"alt-system##S.H" \
"alt-system##S.H.U" \
"alt-system##$T_SYS" \
"alt-host##" \
"alt-host##S" \
"alt-host##S.H" \
"alt-host##S.H.U" \
"alt-host##$T_SYS.$T_HOST" \
"alt-host##${T_SYS}_${T_HOST}" \
"alt-user##" \
"alt-user##S" \
"alt-user##S.H" \
"alt-user##S.H.U" \
"alt-user##$T_SYS.$T_HOST.$T_USER" \
"alt-user##${T_SYS}_${T_HOST}_${T_USER}" \
"alt-override-system##" \
"alt-override-system##$T_SYS" \
"alt-override-system##custom_system" \
"alt-override-host##" \
"alt-override-host##$T_SYS.$T_HOST" \
"alt-override-host##$T_SYS.custom_host" \
"alt-override-user##" \
"alt-override-user##S.H.U" \
"alt-override-user##$T_SYS.$T_HOST.custom_user" \
"dir one/alt-none##S/file1" \
"dir one/alt-none##S/file2" \
"dir one/alt-none##S.H/file1" \
"dir one/alt-none##S.H/file2" \
"dir one/alt-none##S.H.U/file1" \
"dir one/alt-none##S.H.U/file2" \
"dir one/alt-base##/file1" \
"dir one/alt-base##/file2" \
"dir one/alt-base##S/file1" \
"dir one/alt-base##S/file2" \
"dir one/alt-base##S.H/file1" \
"dir one/alt-base##S.H/file2" \
"dir one/alt-base##S.H.U/file1" \
"dir one/alt-base##S.H.U/file2" \
"dir one/alt-system##/file1" \
"dir one/alt-system##/file2" \
"dir one/alt-system##S/file1" \
"dir one/alt-system##S/file2" \
"dir one/alt-system##S.H/file1" \
"dir one/alt-system##S.H/file2" \
"dir one/alt-system##S.H.U/file1" \
"dir one/alt-system##S.H.U/file2" \
"dir one/alt-system##$T_SYS/file1" \
"dir one/alt-system##$T_SYS/file2" \
"dir one/alt-host##/file1" \
"dir one/alt-host##/file2" \
"dir one/alt-host##S/file1" \
"dir one/alt-host##S/file2" \
"dir one/alt-host##S.H/file1" \
"dir one/alt-host##S.H/file2" \
"dir one/alt-host##S.H.U/file1" \
"dir one/alt-host##S.H.U/file2" \
"dir one/alt-host##$T_SYS.$T_HOST/file1" \
"dir one/alt-host##$T_SYS.$T_HOST/file2" \
"dir one/alt-host##${T_SYS}_${T_HOST}/file1" \
"dir one/alt-host##${T_SYS}_${T_HOST}/file2" \
"dir one/alt-user##/file1" \
"dir one/alt-user##/file2" \
"dir one/alt-user##S/file1" \
"dir one/alt-user##S/file2" \
"dir one/alt-user##S.H/file1" \
"dir one/alt-user##S.H/file2" \
"dir one/alt-user##S.H.U/file1" \
"dir one/alt-user##S.H.U/file2" \
"dir one/alt-user##$T_SYS.$T_HOST.$T_USER/file1" \
"dir one/alt-user##$T_SYS.$T_HOST.$T_USER/file2" \
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file1" \
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file2" \
"dir one/alt-override-system##/file1" \
"dir one/alt-override-system##/file2" \
"dir one/alt-override-system##$T_SYS/file1" \
"dir one/alt-override-system##$T_SYS/file2" \
"dir one/alt-override-system##custom_system/file1" \
"dir one/alt-override-system##custom_system/file2" \
"dir one/alt-override-host##/file1" \
"dir one/alt-override-host##/file2" \
"dir one/alt-override-host##$T_SYS.$T_HOST/file1" \
"dir one/alt-override-host##$T_SYS.$T_HOST/file2" \
"dir one/alt-override-host##$T_SYS.custom_host/file1" \
"dir one/alt-override-host##$T_SYS.custom_host/file2" \
"dir one/alt-override-user##/file1" \
"dir one/alt-override-user##/file2" \
"dir one/alt-override-user##S.H.U/file1" \
"dir one/alt-override-user##S.H.U/file2" \
"dir one/alt-override-user##$T_SYS.$T_HOST.custom_user/file1" \
"dir one/alt-override-user##$T_SYS.$T_HOST.custom_user/file2" \
"dir2/file2" \
;
do
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
fi
if [ ! -z "$TEST_TREE_WITH_WILD" ] ; then
#; wildcard test data - yes this is a big mess :(
#; none
for f in "wild-none##"; do
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
#; system
for WILD_S in 'local' 'wild' 'other'; do
local s_base="wild-system-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
local f="${s_base}##${WILD_S}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
#; system.host
for WILD_S in 'local' 'wild' 'other'; do
local s_base="wild-host-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild' 'other'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
local f="${h_base}##${WILD_S}.${WILD_H}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
#; system.host.user
for WILD_S in 'local' 'wild' 'other'; do
local s_base="wild-user-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild' 'other'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
for WILD_U in 'local' 'wild' 'other'; do
local u_base="${h_base}-$WILD_U"
case $WILD_U in local) WILD_U="$T_USER";; wild) WILD_U="%";; esac
local f="${u_base}##${WILD_S}.${WILD_H}.${WILD_U}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
done
#; class
for WILD_C in 'local' 'wild' 'other'; do
local c_base="wild-class-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
local f="${c_base}##${WILD_C}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
#; class.system
for WILD_C in 'local' 'wild' 'other'; do
local c_base="wild-class-system-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
for WILD_S in 'local' 'wild' 'other'; do
local s_base="${c_base}-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
local f="${s_base}##${WILD_C}.${WILD_S}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
#; class.system.host
for WILD_C in 'local' 'wild' 'other'; do
local c_base="wild-class-system-host-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
for WILD_S in 'local' 'wild' 'other'; do
local s_base="${c_base}-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild' 'other'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
local f="${h_base}##${WILD_C}.${WILD_S}.${WILD_H}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
done
#; class.system.host.user
for WILD_C in 'local' 'wild' 'other'; do
local c_base="wild-class-system-host-user-$WILD_C"
case $WILD_C in local) WILD_C="set_class";; wild) WILD_C="%";; esac
for WILD_S in 'local' 'wild' 'other'; do
local s_base="${c_base}-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild' 'other'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
for WILD_U in 'local' 'wild' 'other'; do
local u_base="${h_base}-$WILD_U"
case $WILD_U in local) WILD_U="$T_USER";; wild) WILD_U="%";; esac
local f="${u_base}##${WILD_C}.${WILD_S}.${WILD_H}.${WILD_U}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
done
done
fi
for f in \
"alt-none##S" \
"alt-none##S.H" \
"alt-none##S.H.U" \
"alt-base##" \
"alt-base##S" \
"alt-base##S.H" \
"alt-base##S.H.U" \
"alt-system##" \
"alt-system##S" \
"alt-system##S.H" \
"alt-system##S.H.U" \
"alt-system##$T_SYS" \
"alt-host##" \
"alt-host##S" \
"alt-host##S.H" \
"alt-host##S.H.U" \
"alt-host##$T_SYS.$T_HOST" \
"alt-host##${T_SYS}_${T_HOST}" \
"alt-user##" \
"alt-user##S" \
"alt-user##S.H" \
"alt-user##S.H.U" \
"alt-user##$T_SYS.$T_HOST.$T_USER" \
"alt-user##${T_SYS}_${T_HOST}_${T_USER}" \
"alt-override-system##" \
"alt-override-system##$T_SYS" \
"alt-override-system##custom_system" \
"alt-override-host##" \
"alt-override-host##$T_SYS.$T_HOST" \
"alt-override-host##$T_SYS.custom_host" \
"alt-override-user##" \
"alt-override-user##S.H.U" \
"alt-override-user##$T_SYS.$T_HOST.custom_user" \
"dir one/alt-none##S/file1" \
"dir one/alt-none##S/file2" \
"dir one/alt-none##S.H/file1" \
"dir one/alt-none##S.H/file2" \
"dir one/alt-none##S.H.U/file1" \
"dir one/alt-none##S.H.U/file2" \
"dir one/alt-base##/file1" \
"dir one/alt-base##/file2" \
"dir one/alt-base##S/file1" \
"dir one/alt-base##S/file2" \
"dir one/alt-base##S.H/file1" \
"dir one/alt-base##S.H/file2" \
"dir one/alt-base##S.H.U/file1" \
"dir one/alt-base##S.H.U/file2" \
"dir one/alt-system##/file1" \
"dir one/alt-system##/file2" \
"dir one/alt-system##S/file1" \
"dir one/alt-system##S/file2" \
"dir one/alt-system##S.H/file1" \
"dir one/alt-system##S.H/file2" \
"dir one/alt-system##S.H.U/file1" \
"dir one/alt-system##S.H.U/file2" \
"dir one/alt-system##$T_SYS/file1" \
"dir one/alt-system##$T_SYS/file2" \
"dir one/alt-host##/file1" \
"dir one/alt-host##/file2" \
"dir one/alt-host##S/file1" \
"dir one/alt-host##S/file2" \
"dir one/alt-host##S.H/file1" \
"dir one/alt-host##S.H/file2" \
"dir one/alt-host##S.H.U/file1" \
"dir one/alt-host##S.H.U/file2" \
"dir one/alt-host##$T_SYS.$T_HOST/file1" \
"dir one/alt-host##$T_SYS.$T_HOST/file2" \
"dir one/alt-host##${T_SYS}_${T_HOST}/file1" \
"dir one/alt-host##${T_SYS}_${T_HOST}/file2" \
"dir one/alt-user##/file1" \
"dir one/alt-user##/file2" \
"dir one/alt-user##S/file1" \
"dir one/alt-user##S/file2" \
"dir one/alt-user##S.H/file1" \
"dir one/alt-user##S.H/file2" \
"dir one/alt-user##S.H.U/file1" \
"dir one/alt-user##S.H.U/file2" \
"dir one/alt-user##$T_SYS.$T_HOST.$T_USER/file1" \
"dir one/alt-user##$T_SYS.$T_HOST.$T_USER/file2" \
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file1" \
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file2" \
"dir one/alt-override-system##/file1" \
"dir one/alt-override-system##/file2" \
"dir one/alt-override-system##$T_SYS/file1" \
"dir one/alt-override-system##$T_SYS/file2" \
"dir one/alt-override-system##custom_system/file1" \
"dir one/alt-override-system##custom_system/file2" \
"dir one/alt-override-host##/file1" \
"dir one/alt-override-host##/file2" \
"dir one/alt-override-host##$T_SYS.$T_HOST/file1" \
"dir one/alt-override-host##$T_SYS.$T_HOST/file2" \
"dir one/alt-override-host##$T_SYS.custom_host/file1" \
"dir one/alt-override-host##$T_SYS.custom_host/file2" \
"dir one/alt-override-user##/file1" \
"dir one/alt-override-user##/file2" \
"dir one/alt-override-user##S.H.U/file1" \
"dir one/alt-override-user##S.H.U/file2" \
"dir one/alt-override-user##$T_SYS.$T_HOST.custom_user/file1" \
"dir one/alt-override-user##$T_SYS.$T_HOST.custom_user/file2" \
"dir2/file2" \
.bash_profile \
.gnupg/gpg.conf \
.gnupg/pubring.gpg \
@ -198,49 +307,6 @@ function create_worktree() {
echo "$f" > "$DIR_WORKTREE/$f"
done
#; wildcard test data - yes this is a big mess :(
#; none
for f in "wild-none##"; do
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
#; system
for WILD_S in 'local' 'wild' 'other'; do
local s_base="wild-system-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
local f="${s_base}##${WILD_S}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
#; system.host
for WILD_S in 'local' 'wild' 'other'; do
local s_base="wild-host-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild' 'other'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
local f="${h_base}##${WILD_S}.${WILD_H}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
#; system.host.user
for WILD_S in 'local' 'wild' 'other'; do
local s_base="wild-user-$WILD_S"
case $WILD_S in local) WILD_S="$T_SYS";; wild) WILD_S="%";; esac
for WILD_H in 'local' 'wild' 'other'; do
local h_base="${s_base}-$WILD_H"
case $WILD_H in local) WILD_H="$T_HOST";; wild) WILD_H="%";; esac
for WILD_U in 'local' 'wild' 'other'; do
local u_base="${h_base}-$WILD_U"
case $WILD_U in local) WILD_U="$T_USER";; wild) WILD_U="%";; esac
local f="${u_base}##${WILD_S}.${WILD_H}.${WILD_U}"
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
done
done
#; change all perms (so permission updates can be observed)
find "$DIR_WORKTREE" -exec chmod 0777 '{}' ';'