From 2c86ed6389d741cfe41323937e9e93b89935490e Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 25 Oct 2022 20:29:46 +0000 Subject: Fix parsing of properties containing [ For example, the name extracted from a requirement of "python3.10dist(fonttools[unicode])[>= 4.10]" was sometimes "python3.10dist(fonttools" instead of the expected "python3.10dist(fonttools[unicode])". Code parsing such strings existed in many places, it now exists only in 2 places, a perl version in Resolve.pm and a C version in URPM.xs. Both codes used to handle both "foo >= 0" and "foo[>= 0]" but at least the perl code seems to only call it on provides/conflicts/obsoletes which are always using the second form so the support for it was dropped from the perl version for the sake of simplicity. --- t/resolve.t | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 t/resolve.t (limited to 't/resolve.t') diff --git a/t/resolve.t b/t/resolve.t new file mode 100644 index 0000000..56869b1 --- /dev/null +++ b/t/resolve.t @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +use strict ; +use warnings ; +use Test::More; +use URPM::Resolve; + +my $testcases = [ + { + property => 'mageia-release[>= 1]', + name => 'mageia-release', + op => '>=', + version => '1', + }, { + property => 'python3.10dist(fonttools[unicode])[>= 4.10]', + name => 'python3.10dist(fonttools[unicode])', + op => '>=', + version => '4.10', + }, { + property => 'python3.10dist(fonttools[unicode])', + name => 'python3.10dist(fonttools[unicode])', + op => '', + version => '', + }, { + property => 'openssl[*][>= 0.9.7]', + name => 'openssl', + op => '>=', + version => '0.9.7', + }, { + property => 'openssl[*]', + name => 'openssl', + op => '', + version => '', + }]; + +foreach my $tc (@$testcases) { + is(URPM::property2name($tc->{property}), $tc->{name}, "property2name(\"$tc->{property}\")"); + my $expected = [$tc->{name}, $tc->{op} ? "$tc->{op} $tc->{version}" : ""]; + my @got = URPM::property2name_range($tc->{property}); + is_deeply(\@got, $expected, "property2name_range(\"$tc->{property}\")"); + $expected = [$tc->{name}, $tc->{op}, $tc->{version}]; + @got = URPM::property2name_op_version($tc->{property}); + is_deeply(\@got, $expected, "property2name_op_version(\"$tc->{property}\")"); +} + +done_testing(); -- cgit v1.2.1