Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix pkg upgrade detection and add a test about it
Baptiste Daroussin committed 10 years ago
commit e55670949c9b89bafd0cb0bf65c6cadc63b85333
parent 8a955e6
4 files changed +72 -1
modified libpkg/pkg_jobs.c
@@ -728,7 +728,7 @@ new_pkg_version(struct pkg_jobs *j)

		if (nit) {
			DL_FOREACH(nit, cit) {
-
				if (pkg_version_change_between (p, cit->pkg) == PKG_UPGRADE) {
+
				if (pkg_version_change_between (cit->pkg, p) == PKG_UPGRADE) {
					/* We really have newer version which is not installed */
					ret = true;
				}
modified tests/Makefile.am
@@ -81,6 +81,7 @@ tests_scripts= \
		frontend/alias.sh \
		frontend/annotate.sh \
		frontend/autoremove.sh \
+
		frontend/autoupgrade.sh \
		frontend/config.sh \
		frontend/conflicts.sh \
		frontend/conflicts-multirepo.sh \
modified tests/frontend/Kyuafile.in
@@ -7,6 +7,7 @@ atf_test_program{name='add'}
atf_test_program{name='alias'}
atf_test_program{name='annotate'}
atf_test_program{name='autoremove'}
+
atf_test_program{name='autoupgrade'}
atf_test_program{name='config'}
atf_test_program{name='conflicts'}
atf_test_program{name='conflicts-multirepo'}
added tests/frontend/autoupgrade.sh
@@ -0,0 +1,69 @@
+
#! /usr/bin/env atf-sh
+

+
. $(atf_get_srcdir)/test_environment.sh
+

+
tests_init \
+
	autoupgrade
+

+
autoupgrade_body() {
+

+
	cat << EOF > pkg1.ucl
+
name: pkg
+
origin: test
+
version: 1
+
maintainer: test
+
categories: [test]
+
comment: a test
+
www: http://test
+
prefix: /usr/local
+
desc: <<EOD
+
Yet another test
+
EOD
+
EOF
+

+
	cat << EOF > pkg2.ucl
+
name: pkg
+
origin: test
+
version: 1_1
+
maintainer: test
+
categories: [test]
+
comment: a test
+
www: http://test
+
prefix: /usr/local
+
desc: <<EOD
+
Yet another test
+
EOD
+
EOF
+

+
	atf_check \
+
		-o match:".*Installing.*\.\.\.$" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg register -M pkg1.ucl
+

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

+
	atf_check \
+
		-o inline:"Creating repository in .:  done\nPacking files for repository:  done\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg repo .
+

+
	cat << EOF > repo.conf
+
local: {
+
	url: file:///$TMPDIR,
+
	enabled: true
+
}
+
EOF
+

+
	atf_check \
+
		-o match:".*New version of pkg detected.*" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR="$TMPDIR" -o PKG_CACHEDIR="$TMPDIR" upgrade -n
+
}
+