5 use Test
::Simple tests
=> 8;
7 use Fedora
::Rebuild
::Solver
;
8 use Fedora
::Rebuild
::Set
::Package
;
9 use Fedora
::Rebuild
::Package
;
10 use Fedora
::Rebuild
::RPM
;
14 # Create and return package with one binary package that always provides its
17 my ($name, $provides, $runrequires, $buildrequires) = @_;
19 my $package = Fedora
::Rebuild
::Package
->new(
27 $package->provides(shared_clone
(
30 $name => [[Fedora
::Rebuild
::RPM
::ANY
, '']],
35 $package->runrequires(shared_clone
(
36 { $name => $runrequires }
38 $package->requires(shared_clone
($buildrequires));
42 my $B1 = build_package
(
46 { 'a' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] }
49 my $B2 = build_package
(
53 {'a' => [[Fedora
::Rebuild
::RPM
::ANY
, '']]}
56 my $C = build_package
(
60 [[Fedora
::Rebuild
::RPM
::EQUAL
|Fedora
::Rebuild
::RPM
::GREATER
, '1']],
63 { 'nonexistent' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] }
66 my $a = build_package
(
70 [[Fedora
::Rebuild
::RPM
::EQUAL
|Fedora
::Rebuild
::RPM
::GREATER
, '1']],
76 my $b1 = build_package
(
79 { 'a' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
83 my $b2 = build_package
(
86 {'a' => [[Fedora
::Rebuild
::RPM
::ANY
, '']]},
90 my $c = build_package
(
94 [[Fedora
::Rebuild
::RPM
::EQUAL
|Fedora
::Rebuild
::RPM
::GREATER
, '1']],
96 { 'nonexistent' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
100 my $D = build_package
(
104 {'b1' => [[Fedora
::Rebuild
::RPM
::ANY
, '']]},
107 my $E = build_package
(
112 'b1' => [[Fedora
::Rebuild
::RPM
::ANY
, '']],
113 'b2' => [[Fedora
::Rebuild
::RPM
::ANY
, '']],
117 my $F = build_package
(
122 'a' => [[Fedora
::Rebuild
::RPM
::ANY
, '']],
123 'dual' => [[Fedora
::Rebuild
::RPM
::ANY
, '']],
127 my $G = build_package
(
133 [Fedora
::Rebuild
::RPM
::GREATER
, '1'],
134 [Fedora
::Rebuild
::RPM
::LESS
, '1'],
135 [Fedora
::Rebuild
::RPM
::GREATER
, '2'],
140 my $H = build_package
(
144 { 'c' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
147 # Prepare set of packages
148 my $packages = Fedora
::Rebuild
::Set
::Package
->new();
149 $packages->insert($B1);
150 $packages->insert($B2);
151 $packages->insert($C);
152 $packages->insert($a);
153 $packages->insert($b1);
154 $packages->insert($b2);
155 $packages->insert($c);
156 $packages->insert($D);
157 $packages->insert($E);
158 $packages->insert($F);
159 $packages->insert($G);
160 $packages->insert($H);
163 my $solver = Fedora
::Rebuild
::Solver
->new(packages
=> $packages,
164 dependencyfilter
=> sub {0});
169 # Direct dependencies
170 ok
($solver->is_buildable($a, \
$message),
171 "a build-requires nothing: $message");
172 ok
($solver->is_buildable($B1, \
$message),
173 "B1 build-requires a: $message");
174 ok
(! $solver->is_buildable($C, \
$message),
175 "C build-requires nonexistent: $message");
177 # Indirect dependencies
178 ok
($solver->is_buildable($D, \
$message),
179 "D build-requires b1 that requires a: $message");
180 ok
($solver->is_buildable($E, \
$message),
181 "E build-requires b1 and b2, both require a: $message");
182 ok
(! $solver->is_buildable($H, \
$message),
183 "H build-requires c that is not installable: $message");
185 # More provides, one is not installable.
186 # XXX: This is not deterministic as it depend on hash ordering.
187 ok
($solver->is_buildable($F, \
$message),
188 "F build-requires a and dual, dual is provided by installable a and " .
189 "uninstallable c: $message");
191 # More provides, one is not installable, but all requires cannot be satisfied
193 ok
(! $solver->is_buildable($G, \
$message),
194 "G build-requires versioned dual's, they cannot be satisfied at the " .
195 "same time: $message");