aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2022-10-25 20:29:46 +0000
committerPascal Terjan <pterjan@mageia.org>2022-11-01 22:23:53 +0000
commit2c86ed6389d741cfe41323937e9e93b89935490e (patch)
tree046cb4f3b1bf2046d8555ae18100280c3a3fb62c /t
parent775e1ad51b6318b1a308be9b997accc470329282 (diff)
downloadperl-URPM-topic/parse_property.tar
perl-URPM-topic/parse_property.tar.gz
perl-URPM-topic/parse_property.tar.bz2
perl-URPM-topic/parse_property.tar.xz
perl-URPM-topic/parse_property.zip
Fix parsing of properties containing [topic/parse_property
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.
Diffstat (limited to 't')
-rw-r--r--t/resolve.t46
-rw-r--r--t/synthesis.t52
2 files changed, 96 insertions, 2 deletions
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();
diff --git a/t/synthesis.t b/t/synthesis.t
index 8246b36..794fd7a 100644
--- a/t/synthesis.t
+++ b/t/synthesis.t
@@ -2,7 +2,7 @@
use strict ;
use warnings ;
-use Test::More tests => 95;
+use Test::More tests => 113;
use URPM;
chdir 't' if -d 't';
@@ -27,7 +27,25 @@ $s =~ s/-devel//g;
print $f $s;
close $f;
-END { unlink $file1, $file2 }
+$s = <<'EOF';
+@provides@python3-fonttools+ufo[== 4.18.2-4.mga9]@python3dist(fonttools[ufo])[== 4.18.2]
+@summary@Metapackage for python3-fonttools: ufo extras
+@info@python3-fonttools+ufo-4.18.2-4.mga9.noarch@0@221683@Development/Other
+@provides@config(dovecot)[== 2.3.19.1-2.mga9]
+@requires@openssl[*]@rpm-helper[*][>= 0.21]
+@summary@Secure IMAP and POP3 server
+@info@dovecot-2.3.19.1-2.mga9.x86_64@0@17815993@System/Servers
+@provides@openimageio[== 2.3.20.0-2.mga9]@font(:lang=aa)
+@summary@Library for reading and writing images
+@info@openimageio-2.3.20.0-2.mga9.x86_64@0@42@Development/Other
+EOF
+
+my $file3 = 'synthesis.squarebrackets.cz';
+open $f, "| gzip -9 >$file3";
+print $f $s;
+close $f;
+
+END { unlink $file1, $file2, $file3 }
my $a = URPM->new;
ok($a);
@@ -161,3 +179,33 @@ ok($requires[8] eq 'rpmlib(CompressedFileNames)');
@provides = $pkg->provides_nosense;
ok(@provides == 1);
ok($provides[0] eq 'glibc-devel');
+
+my $b = URPM->new;
+$b->parse_synthesis($file3);
+$pkg = $b->{depslist}[0];
+ok($pkg);
+is($pkg->name, 'python3-fonttools+ufo');
+@provides = $pkg->provides;
+is(@provides, 2);
+is($provides[1], 'python3dist(fonttools[ufo])[== 4.18.2]');
+@provides = $pkg->provides_nosense;
+is(@provides, 2);
+is($provides[1], 'python3dist(fonttools[ufo])');
+$pkg = $b->{depslist}[1];
+ok($pkg);
+is($pkg->name, 'dovecot');
+@requires = $pkg->requires;
+is(@requires, 2);
+is($requires[0], 'openssl[*]');
+is($requires[1], 'rpm-helper[*][>= 0.21]');
+@requires = $pkg->requires_nosense;
+is(@requires, 2);
+is($requires[0], 'openssl');
+is($requires[1], 'rpm-helper');
+$pkg = $b->{depslist}[2];
+ok($pkg);
+is($pkg->name, 'openimageio');
+@provides = $pkg->provides;
+is(@provides, 2);
+is($provides[1], 'font(:lang=aa)');
+