Debian Codegraph @

tests-ng/update-negative-ignore-all-but.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 # author: deadc0de6
3 #
4 # test negative ignore on update
5 # returns 1 in case of error
6 #
7
8 ## start-cookie
9 set -eu -o errtrace -o pipefail
10 cur=$(cd "$(dirnamescip-shell system . . dirname. "${0}")" && pwdscip-shell system . . pwd.)
11 ddpath="${cur}/../"
12 PPATH="{PYTHONPATH:-}"
13 export PYTHONPATH="${ddpath}:${PPATH}"
14 altbin="python3 -m dotdrop.dotdrop"
15 if hash coverage 2>/dev/nullscip-shell filesystem . . `/dev/null`.; then
16 mkdirscip-shell system . . mkdir. -p coverages/
17 altbin="coverage run -p --data-file coverages/coverage --source=dotdrop -m dotdrop.dotdrop"
18 fi
19 bin="${DT_BIN:-${altbin}}"
20 # shellcheck source=tests-ng/helpers
21 source "${cur}"/helpers
22 echoscip-shell system . . echo. -e "$(tputscip-shell system . . tput. setaf 6)==> RUNNING $(basenamescip-shell system . . basename. "${BASH_SOURCE[0]}") <==$(tputscip-shell system . . tput. sgr0)"
23 ## end-cookie
24
25 ################################################################
26 # this is the test
27 ################################################################
28
29 # $1 pattern
30 # $2 path
31 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail().()
32 {
33 grepscip-shell system . . grep. "${1}" "${2}" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || (echoscip-shell system . . echo. "pattern \"${1}\" not found in ${2}" && exit 1)
34 }
35
36 # dotdrop directory
37 basedir=$(mktempscip-shell system . . mktemp. -d --suffix='-dotdrop-tests' 2>/dev/nullscip-shell filesystem . . `/dev/null`. || mktempscip-shell system . . mktemp. -d)
38 # the dotfile to be updated
39 tmpd=$(mktempscip-shell system . . mktemp. -d --suffix='-dotdrop-tests' 2>/dev/nullscip-shell filesystem . . `/dev/null`. || mktempscip-shell system . . mktemp. -d)
40
41 echoscip-shell system . . echo. "[+] dotdrop dir: ${basedir}"
42 echoscip-shell system . . echo. "[+] dotpath dir: ${basedir}/dotfiles"
43 echoscip-shell system . . echo. "[+] dst dir: ${tmpd}"
44
45 # dotfiles in dotdrop
46 mkdirscip-shell system . . mkdir. -p "${basedir}"/dotfiles/a/{b,c,x}
47 echoscip-shell system . . echo. 'original' > "${basedir}"/dotfiles/a/b/abfile1
48 echoscip-shell system . . echo. 'original' > "${basedir}"/dotfiles/a/b/abfile2
49 echoscip-shell system . . echo. 'original' > "${basedir}"/dotfiles/a/b/abfile3
50 echoscip-shell system . . echo. 'original' > "${basedir}"/dotfiles/a/c/acfile
51 echoscip-shell system . . echo. 'original' > "${basedir}"/dotfiles/a/x/axfile
52
53 # filesystem
54 mkdirscip-shell system . . mkdir. -p "${tmpd}"/a/{b,c,d,x}
55 echoscip-shell system . . echo. "updated" > "${tmpd}/a/b/abfile1"
56 echoscip-shell system . . echo. "updated" > "${tmpd}/a/b/abfile2"
57 echoscip-shell system . . echo. "updated" > "${tmpd}/a/b/abfile3"
58 echoscip-shell system . . echo. "updated" > "${tmpd}/a/c/acfile"
59 echoscip-shell system . . echo. "updated" > "${tmpd}/a/d/adfile"
60 echoscip-shell system . . echo. "updated" > "${tmpd}/a/x/axfile"
61
62 clear_on_exit "${basedir}"
63 clear_on_exit "${tmpd}"
64
65 # create the config file
66 cfg="${basedir}/config.yaml"
67 catscip-shell system . . cat. > "${cfg}" << _EOF
68 config:
69 backup: false
70 create: true
71 dotpath: dotfiles
72 dotfiles:
73 d_abc:
74 dst: ${tmpd}/a
75 src: a
76 upignore:
77 - "*"
78 - "!*/c/**"
79 - "!*/d/**"
80 - "!x/"
81 profiles:
82 p1:
83 dotfiles:
84 - d_abc
85 _EOF
86
87 # update
88 echoscip-shell system . . echo. "[+] update"
89 cd "${ddpath}" | ${bin} update -f -c "${cfg}" --verbose --profile=p1 --key d_abc
90
91 # check files haven't been updated
92 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail(). "original" "${basedir}"/dotfiles/a/b/abfile1
93 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail(). "original" "${basedir}"/dotfiles/a/b/abfile2
94 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail(). "original" "${basedir}"/dotfiles/a/b/abfile3
95 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail(). "updated" "${basedir}"/dotfiles/a/c/acfile
96 [scip-shell system . . `[`. ! -s "${basedir}"/dotfiles/a/d/adfile ] && echoscip-shell system . . echo. "adfile not updated" && exit 1
97 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail(). "updated" "${basedir}"/dotfiles/a/d/adfile
98 grep_or_failscip-shell shell dotdrop 1.16.1-1 grep_or_fail(). "original" "${basedir}"/dotfiles/a/x/axfile
99
100 echoscip-shell system . . echo. "OK"
101 exit 0