Advertise homepage and git repository
[Fedora-Rebuild.git] / t / 09is_buildable_regression1.t
blobcd77a6bff02a187117a5522b96dc549710043a6c
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use Test::Simple tests => 2;
7 use Fedora::Rebuild::Solver;
8 use Fedora::Rebuild::Set::Package;
9 use Fedora::Rebuild::Package;
10 use Fedora::Rebuild::RPM;
11 use threads::shared;
12 use Storable;
13 use File::Spec;
15 # Prepare packages
16 # Create and return package.
17 sub build_package {
18 my ($name, $provides, $runrequires, $buildrequires) = @_;
20 my $package = Fedora::Rebuild::Package->new(
21 'name' => $name,
22 workdir => 't/tmp',
23 dist => 'foo',
24 target => 'foo',
25 message => 'foo',
28 $package->provides(shared_clone($provides));
29 $package->runrequires(shared_clone($runrequires));
30 $package->requires(shared_clone($buildrequires));
31 return $package;
34 # Test
35 my $message;
38 # Case 1
41 my $perl_DBI = build_package(
42 'perl-DBI',
43 {},
44 {},
45 { 'perl(ExtUtils::MakeMaker)' => [[Fedora::Rebuild::RPM::ANY, '']] },
48 my $perl = build_package(
49 'perl',
51 '0:perl-ExtUtils-MakeMaker-6.56-162.fc16' => {
52 'perl(ExtUtils::MakeMaker)' => [[Fedora::Rebuild::RPM::ANY, '']]
54 '4:perl-5.12.3-162.fc16' => {
55 'perl(strict)' => [[Fedora::Rebuild::RPM::ANY, '']]
57 '0:perl-PathTools-3.31-162.fc16' => {
58 'perl(File::Spec::Unix)' => [[Fedora::Rebuild::RPM::ANY, '']],
59 'perl(File::Spec)' => [[Fedora::Rebuild::RPM::ANY, '']],
63 '0:perl-ExtUtils-MakeMaker-6.56-162.fc16' => {
64 'perl(strict)' => [[Fedora::Rebuild::RPM::ANY, '']]
66 '4:perl-5.12.3-162.fc16' => {
67 'perl(File::Spec::Unix)' => [[Fedora::Rebuild::RPM::ANY, '']]
69 '0:perl-PathTools-3.31-162.fc16' => {
70 'perl(File::Spec)' => [[Fedora::Rebuild::RPM::ANY, '']]
73 {},
76 my $packages = Fedora::Rebuild::Set::Package->new();
77 $packages->insert($perl);
79 my $solver = Fedora::Rebuild::Solver->new(packages => $packages);
81 ok($solver->is_buildable($perl_DBI, \$message),
82 "perl-DBI build-requires perl-ExtUtils-MakeMaker " .
83 "that is satisfied by perl " .
84 "that is satisfied by perl-PathTools " .
85 "that requires different symbol provided by perl-PathTool again: $message");
89 # Load hashe fo $what for package $name.
90 sub load_hash {
91 my ($name, $what) = @_;
92 my $store = 't/regression1';
94 my $file = File::Spec->catfile($store, $name . '-' . $what . '.store');
95 if (-e $file) {
96 return retrieve($file);
97 } else {
98 return {};
102 # Create and return package. Populate dependencies from files.
103 sub build_package_from_store {
104 my $name = shift;
106 return build_package(
107 $name,
108 load_hash($name, 'provides'),
109 load_hash($name, 'runrequires'),
110 load_hash($name, 'buildrequires')
114 my $perl = build_package_from_store('perl');
115 my $perl_Test_Simple = build_package_from_store('perl-Test-Simple');
116 my $perl_Test_Pod = build_package_from_store('perl-Test-Pod');
117 my $perl_Crypt_CBC = build_package_from_store('perl-Crypt-CBC');
118 my $perl_Crypt_DES = build_package_from_store('perl-Crypt-DES');
119 my $perl_Net_Daemon = build_package_from_store('perl-Net-Daemon');
120 my $perl_PlRPC = build_package_from_store('perl-PlRPC');
121 my $perl_DBI = build_package_from_store('perl-DBI');
123 my $packages = Fedora::Rebuild::Set::Package->new();
124 $packages->insert($perl);
125 $packages->insert($perl_Test_Simple);
126 $packages->insert($perl_Test_Pod);
127 $packages->insert($perl_Crypt_CBC);
128 $packages->insert($perl_Crypt_DES);
130 my $solver = Fedora::Rebuild::Solver->new(
131 packages => $packages,
132 dependencyfilter => sub {
133 $_[0] !~ /^\s*perl\(/ or
134 $_[0] =~ /^\s*perl\(:MODULE_COMPAT/;
138 #ok($solver->is_buildable($perl_DBI, \$message),
139 # "perl-DBI build-requires perl-ExtUtils-MakeMaker " .
140 # "that is satisfied by perl: $message");
141 ok($solver->is_buildable($perl_Net_Daemon, \$message),
142 "perl-Net-Daemon: $message");