Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
info: fix version comparison after e1841f2e9
Baptiste Daroussin committed 1 month ago
commit 60bea382521803b2a245a9e154c25ae64e6fbf78
parent 9169aa5
2 files changed +37 -3
modified src/info.c
@@ -384,10 +384,13 @@ exec_info(int argc, char **argv)
		if (argc > 0) {
			for (j = 0; pkgname[j] != '\0'; j++) {
				if (pkgname[j] == '<' || pkgname[j] == '>' || pkgname[j] == '=') {
-
					if (pkgversion)
+
					if (pkgversion) {
						parse_version_op(pkgname, j, &pkgversion2, &sign2);
-
					else
+
						j = pkgversion2 - pkgname - 1;
+
					} else {
						parse_version_op(pkgname, j, &pkgversion, &sign);
+
						j = pkgversion - pkgname - 1;
+
					}
				}
			}
		}
modified tests/frontend/version.sh
@@ -4,7 +4,8 @@

tests_init \
	version \
-
	compare
+
	compare \
+
	compare_ge_le

version_body() {
	atf_check -o inline:"<\n" -s exit:0 pkg version -t 1 2
@@ -50,3 +51,33 @@ compare_body() {
		-s exit:1 \
		pkg info "test>5.20_3<6"
}
+

+
compare_ge_le_body() {
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg test test 5.20_3
+

+
	atf_check \
+
		-o match:".*Installing.*" \
+
		pkg register -M test.ucl
+
	atf_check \
+
		-o ignore \
+
		pkg info "test>=5.20_3"
+
	atf_check \
+
		-o ignore \
+
		pkg info "test<=5.20_3"
+
	atf_check \
+
		-o ignore \
+
		pkg info "test>=5"
+
	atf_check \
+
		-o ignore \
+
		-e ignore \
+
		-s exit:1 \
+
		pkg info "test>=6"
+
	atf_check \
+
		-o ignore \
+
		-e ignore \
+
		-s exit:1 \
+
		pkg info "test<=5"
+
	atf_check \
+
		-o ignore \
+
		pkg info "test>=5<=6"
+
}