Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Move new_pkg and new_manifest out.
Brad Davis committed 8 years ago
commit 40f84d3736153596bdda63cf0b19dfbe7cc99e07
parent fdebf89
10 files changed +63 -58
modified tests/frontend/config.sh
@@ -14,7 +14,7 @@ duplicatedefault: 2
EOF

	for n in 1 2; do
-
		new_pkg test${n} test ${n}
+
		atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test${n} test ${n}
		echo 'allowduplicate: true' >> test${n}.ucl

	atf_check \
@@ -34,7 +34,7 @@ done

duplicate_pkgs_notallowed_body() {
	for n in 1 2; do
-
		new_pkg test${n} test ${n}
+
		atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test${n} test ${n}
	done

	atf_check \
modified tests/frontend/configmerge.sh
@@ -8,7 +8,7 @@ tests_init \

config_body()
{
-
	new_pkg "test" "test" "1"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	echo "@config ${TMPDIR}/a" > plist

	echo "entry" > a
@@ -30,7 +30,7 @@ config_body()
		-o inline:"entry\naddition\n" \
		cat ${TMPDIR}/target/${TMPDIR}/a

-
	new_pkg "test" "test" "2"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "2"
	echo "entry 2" > a

	atf_check \
@@ -49,7 +49,7 @@ config_body()

config_fileexist_body()
{
-
	new_pkg "test" "test" "1"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	echo "${TMPDIR}/a" > plist

	echo "entry" > a
@@ -67,7 +67,7 @@ config_fileexist_body()
		-o inline:"entry\naddition\n" \
		cat ${TMPDIR}/target/${TMPDIR}/a

-
	new_pkg "test" "test" "2"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "2"
	echo "entry 2" > a
	echo "@config ${TMPDIR}/a" > plist

@@ -89,7 +89,7 @@ config_fileexist_notinpkg_body()
	echo "entry" > ${TMPDIR}/target/${TMPDIR}/a
	unset PKG_DBDIR

-
	new_pkg "test" "test" "2"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "2"
	echo "entry 2" > a
	echo "@config ${TMPDIR}/a" > plist

modified tests/frontend/extract.sh
@@ -14,7 +14,7 @@ tests_init \
basic_body()
{
	echo "test" > a
-
	new_pkg "test" "test" "1" || atf_fail "plop"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
cat << EOF >> test.ucl
files = {
	${TMPDIR}/a: ""
@@ -70,7 +70,7 @@ ${TMPDIR}/target${TMPDIR}/a
basic_dirs_body()
{
	mkdir ${TMPDIR}/plop
-
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
cat << EOF >> test.ucl
directories = {
	${TMPDIR}/plop: y
@@ -98,7 +98,7 @@ setuid_body()
{
	touch ${TMPDIR}/a
	chmod 04554 ${TMPDIR}/a || atf_fail "Fail to chmod"
-
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	cat << EOF >> test.ucl
files = {
	${TMPDIR}/a = ""
@@ -136,7 +136,7 @@ setuid_hardlinks_body()
	ln ${TMPDIR}/a ${TMPDIR}/b
	chmod 04554 ${TMPDIR}/a || atf_fail "Fail to chmod"
	chmod 04554 ${TMPDIR}/b || atf_fail "Fail to chmod"
-
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	cat << EOF >> test.ucl
files = {
	${TMPDIR}/a = ""
@@ -184,7 +184,7 @@ chflags_body()
	# use nodump as it is the only one supported as user, by zfs and by
	# libarchive
	touch ${TMPDIR}/a
-
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	echo "@(,,,nodump) ${TMPDIR}/a" > test.plist
	atf_check \
		-o empty \
@@ -214,7 +214,7 @@ chflags_schg_body()
	test $(id -u) = 0 || atf_skip "Can only be run as root"

	touch ${TMPDIR}/a
-
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	echo "@(root,wheel,,schg) ${TMPDIR}/a" > test.plist
	atf_check \
		-o empty \
@@ -253,7 +253,7 @@ chflags_schg_cleanup()

symlinks_body()
{
-
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	cat << EOF >> test.ucl
files: {
${TMPDIR}/a = "";
modified tests/frontend/install.sh
@@ -10,7 +10,7 @@ tests_init \

metalog_body()
{
-
	new_pkg test test 1 / || atf_fail "Failed to create the ucl file"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test test 1 / || atf_fail "Failed to create the ucl file"
	touch ${TMPDIR}/testfile1 || atf_fail "Failed to create the temp file"
	echo "@(root,wheel,640,) testfile1" > test.plist
	echo "test123" > ${TMPDIR}/testfile2 || atf_fail "Failed to create the temp file"
@@ -70,7 +70,7 @@ EOF

reinstall_body()
{
-
	new_pkg test test 1 /usr/local
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test test 1 /usr/local

	atf_check \
		-o ignore \
@@ -106,7 +106,7 @@ EOF

pre_script_fail_body()
{
-
	new_pkg test test 1
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test test 1
	cat << EOF >> test.ucl
scripts: {
   pre-install: "exit 1"
@@ -127,7 +127,7 @@ EOF

post_script_ignored_body()
{
-
	new_pkg test test 1
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test test 1
	cat << EOF >> test.ucl
scripts: {
   post-install: "exit 1"
modified tests/frontend/issue1445.sh
@@ -8,7 +8,7 @@ tests_init \


dead_symlink_body() {
-
	new_pkg "test" "test" "1" || atf_fail "plop"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	cat << EOF >> test.ucl
directories {
	${TMPDIR}/plop = "y";
@@ -27,7 +27,7 @@ EOF
}

good_symlink_body() {
-
	new_pkg "test" "test" "1" || atf_fail "plop"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	cat << EOF >> test.ucl
directories {
	${TMPDIR}/plop = "y";
modified tests/frontend/register.sh
@@ -58,7 +58,7 @@ EOF
}

register_message_body() {
-
	new_manifest test1 1 "${TMPDIR}"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_manifest test1 1 "${TMPDIR}"
	cat << EOF > +DISPLAY
message
EOF
@@ -71,7 +71,7 @@ message
	atf_check -o match:"message" pkg register -m .
	atf_check -o inline:"${OUTPUT}" pkg info -D test1

-
	new_manifest test2 1 "${TMPDIR}"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_manifest test2 1 "${TMPDIR}"
	cat << EOF > +DISPLAY
[
	{ message: "hey"},
@@ -97,7 +97,7 @@ remove

prefix_is_a_symlink_body()
{
-
	new_pkg "test" "test" "1"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	mkdir -p ${TMPDIR}/${TMPDIR}/plop/bla
	echo "something" > ${TMPDIR}/${TMPDIR}/plop/bla/a
	ln ${TMPDIR}/${TMPDIR}/plop/bla/a ${TMPDIR}/${TMPDIR}/plop/bla/b
modified tests/frontend/repo.sh
@@ -9,7 +9,7 @@ tests_init \
repo_body() {
	touch plop
	touch bla
-
	new_pkg test test 1 "${TMPDIR}"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test test 1 "${TMPDIR}"
	cat >> test.ucl << EOF
files: {
	"${TMPDIR}/plop": ""
@@ -59,8 +59,8 @@ EOF
}

repo_multiversion_body() {
-
	new_pkg test test 1.0 "${TMPDIR}"
-
	new_pkg test1 test 1.1 "${TMPDIR}"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test test 1.0 "${TMPDIR}"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg test1 test 1.1 "${TMPDIR}"
	for i in test test1; do
		atf_check pkg create -M $i.ucl
	done
modified tests/frontend/test_environment.sh.in
@@ -40,34 +40,3 @@ atf_skip_on() {
		atf_skip "$@"
	fi
}
-

-
new_pkg() {
-
	cat << EOF > $1.ucl
-
name: $2
-
origin: $2
-
version: "$3"
-
maintainer: test
-
categories: [test]
-
comment: a test
-
www: http://test
-
prefix: ${4}
-
abi: "*"
-
desc: <<EOD
-
This is a test
-
EOD
-
EOF
-
}
-

-
new_manifest() {
-
	cat << EOF > +MANIFEST
-
name: "$1"
-
origin: $1"
-
version: "$2"
-
arch: "freebsd:*"
-
maintainer: "test"
-
prefix: "${3}"
-
www: "http://test"
-
comment: "a test"
-
desc: "This is a test"
-
EOF
-
}
added tests/frontend/test_subr.sh
@@ -0,0 +1,36 @@
+

+

+
new_pkg() {
+
	cat << EOF > $1.ucl
+
name: $2
+
origin: $2
+
version: "$3"
+
maintainer: test
+
categories: [test]
+
comment: a test
+
www: http://test
+
prefix: ${4}
+
abi: "*"
+
desc: <<EOD
+
This is a test
+
EOD
+
EOF
+
}
+

+
new_manifest() {
+
	cat << EOF > +MANIFEST
+
name: "$1"
+
origin: $1"
+
version: "$2"
+
arch: "freebsd:*"
+
maintainer: "test"
+
prefix: "${3}"
+
www: "http://test"
+
comment: "a test"
+
desc: "This is a test"
+
EOF
+
}
+

+
SUBCMD=$1
+
shift
+
${SUBCMD} $*
modified tests/frontend/vital.sh
@@ -7,7 +7,7 @@ tests_init \

vital_body()
{
-
	new_pkg "test" "test" "1" || atf_fail "plop"
+
	atf_check -s exit:0 $(atf_get_srcdir)/test_subr.sh new_pkg "test" "test" "1"
	cat << EOF >> test.ucl
vital = true;
EOF