mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 19:54:17 +00:00
fix empty dirs in tests
This commit is contained in:
5
tests-ng/ignore-dir-when-sub-ignored.sh
vendored
5
tests-ng/ignore-dir-when-sub-ignored.sh
vendored
@@ -29,12 +29,12 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
|||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# the dotfile source
|
# the dotfile source
|
||||||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
tmps=$(mktemp -d --suffix='-dotdrop-dotpath' || mktemp -d)
|
||||||
dotpath="${tmps}"/dotfiles
|
dotpath="${tmps}"/dotfiles
|
||||||
mkdir -p "${dotpath}"
|
mkdir -p "${dotpath}"
|
||||||
#echo "dotfile source: ${tmps}"
|
#echo "dotfile source: ${tmps}"
|
||||||
# the dotfile destination
|
# the dotfile destination
|
||||||
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
tmpd=$(mktemp -d --suffix='-dotdrop-fs' || mktemp -d)
|
||||||
#echo "dotfile destination: ${tmpd}"
|
#echo "dotfile destination: ${tmpd}"
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
@@ -132,7 +132,6 @@ cd "${ddpath}" | ${bin} update -f -c "${cfg1}" -p p1 -V
|
|||||||
###################################################
|
###################################################
|
||||||
# test import
|
# test import
|
||||||
###################################################
|
###################################################
|
||||||
exit 0 # TODO
|
|
||||||
clean_both
|
clean_both
|
||||||
create_in_dst
|
create_in_dst
|
||||||
|
|
||||||
|
|||||||
20
tests-ng/update.sh
vendored
20
tests-ng/update.sh
vendored
@@ -28,12 +28,13 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
|||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
basedir=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
basedir=$(mktemp -d --suffix='-dotdrop-dotpath' || mktemp -d)
|
||||||
|
dotpath="${basedir}/dotfiles"
|
||||||
echo "[+] dotdrop dir: ${basedir}"
|
echo "[+] dotdrop dir: ${basedir}"
|
||||||
echo "[+] dotpath dir: ${basedir}/dotfiles"
|
echo "[+] dotpath dir: ${dotpath}"
|
||||||
|
|
||||||
# the dotfile to be imported
|
# the dotfile to be imported
|
||||||
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
tmpd=$(mktemp -d --suffix='-dotdrop-fs' || mktemp -d)
|
||||||
|
|
||||||
clear_on_exit "${basedir}"
|
clear_on_exit "${basedir}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
@@ -47,7 +48,9 @@ echo 'unique' > "${tmpd}"/uniquefile
|
|||||||
mkdir "${tmpd}"/dir1
|
mkdir "${tmpd}"/dir1
|
||||||
touch "${tmpd}"/dir1/file_only_in_dir1
|
touch "${tmpd}"/dir1/file_only_in_dir1
|
||||||
mkdir -p "${tmpd}"/dir1/dir_only_in_dir1
|
mkdir -p "${tmpd}"/dir1/dir_only_in_dir1
|
||||||
|
touch "${tmpd}/dir1/dir_only_in_dir1/x"
|
||||||
mkdir -p "${tmpd}"/dir1/common_dir
|
mkdir -p "${tmpd}"/dir1/common_dir
|
||||||
|
touch "${tmpd}/dir1/common_dir/y"
|
||||||
echo 'this file is the same' > "${tmpd}"/dir1/common_file
|
echo 'this file is the same' > "${tmpd}"/dir1/common_file
|
||||||
echo 'in dir1' > "${tmpd}"/dir1/not_the_same
|
echo 'in dir1' > "${tmpd}"/dir1/not_the_same
|
||||||
echo 'This is a file in dir1' > "${tmpd}"/dir1/file_in_dir1
|
echo 'This is a file in dir1' > "${tmpd}"/dir1/file_in_dir1
|
||||||
@@ -61,12 +64,14 @@ echo 'first' > "${tmpd}"/dir1/sub/sub2/different
|
|||||||
mkdir "${tmpd}"/dir2
|
mkdir "${tmpd}"/dir2
|
||||||
touch "${tmpd}"/dir2/file_only_in_dir2
|
touch "${tmpd}"/dir2/file_only_in_dir2
|
||||||
mkdir -p "${tmpd}"/dir2/common_dir
|
mkdir -p "${tmpd}"/dir2/common_dir
|
||||||
|
touch "${tmpd}/dir2/common_dir/z"
|
||||||
echo 'this file is the same' > "${tmpd}"/dir2/common_file
|
echo 'this file is the same' > "${tmpd}"/dir2/common_file
|
||||||
echo 'in dir2' > "${tmpd}"/dir2/not_the_same
|
echo 'in dir2' > "${tmpd}"/dir2/not_the_same
|
||||||
mkdir -p "${tmpd}"/dir2/file_in_dir1
|
mkdir -p "${tmpd}"/dir2/file_in_dir1
|
||||||
mkdir -p "${tmpd}"/dir2/sub/sub2
|
mkdir -p "${tmpd}"/dir2/sub/sub2
|
||||||
echo 'modified' > "${tmpd}"/dir2/sub/sub2/different
|
echo 'modified' > "${tmpd}"/dir2/sub/sub2/different
|
||||||
mkdir -p "${tmpd}"/dir2/new/new2
|
mkdir -p "${tmpd}"/dir2/new/new2
|
||||||
|
touch "${tmpd}/dir2/new/new2/new"
|
||||||
mkdir -p "${tmpd}"/dir2/sub1/sub2/sub3/
|
mkdir -p "${tmpd}"/dir2/sub1/sub2/sub3/
|
||||||
touch "${tmpd}"/dir2/sub1/sub2/sub3/file
|
touch "${tmpd}"/dir2/sub1/sub2/sub3/file
|
||||||
#tree ${tmpd}/dir2
|
#tree ${tmpd}/dir2
|
||||||
@@ -99,14 +104,17 @@ echo 'changed' > "${tmpd}"/uniquefile
|
|||||||
# update
|
# update
|
||||||
echo "[+] updating"
|
echo "[+] updating"
|
||||||
cd "${ddpath}" | ${bin} update -c "${cfg}" -f --verbose "${tmpd}"/uniquefile "${tmpd}"/dir1
|
cd "${ddpath}" | ${bin} update -c "${cfg}" -f --verbose "${tmpd}"/uniquefile "${tmpd}"/dir1
|
||||||
|
grep 'changed' "${dotpath}/${tmpd}/uniquefile"
|
||||||
|
[ ! -e "${dotpath}/${tmpd}/dir1/file_only_in_dir2" ] && echo "file_only_in_dir2 not found" && exit 1
|
||||||
|
[ -f "${dotpath}/${tmpd}/dir1/file_in_dir1" ] && echo "directory \"file_in_dir1\" not removed" && exit 1
|
||||||
|
|
||||||
# manually update
|
# manually update
|
||||||
rm "${basedir}"/dotfiles/"${tmpd}"/dir1/file_in_dir1
|
mkdir -p "${dotpath}/${tmpd}/dir1/file_in_dir1"
|
||||||
mkdir -p "${basedir}"/dotfiles/"${tmpd}"/dir1/file_in_dir1
|
|
||||||
|
|
||||||
# ensure changes applied correctly
|
# ensure changes applied correctly
|
||||||
echo "diff dir1"
|
echo "diff dir1"
|
||||||
diff -r --suppress-common-lines "${tmpd}"/dir1 "${basedir}"/dotfiles/"${tmpd}"/dir1
|
tree "${tmpd}"/dir1
|
||||||
|
diff -r --suppress-common-lines "${tmpd}"/dir1 "${dotpath}/${tmpd}/dir1"
|
||||||
echo "diff uniquefile"
|
echo "diff uniquefile"
|
||||||
diff "${tmpd}"/uniquefile "${basedir}"/dotfiles/"${tmpd}"/uniquefile
|
diff "${tmpd}"/uniquefile "${basedir}"/dotfiles/"${tmpd}"/uniquefile
|
||||||
[ ! -e "${basedir}"/dotfiles/"${tmpd}"/dir1/sub1/sub2/sub3/file ] && echo "sub does not exist" && exit 1
|
[ ! -e "${basedir}"/dotfiles/"${tmpd}"/dir1/sub1/sub2/sub3/file ] && echo "sub does not exist" && exit 1
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class TestCompare(unittest.TestCase):
|
|||||||
def compare(self, opt, tmp, nbdotfiles):
|
def compare(self, opt, tmp, nbdotfiles):
|
||||||
"""compare"""
|
"""compare"""
|
||||||
dotfiles = opt.dotfiles
|
dotfiles = opt.dotfiles
|
||||||
self.assertTrue(len(dotfiles) == nbdotfiles)
|
self.assertEqual(len(dotfiles), nbdotfiles)
|
||||||
templ = Templategen(base=opt.dotpath, debug=True)
|
templ = Templategen(base=opt.dotpath, debug=True)
|
||||||
inst = Installer(create=opt.create, backup=opt.backup,
|
inst = Installer(create=opt.create, backup=opt.backup,
|
||||||
dry=opt.dry, base=opt.dotpath, debug=opt.debug)
|
dry=opt.dry, base=opt.dotpath, debug=opt.debug)
|
||||||
@@ -96,6 +96,7 @@ class TestCompare(unittest.TestCase):
|
|||||||
df5 = get_tempdir()
|
df5 = get_tempdir()
|
||||||
self.assertTrue(os.path.exists(df5))
|
self.assertTrue(os.path.exists(df5))
|
||||||
self.addCleanup(clean, df5)
|
self.addCleanup(clean, df5)
|
||||||
|
_, _ = create_random_file(df5)
|
||||||
|
|
||||||
df6, _ = create_random_file(df5)
|
df6, _ = create_random_file(df5)
|
||||||
self.assertTrue(os.path.exists(df6))
|
self.assertTrue(os.path.exists(df6))
|
||||||
|
|||||||
Reference in New Issue
Block a user