5 use Test
::Simple tests
=> 6;
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 $A = build_package
(
45 { 'A' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
46 { 'A' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
49 my $B = build_package
(
53 { 'A' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
56 my $C = build_package
(
59 { 'D' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
60 { 'D' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
63 my $D = build_package
(
66 { 'C' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
67 { 'C' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
70 my $E = build_package
(
74 { 'D' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
77 my $F = build_package
(
81 { 'C' => [[Fedora
::Rebuild
::RPM
::ANY
, '']] },
84 # Prepare set of packages
85 my $packages = Fedora
::Rebuild
::Set
::Package
->new();
86 $packages->insert($A);
87 $packages->insert($B);
88 $packages->insert($C);
89 $packages->insert($D);
90 $packages->insert($E);
91 $packages->insert($F);
94 my $solver = Fedora
::Rebuild
::Solver
->new(packages
=> $packages,
95 dependencyfilter
=> sub {0});
101 ok
($solver->is_buildable($A, \
$message),
102 "A build-requires itself: $message");
103 ok
($solver->is_buildable($B, \
$message),
104 "B build-requires reflexive A: $message");
107 ok
($solver->is_buildable($D, \
$message),
108 "D build-requires C that requires D that requires C: $message");
109 ok
($solver->is_buildable($C, \
$message),
110 "C build-requires D that requires C that requires D: $message");
111 ok
($solver->is_buildable($E, \
$message),
112 "E build-requires D that requires C that requires D: $message");
113 ok
($solver->is_buildable($F, \
$message),
114 "F build-requires C that requires D that requires C: $message");