aboutsummaryrefslogtreecommitdiffstats
path: root/t/synthesis.t
blob: a16d909d3bfdd09ff05529a70aff54f00e6a862e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/perl

use strict ;
use warnings ;
use Test::More tests => 88;
use URPM;

chdir 't' if -d 't';
my $file1 = 'synthesis.sample.cz';

open my $f, "| gzip -9 >$file1";
print $f <<'EOF';
@provides@glibc-devel == 6:2.2.4-25mdk
@requires@/sbin/install-info@glibc == 2.2.4@kernel-headers@kernel-headers >= 2.2.1@/bin/sh@/bin/sh@/bin/sh@rpmlib(PayloadFilesHavePrefix) <= 4.0-1@rpmlib(CompressedFileNames) <= 3.0.4-1
@conflicts@texinfo < 3.11@gcc < 2.96-0.50mdk
@obsoletes@libc-debug@libc-headers@libc-devel@linuxthreads-devel@glibc-debug
@info@glibc-devel-2.2.4-25mdk.i586@6@45692097@Development/C
EOF
close $f;

END { unlink $file1 }

my $a = new URPM;
ok($a);

my ($first, $end);

($first, $end) = URPM->new->parse_synthesis('empty_synthesis.cz');
is("$first $end", "0 -1", 'parse empty synthesis');

is(URPM->new->parse_synthesis('buggy_synthesis.cz'), undef, 'parse buggy synthesis');

($first, $end) = $a->parse_synthesis($file1);
ok($first == 0 && $end == 0);
is(int @{$a->{depslist}}, 1);
ok(keys(%{$a->{provides}}) == 3);
ok(defined $a->{provides}{'glibc-devel'});
ok(exists $a->{provides}{'/bin/sh'});
ok(! defined $a->{provides}{'/bin/sh'});
ok(exists $a->{provides}{'/sbin/install-info'});
ok(! defined $a->{provides}{'/sbin/install-info'});

my $pkg = $a->{depslist}[0];
ok($pkg);
ok($pkg->name eq 'glibc-devel');
ok($pkg->version eq '2.2.4');
ok($pkg->release eq '25mdk');
ok($pkg->arch eq 'i586');
ok($pkg->fullname eq 'glibc-devel-2.2.4-25mdk.i586');
ok(!defined $pkg->buildarchs);
ok(!defined $pkg->buildhost);
is($pkg->buildtime,0);
ok(!defined $pkg->changelog_name);
ok(!defined $pkg->changelog_text);
ok(!defined $pkg->changelog_time);

my ($name, $version, $release, $arch, @l) = $pkg->fullname;
ok(@l == 0);
ok($name eq 'glibc-devel');
ok($version eq '2.2.4');
ok($release eq '25mdk');
ok($arch eq 'i586');

ok($pkg->epoch == 6);
ok($pkg->size == 45692097);
ok($pkg->group eq 'Development/C');
ok($pkg->filename eq 'glibc-devel-2.2.4-25mdk.i586.rpm');
ok(defined $pkg->id);
ok($pkg->id == 0);
ok($pkg->set_id(6) == 0);
ok($pkg->id == 6);
ok($pkg->set_id == 6);
ok(! defined $pkg->id);
ok(! defined $pkg->set_id(0));
ok(defined $pkg->id);
ok($pkg->id == 0);

my @obsoletes = $pkg->obsoletes;
ok(@obsoletes == 5);
ok($obsoletes[0] eq 'libc-debug');
ok($obsoletes[4] eq 'glibc-debug');

my @conflicts = $pkg->conflicts;
ok(@conflicts == 2);
ok($conflicts[0] eq 'texinfo < 3.11');
ok($conflicts[1] eq 'gcc < 2.96-0.50mdk');

my @requires = $pkg->requires;
ok(@requires == 9);
ok($requires[0] eq '/sbin/install-info');
ok($requires[8] eq 'rpmlib(CompressedFileNames) <= 3.0.4-1');

my @provides = $pkg->provides;
ok(@provides == 1);
ok($provides[0] eq 'glibc-devel == 6:2.2.4-25mdk');

my @files = $pkg->files;
ok(@files == 0);

ok($pkg->compare("6:2.2.4-25mdk") == 0);
ok($pkg->compare("2.2.4-25mdk") == 0);
ok($pkg->compare("2.2.4") == 0);
ok($pkg->compare("2.2.3") > 0);
ok($pkg->compare("2.2") > 0);
ok($pkg->compare("2") > 0);
ok($pkg->compare("2.2.4.0") < 0);
ok($pkg->compare("2.2.5") < 0);
ok($pkg->compare("2.1.7") > 0);
ok($pkg->compare("2.3.1") < 0);
ok($pkg->compare("2.2.31") < 0);
ok($pkg->compare("2.2.4-25") > 0);
ok($pkg->compare("2.2.4-25.1mdk") < 0);
ok($pkg->compare("2.2.4-24mdk") > 0);
ok($pkg->compare("2.2.4-26mdk") < 0);
ok($pkg->compare("6:2.2.4-26mdk") < 0);
ok($pkg->compare("7:2.2.4-26mdk") < 0);
ok($pkg->compare("7:2.2.4-24mdk") < 0);

ok($a->traverse() == 1);

my $test = 0;
ok($a->traverse(sub { my ($pkg) = @_; $test = $pkg->name eq 'glibc-devel' }) == 1);
ok($test);
ok($a->traverse_tag('name', [ 'glibc-devel' ]) == 1);
ok($a->traverse_tag('name', [ 'glibc' ]) == 0);

$test = 0;
ok($a->traverse_tag('name', [ 'glibc-devel' ], sub { my ($pkg) = @_; $test = $pkg->name eq 'glibc-devel' }) == 1);
ok($test);

@conflicts = $pkg->conflicts_nosense;
ok(@conflicts == 2);
ok($conflicts[0] eq 'texinfo');
ok($conflicts[1] eq 'gcc');

@requires = $pkg->requires_nosense;
ok(@requires == 9);
ok($requires[0] eq '/sbin/install-info');
ok($requires[1] eq 'glibc');
ok($requires[3] eq 'kernel-headers');
ok($requires[8] eq 'rpmlib(CompressedFileNames)');

@provides = $pkg->provides_nosense;
ok(@provides == 1);
ok($provides[0] eq 'glibc-devel');