mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 23:44:16 +00:00
linting
This commit is contained in:
7
scripts/check-syntax.sh
vendored
7
scripts/check-syntax.sh
vendored
@@ -54,6 +54,13 @@ find . -iname '*.sh' | while read -r script; do
|
|||||||
-e SC1004 \
|
-e SC1004 \
|
||||||
"${script}"
|
"${script}"
|
||||||
done
|
done
|
||||||
|
shellcheck -x \
|
||||||
|
-e SC2002 \
|
||||||
|
-e SC2126 \
|
||||||
|
-e SC2129 \
|
||||||
|
-e SC2181 \
|
||||||
|
-e SC1004 \
|
||||||
|
"tests-ng/helpers"
|
||||||
|
|
||||||
# check other python scripts
|
# check other python scripts
|
||||||
echo "-----------------------------------------"
|
echo "-----------------------------------------"
|
||||||
|
|||||||
2
tests-ng/chmod-install.sh
vendored
2
tests-ng/chmod-install.sh
vendored
@@ -267,7 +267,7 @@ chmod 600 "${tmps}"/dotfiles/nomode
|
|||||||
echo "nomode" > "${tmpd}"/nomode
|
echo "nomode" > "${tmpd}"/nomode
|
||||||
chmod 700 "${tmpd}"/nomode
|
chmod 700 "${tmpd}"/nomode
|
||||||
(
|
(
|
||||||
d "${ddpath}"
|
cd "${ddpath}"
|
||||||
printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode
|
printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode
|
||||||
exit $?
|
exit $?
|
||||||
)
|
)
|
||||||
|
|||||||
5
tests-ng/dynvariables.sh
vendored
5
tests-ng/dynvariables.sh
vendored
@@ -91,7 +91,7 @@ profiles:
|
|||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat "${cfg}"
|
||||||
|
|
||||||
# create the dotfile
|
# create the dotfile
|
||||||
echo "{{@@ var1 @@}}" > "${tmps}"/dotfiles/abc
|
echo "{{@@ var1 @@}}" > "${tmps}"/dotfiles/abc
|
||||||
@@ -104,12 +104,13 @@ echo "test" >> "${tmps}"/dotfiles/abc
|
|||||||
# install
|
# install
|
||||||
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V
|
||||||
|
|
||||||
|
#cat "${cfg}"
|
||||||
echo "-----"
|
echo "-----"
|
||||||
cat "${tmpd}"/abc
|
cat "${tmpd}"/abc
|
||||||
echo "-----"
|
echo "-----"
|
||||||
|
|
||||||
grep '^this is some test' "${tmpd}"/abc >/dev/null
|
grep '^this is some test' "${tmpd}"/abc >/dev/null
|
||||||
grep '^# author: deadc0de6' "${tmpd}"/abc >/dev/null
|
grep '^# shellcheck' "${tmpd}"/abc >/dev/null
|
||||||
grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null
|
grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null
|
||||||
grep "^${TESTENV}" "${tmpd}"/abc > /dev/null
|
grep "^${TESTENV}" "${tmpd}"/abc > /dev/null
|
||||||
grep '^4ravd_eht' "${tmpd}"/abc >/dev/null
|
grep '^4ravd_eht' "${tmpd}"/abc >/dev/null
|
||||||
|
|||||||
14
tests-ng/helpers
vendored
14
tests-ng/helpers
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
# shellcheck disable=SC2148
|
||||||
# author: deadc0de6 (https://github.com/deadc0de6)
|
# author: deadc0de6 (https://github.com/deadc0de6)
|
||||||
# Copyright (c) 2017, deadc0de6
|
# Copyright (c) 2017, deadc0de6
|
||||||
#
|
#
|
||||||
@@ -14,6 +15,7 @@ declare -a to_be_cleared
|
|||||||
clear_on_exit()
|
clear_on_exit()
|
||||||
{
|
{
|
||||||
local len="${#to_be_cleared[*]}"
|
local len="${#to_be_cleared[*]}"
|
||||||
|
# shellcheck disable=SC2004
|
||||||
to_be_cleared[${len}]="$1"
|
to_be_cleared[${len}]="$1"
|
||||||
if [ "${len}" = "0" ]; then
|
if [ "${len}" = "0" ]; then
|
||||||
# set trap
|
# set trap
|
||||||
@@ -37,14 +39,16 @@ on_exit()
|
|||||||
create_dir()
|
create_dir()
|
||||||
{
|
{
|
||||||
dirs="a/aa a/ab a/ac b/ba c"
|
dirs="a/aa a/ab a/ac b/ba c"
|
||||||
mkdir -p ${1}
|
mkdir -p "${1}"
|
||||||
for d in ${dirs}; do
|
for d in ${dirs}; do
|
||||||
# create some dirs
|
# create some dirs
|
||||||
mkdir -p ${1}/${d}
|
mkdir -p "${1}"/"${d}"
|
||||||
# create some files
|
# create some files
|
||||||
fn=`echo ${d} | sed 's#/#-#g'`
|
# shellcheck disable=SC2001
|
||||||
|
fn=$(echo "${d}" | sed 's#/#-#g')
|
||||||
f="${1}/${d}/${fn}"
|
f="${1}/${d}/${fn}"
|
||||||
echo "${d}" > ${f}
|
echo "${d}" > "${f}"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
token=${f}
|
token=${f}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -54,7 +58,7 @@ create_dir()
|
|||||||
# $1: path to save to
|
# $1: path to save to
|
||||||
create_conf()
|
create_conf()
|
||||||
{
|
{
|
||||||
cat > ${1} << _EOF
|
cat > "${1}" << _EOF
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
|
|||||||
2
tests-ng/profile-dynvariables.sh
vendored
2
tests-ng/profile-dynvariables.sh
vendored
@@ -126,7 +126,7 @@ grep '^local1' "${tmpd}"/abc >/dev/null
|
|||||||
grep '^global2' "${tmpd}"/abc >/dev/null
|
grep '^global2' "${tmpd}"/abc >/dev/null
|
||||||
grep '^local2' "${tmpd}"/abc >/dev/null
|
grep '^local2' "${tmpd}"/abc >/dev/null
|
||||||
# test dynvariables
|
# test dynvariables
|
||||||
grep "^# author: deadc0de6" "${tmpd}"/abc >/dev/null
|
grep "^# shellcheck" "${tmpd}"/abc >/dev/null
|
||||||
grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null
|
grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null
|
||||||
grep "^${TESTENV2}" "${tmpd}"/abc > /dev/null
|
grep "^${TESTENV2}" "${tmpd}"/abc > /dev/null
|
||||||
grep "^cba" "${tmpd}"/abc >/dev/null
|
grep "^cba" "${tmpd}"/abc >/dev/null
|
||||||
|
|||||||
18
tests-ng/re-import.sh
vendored
18
tests-ng/re-import.sh
vendored
@@ -122,9 +122,11 @@ cat "${cfg}"
|
|||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
||||||
cat "${cfg}" | grep "${HOME}/.dotdrop.test" >/dev/null 2>&1
|
# shellcheck disable=SC2088
|
||||||
|
cat "${cfg}" | grep '~/.dotdrop.test'
|
||||||
grep 'original' "${tmps}"/dotfiles/dotdrop.test
|
grep 'original' "${tmps}"/dotfiles/dotdrop.test
|
||||||
nb=$(cat "${cfg}" | grep "${HOME}/.dotdrop.test" | wc -l)
|
# shellcheck disable=SC2088
|
||||||
|
nb=$(cat "${cfg}" | grep '~/.dotdrop.test' | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1
|
[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1
|
||||||
|
|
||||||
# re-import without changing
|
# re-import without changing
|
||||||
@@ -134,9 +136,11 @@ cat "${cfg}"
|
|||||||
|
|
||||||
# test is only once
|
# test is only once
|
||||||
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
||||||
cat "${cfg}" | grep "${HOME}/.dotdrop.test" >/dev/null 2>&1
|
# shellcheck disable=SC2088
|
||||||
|
cat "${cfg}" | grep '~/.dotdrop.test' >/dev/null 2>&1
|
||||||
grep 'original' "${tmps}"/dotfiles/dotdrop.test
|
grep 'original' "${tmps}"/dotfiles/dotdrop.test
|
||||||
nb=$(cat "${cfg}" | grep "${HOME}/.dotdrop.test" | wc -l)
|
# shellcheck disable=SC2088
|
||||||
|
nb=$(cat "${cfg}" | grep '~/.dotdrop.test' | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
||||||
|
|
||||||
# re-import with changes
|
# re-import with changes
|
||||||
@@ -147,9 +151,11 @@ cat "${cfg}"
|
|||||||
|
|
||||||
# test is only once
|
# test is only once
|
||||||
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
||||||
cat "${cfg}" | grep "${HOME}/.dotdrop.test" >/dev/null 2>&1
|
# shellcheck disable=SC2088
|
||||||
|
cat "${cfg}" | grep '~/.dotdrop.test' >/dev/null 2>&1
|
||||||
grep 'modified' "${tmps}"/dotfiles/dotdrop.test
|
grep 'modified' "${tmps}"/dotfiles/dotdrop.test
|
||||||
nb=$(cat "${cfg}" | grep "${HOME}/.dotdrop.test" | wc -l)
|
# shellcheck disable=SC2088
|
||||||
|
nb=$(cat "${cfg}" | grep '~/.dotdrop.test' | wc -l)
|
||||||
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user