Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add tests for pkg add
Baptiste Daroussin committed 11 years ago
commit b7604c470f8061af195208640235fadcc2bc24f9
parent 4245c52
3 files changed +230 -0
modified tests/Makefile.am
@@ -66,6 +66,7 @@ EXTRA_DIST= frontend/png.uclin \
		frontend/sqlite3.uclin \
		Kyuafile \
		frontend/Kyuafile \
+
		frontend/add.shin \
		frontend/annotate.shin \
		frontend/pkg.shin \
		frontend/search.shin \
@@ -87,6 +88,7 @@ tests_programs= pkg_printf \
EXTRA_PROGRAMS=	$(tests_programs)
check_PROGRAMS=	$(tests_programs)
check_SCRIPTS=	frontend/pkg.sh \
+
		frontend/add.sh \
		frontend/annotate.sh \
		frontend/search.sh \
		frontend/version.sh \
modified tests/frontend/Kyuafile
@@ -12,3 +12,4 @@ atf_test_program{name='lock.sh'}
atf_test_program{name='delete.sh'}
atf_test_program{name='create.sh'}
atf_test_program{name='conflicts.sh'}
+
atf_test_program{name='add.sh'}
added tests/frontend/add.shin
@@ -0,0 +1,227 @@
+
#! /usr/bin/env atf-sh
+

+
initialize_pkg() {
+
	export INSTALL_AS_USER=yes
+
	export PKG_DBDIR=.
+

+
	jailed=$(sysctl -n security.jail.jailed || :)
+
	if [ "$jailed" = "1" ]; then
+
		JAILED="[`hostname`] "
+
	fi
+
	touch a
+
	cat << EOF > test.ucl
+
name: test
+
origin: test
+
version: 1
+
maintainer: test
+
categories: [test]
+
comment: a test
+
www: http://test
+
prefix: /
+
abi = "*";
+
desc: <<EOD
+
Yet another test
+
EOD
+
files: {
+
	${TMPDIR}/a: ""
+
}
+
scripts: {
+
	pre-install: <<EOD
+
echo "pre-install"
+
EOD
+
	post-install: <<EOD
+
echo "post-install"
+
EOD
+
}
+
EOF
+

+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -M test.ucl
+
}
+

+
atf_test_case add
+
add_head() {
+
	atf_set "descr" "pkg add"
+
}
+

+
add_body() {
+
	initialize_pkg
+

+
OUTPUT="${JAILED}Installing test-1...
+
pre-install
+
${JAILED}Extracting test-1... done
+
post-install
+
"
+
	atf_check \
+
		-o inline:"${OUTPUT}" \
+
		-e empty \
+
		pkg add test-1.txz
+

+
# test automatic is not set
+
	atf_check \
+
		-o inline:"0\n" \
+
		-e empty \
+
		pkg query "%a" test
+
}
+

+
atf_test_case add_automatic
+
add_automatic_head() {
+
	atf_set "descr" "pkg add -A"
+
}
+
add_automatic_body() {
+
	initialize_pkg
+

+
OUTPUT="${JAILED}Installing test-1...
+
pre-install
+
${JAILED}Extracting test-1... done
+
post-install
+
"
+
	atf_check \
+
		-o inline:"${OUTPUT}" \
+
		-e empty \
+
		pkg add -A test-1.txz
+

+
	atf_check \
+
		-o inline:"1\n" \
+
		-e empty \
+
		pkg query "%a" test
+

+
}
+

+
atf_test_case add_noscript
+
add_noscript_head() {
+
	atf_set "descr" "pkg add -I"
+
}
+
add_noscript_body() {
+
	initialize_pkg
+

+
OUTPUT="${JAILED}Installing test-1...
+
${JAILED}Extracting test-1... done
+
"
+
	cat test-1.txz | atf_check \
+
		-o inline:"${OUTPUT}" \
+
		-e empty \
+
		pkg add -I test-1.txz
+
}
+
atf_test_case add_force
+
add_force_head() {
+
	atf_set "descr" "pkg add -f"
+
}
+
add_force_body() {
+
	initialize_pkg
+
}
+

+
atf_test_case add_accept_missing
+
add_accept_missing_head() {
+
	atf_set "descr" "pkg add -M"
+
}
+
add_accept_missing_body() {
+
	export INSTALL_AS_USER=yes
+
	export PKG_DBDIR=.
+

+
	jailed=$(sysctl -n security.jail.jailed || :)
+
	if [ "$jailed" = "1" ]; then
+
		JAILED="[`hostname`] "
+
	fi
+
	touch a
+
	cat << EOF > test.ucl
+
name: test
+
origin: test
+
version: 1
+
maintainer: test
+
categories: [test]
+
comment: a test
+
www: http://test
+
prefix: /
+
abi = "*";
+
desc: <<EOD
+
Yet another test
+
EOD
+
deps: {
+
	b: {
+
		origin: "wedontcare",
+
		version: "1"
+
	}
+
}
+
files: {
+
	${TMPDIR}/a: ""
+
}
+
scripts: {
+
	pre-install: <<EOD
+
echo "pre-install"
+
EOD
+
	post-install: <<EOD
+
echo "post-install"
+
EOD
+
}
+
EOF
+

+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -M test.ucl
+

+
	atf_check \
+
		-o inline:"${JAILED}Installing test-1...\n\nFailed to install the following 1 package(s): test-1.txz\n" \
+
		-e inline:"pkg: Missing dependency 'b-1'\n" \
+
		-s exit:70 \
+
		pkg add test-1.txz
+

+
OUTPUT="${JAILED}Installing test-1...
+
pre-install
+
${JAILED}Extracting test-1... done
+
post-install
+
"
+
	atf_check \
+
		-o inline:"${OUTPUT}" \
+
		-e inline:"pkg: Missing dependency 'b-1'\n" \
+
		-s exit:0 \
+
		pkg add -M test-1.txz
+
}
+

+
atf_test_case add_quiet
+
add_quiet_head() {
+
	atf_set "descr" "pkg add -q"
+
}
+
add_quiet_body() {
+
	initialize_pkg
+

+
	atf_check \
+
		-o inline:"pre-install\npost-install\n" \
+
		-e empty \
+
		pkg add -q ./test-1.txz
+
}
+

+
atf_test_case add_stdin
+
add_stdin_head() {
+
	atf_set "descr" "pkg add -"
+
}
+
add_stdin_body() {
+
	initialize_pkg
+

+
OUTPUT="${JAILED}Installing test-1...
+
pre-install
+
${JAILED}Extracting test-1... done
+
post-install
+
"
+
	cat test-1.txz | atf_check \
+
		-o inline:"${OUTPUT}" \
+
		-e empty \
+
		pkg add -
+
}
+

+
atf_init_test_cases() {
+
        . $(atf_get_srcdir)/test_environment.sh
+

+
	atf_add_test_case add
+
	atf_add_test_case add_automatic
+
	atf_add_test_case add_noscript
+
	atf_add_test_case add_force
+
	atf_add_test_case add_accept_missing
+
	atf_add_test_case add_quiet
+
	atf_add_test_case add_stdin
+
}