| |
test -d dir && atf_fail "'dir' still present"
|
| |
test -d ${TMPDIR} || atf_fail "Prefix has been removed"
|
| |
}
|
| + |
|
| + |
delete_dry_run_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
|
| + |
touch file1
|
| + |
cat << EOF >> test.ucl
|
| + |
files: {
|
| + |
${TMPDIR}/file1: "",
|
| + |
}
|
| + |
EOF
|
| + |
atf_check -o ignore pkg register -M test.ucl
|
| + |
|
| + |
# -n: dry run should show what would be removed
|
| + |
atf_check \
|
| + |
-o match:"REMOVED" \
|
| + |
-o match:"test" \
|
| + |
-s exit:0 \
|
| + |
pkg delete -n test
|
| + |
|
| + |
# Package should still be installed
|
| + |
atf_check \
|
| + |
-s exit:0 \
|
| + |
pkg info -e test
|
| + |
}
|
| + |
|
| + |
delete_dry_run_no_remove_body() {
|
| + |
touch file1
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
|
| + |
cat << EOF >> test.ucl
|
| + |
files: {
|
| + |
${TMPDIR}/file1: "",
|
| + |
}
|
| + |
EOF
|
| + |
atf_check -o ignore pkg register -M test.ucl
|
| + |
|
| + |
# Dry run should not remove files
|
| + |
atf_check -o ignore -s exit:0 pkg delete -ny test
|
| + |
|
| + |
test -f file1 || atf_fail "'file1' was removed during dry run"
|
| + |
|
| + |
# Package should still be queryable
|
| + |
atf_check \
|
| + |
-o match:"test-1" \
|
| + |
-s exit:0 \
|
| + |
pkg info test
|
| + |
}
|
| + |
|
| + |
delete_quiet_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
|
| + |
atf_check -o ignore pkg register -M test.ucl
|
| + |
|
| + |
# -q: quiet mode should suppress output
|
| + |
atf_check \
|
| + |
-o empty \
|
| + |
-s exit:0 \
|
| + |
pkg delete -yq test
|
| + |
|
| + |
# Package should be gone
|
| + |
atf_check \
|
| + |
-s exit:1 \
|
| + |
pkg info -e test
|
| + |
}
|
| + |
|
| + |
delete_glob_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "libfoo" "libfoo" "1"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "libbar" "libbar" "2"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "baz" "baz" "3"
|
| + |
|
| + |
atf_check -o ignore pkg register -M libfoo.ucl
|
| + |
atf_check -o ignore pkg register -M libbar.ucl
|
| + |
atf_check -o ignore pkg register -M baz.ucl
|
| + |
|
| + |
# -g: glob match should delete lib* only
|
| + |
atf_check \
|
| + |
-o match:"Deinstalling libfoo" \
|
| + |
-o match:"Deinstalling libbar" \
|
| + |
-s exit:0 \
|
| + |
pkg delete -yfg 'lib*'
|
| + |
|
| + |
# baz should remain
|
| + |
atf_check -s exit:0 pkg info -e baz
|
| + |
|
| + |
# lib* should be gone
|
| + |
atf_check -s exit:1 pkg info -e libfoo
|
| + |
atf_check -s exit:1 pkg info -e libbar
|
| + |
}
|
| + |
|
| + |
delete_regex_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "libfoo" "libfoo" "1"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "libbar" "libbar" "2"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "baz" "baz" "3"
|
| + |
|
| + |
atf_check -o ignore pkg register -M libfoo.ucl
|
| + |
atf_check -o ignore pkg register -M libbar.ucl
|
| + |
atf_check -o ignore pkg register -M baz.ucl
|
| + |
|
| + |
# -x: regex match
|
| + |
atf_check \
|
| + |
-o match:"Deinstalling libfoo" \
|
| + |
-o match:"Deinstalling libbar" \
|
| + |
-o not-match:"baz" \
|
| + |
-s exit:0 \
|
| + |
pkg delete -yx '^lib'
|
| + |
|
| + |
# baz should remain
|
| + |
atf_check -s exit:0 pkg info -e baz
|
| + |
atf_check -s exit:1 pkg info -e libfoo
|
| + |
atf_check -s exit:1 pkg info -e libbar
|
| + |
}
|
| + |
|
| + |
delete_nonexistent_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
|
| + |
atf_check -o ignore pkg register -M test.ucl
|
| + |
|
| + |
# Deleting a package that does not exist
|
| + |
atf_check \
|
| + |
-o match:"No packages matched" \
|
| + |
-s exit:1 \
|
| + |
pkg delete -y nosuchpkg
|
| + |
}
|
| + |
|
| + |
delete_locked_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
|
| + |
atf_check -o ignore pkg register -M test.ucl
|
| + |
|
| + |
# Lock the package
|
| + |
atf_check -o ignore -s exit:0 pkg lock -y test
|
| + |
|
| + |
# Attempt to delete locked package should fail (exit 7 = EPKG_LOCKED)
|
| + |
atf_check \
|
| + |
-o match:"locked" \
|
| + |
-s exit:7 \
|
| + |
pkg delete -y test
|
| + |
|
| + |
# Package should still be installed
|
| + |
atf_check -s exit:0 pkg info -e test
|
| + |
|
| + |
# Unlock and delete should work
|
| + |
atf_check -o ignore -s exit:0 pkg unlock -y test
|
| + |
atf_check -o ignore -s exit:0 pkg delete -y test
|
| + |
atf_check -s exit:1 pkg info -e test
|
| + |
}
|
| + |
|
| + |
delete_multiple_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "1"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "bar" "bar" "2"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "baz" "baz" "3"
|
| + |
|
| + |
atf_check -o ignore pkg register -M foo.ucl
|
| + |
atf_check -o ignore pkg register -M bar.ucl
|
| + |
atf_check -o ignore pkg register -M baz.ucl
|
| + |
|
| + |
# Delete two packages at once, third should remain
|
| + |
atf_check \
|
| + |
-o match:"Deinstalling foo" \
|
| + |
-o match:"Deinstalling bar" \
|
| + |
-o not-match:"baz" \
|
| + |
-s exit:0 \
|
| + |
pkg delete -y foo bar
|
| + |
|
| + |
atf_check -s exit:1 pkg info -e foo
|
| + |
atf_check -s exit:1 pkg info -e bar
|
| + |
atf_check -s exit:0 pkg info -e baz
|
| + |
}
|
| + |
|
| + |
delete_no_scripts_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
|
| + |
cat << EOF >> test.ucl
|
| + |
scripts: {
|
| + |
pre-deinstall: "echo PRESCRIPT >> ${TMPDIR}/scriptlog",
|
| + |
post-deinstall: "echo POSTSCRIPT >> ${TMPDIR}/scriptlog",
|
| + |
}
|
| + |
EOF
|
| + |
atf_check -o ignore pkg register -M test.ucl
|
| + |
|
| + |
# -D: skip scripts
|
| + |
atf_check \
|
| + |
-o match:"Deinstalling test" \
|
| + |
-s exit:0 \
|
| + |
pkg delete -yD test
|
| + |
|
| + |
# Script log should not exist (scripts were not run)
|
| + |
test -f ${TMPDIR}/scriptlog && atf_fail "Scripts were executed with -D"
|
| + |
return 0
|
| + |
}
|
| + |
|
| + |
delete_all_preserves_pkg_body() {
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "1"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "bar" "bar" "1"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkg" "pkg" "1"
|
| + |
|
| + |
atf_check -o ignore pkg register -M foo.ucl
|
| + |
atf_check -o ignore pkg register -M bar.ucl
|
| + |
atf_check -o ignore pkg register -M pkg.ucl
|
| + |
|
| + |
# -a without -f should preserve pkg itself
|
| + |
atf_check -o ignore -s exit:0 pkg delete -ay
|
| + |
|
| + |
# pkg should still be installed
|
| + |
atf_check -s exit:0 pkg info -e pkg
|
| + |
|
| + |
# others should be gone
|
| + |
atf_check -s exit:1 pkg info -e foo
|
| + |
atf_check -s exit:1 pkg info -e bar
|
| + |
}
|
| + |
|
| + |
delete_recursive_force_body() {
|
| + |
# A depends on B depends on C. Default delete is recursive.
|
| + |
# -f forces non-recursive even with -R.
|
| + |
# Verify that -f only deletes the target, leaving rdeps.
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgC" "pkgC" "1"
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgB" "pkgB" "1"
|
| + |
cat << EOF >> pkgB.ucl
|
| + |
deps: {
|
| + |
pkgC {
|
| + |
origin: pkgC,
|
| + |
version: "1"
|
| + |
}
|
| + |
}
|
| + |
EOF
|
| + |
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgA" "pkgA" "1"
|
| + |
cat << EOF >> pkgA.ucl
|
| + |
deps: {
|
| + |
pkgB {
|
| + |
origin: pkgB,
|
| + |
version: "1"
|
| + |
}
|
| + |
}
|
| + |
EOF
|
| + |
|
| + |
atf_check -o ignore pkg register -M pkgC.ucl
|
| + |
atf_check -o ignore pkg register -M pkgB.ucl
|
| + |
atf_check -o ignore pkg register -M pkgA.ucl
|
| + |
|
| + |
# -f: force non-recursive, only pkgC is removed
|
| + |
atf_check \
|
| + |
-o match:"Deinstalling pkgC" \
|
| + |
-o not-match:"pkgB" \
|
| + |
-o not-match:"pkgA" \
|
| + |
-s exit:0 \
|
| + |
pkg delete -yf pkgC
|
| + |
|
| + |
# pkgA and pkgB should still be installed
|
| + |
atf_check -s exit:0 pkg info -e pkgA
|
| + |
atf_check -s exit:0 pkg info -e pkgB
|
| + |
atf_check -s exit:1 pkg info -e pkgC
|
| + |
}
|