Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/tests/frontend/autoremove.sh
2065 views
1
#! /usr/bin/env atf-sh
2
3
. $(atf_get_srcdir)/test_environment.sh
4
5
tests_init \
6
autoremove \
7
autoremove_quiet \
8
autoremove_dryrun
9
10
autoremove_prep() {
11
touch file1
12
touch file2
13
14
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg pkg1 test 1
15
cat << EOF >> pkg1.ucl
16
files: {
17
${TMPDIR}/file1: "",
18
${TMPDIR}/file2: "",
19
}
20
scripts: {
21
post-deinstall: "exit 1"
22
}
23
EOF
24
25
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg dep1 master 1
26
cat << EOF >> dep1.ucl
27
deps: {
28
test {
29
origin: test,
30
version: 1
31
}
32
}
33
EOF
34
35
atf_check \
36
-o match:".*Installing.*\.\.\.$" \
37
-e empty \
38
-s exit:0 \
39
pkg register -A -M pkg1.ucl
40
41
atf_check \
42
-o match:".*Installing.*\.\.\.$" \
43
-e empty \
44
-s exit:0 \
45
pkg register -M dep1.ucl
46
47
atf_check \
48
-o match:".*Deinstalling.*\.\.\.$" \
49
-e empty \
50
-s exit:0 \
51
pkg delete -y master
52
}
53
54
autoremove_body() {
55
autoremove_prep
56
57
atf_check \
58
-o match:"Deinstalling test-1\.\.\." \
59
-e inline:"${PROGNAME}: POST-DEINSTALL script failed\n" \
60
-s exit:0 \
61
pkg autoremove -y
62
63
atf_check \
64
-o empty \
65
-e empty \
66
-s exit:0 \
67
pkg info
68
69
test ! -f ${TMPDIR}/file1 -o ! -f ${TMPDIR}/file2 || atf_fail "Files are still present"
70
}
71
72
autoremove_no_scripts_body() {
73
autoremove_prep
74
75
atf_check \
76
-o match:"Deinstalling test-1\.\.\." \
77
-e empty \
78
-s exit:0 \
79
pkg autoremove -yDq
80
81
atf_check \
82
-o empty \
83
-e empty \
84
-s exit:0 \
85
pkg info
86
87
test ! -f ${TMPDIR}/file1 -o ! -f ${TMPDIR}/file2 || atf_fail "Files are still present"
88
}
89
90
91
autoremove_quiet_body() {
92
autoremove_prep
93
94
atf_check \
95
-o empty \
96
-e inline:"${PROGNAME}: POST-DEINSTALL script failed\n" \
97
-s exit:0 \
98
pkg autoremove -yq
99
100
atf_check \
101
-o empty \
102
-e empty \
103
-s exit:0 \
104
pkg info
105
106
test ! -f ${TMPDIR}/file1 -o ! -f ${TMPDIR}/file2 || atf_fail "Files are still present"
107
}
108
109
autoremove_dryrun_body() {
110
autoremove_prep
111
112
atf_check \
113
-o match:"^Installed packages to be REMOVED:$" \
114
-o match:"^ test: 1$" \
115
-e empty \
116
-s exit:0 \
117
pkg autoremove -yn
118
119
atf_check \
120
-o match:"^test-1 a test$" \
121
-e empty \
122
-s exit:0 \
123
pkg info
124
125
test -f ${TMPDIR}/file1 -o -f ${TMPDIR}/file2 || atf_fail "Files are missing"
126
}
127
128