~chrisccoulson/dpkg/ssd-ionice

« back to all changes in this revision

Viewing changes to scripts/t/400_Dpkg_Deps.t

  • Committer: chrisccoulson at googlemail
  • Date: 2009-01-13 17:28:50 UTC
  • Revision ID: chrisccoulson@googlemail.com-20090113172850-4e9rba0bqopwbzbq
Initial import 1.14.24 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- mode: cperl;-*-
 
2
 
 
3
use Test::More tests => 15;
 
4
 
 
5
use strict;
 
6
use warnings;
 
7
 
 
8
use_ok('Dpkg::Deps');
 
9
 
 
10
my $field_multiline = " , , libgtk2.0-common (= 2.10.13-1)  , libatk1.0-0 (>=
 
11
1.13.2), libc6 (>= 2.5-5), libcairo2 (>= 1.4.0), libcupsys2 (>= 1.2.7),
 
12
libfontconfig1 (>= 2.4.0), libglib2.0-0  (  >= 2.12.9), libgnutls13 (>=
 
13
1.6.3-0), libjpeg62, python (<< 2.5) , , ";
 
14
my $field_multiline_sorted = "libatk1.0-0 (>= 1.13.2), libc6 (>= 2.5-5), libcairo2 (>= 1.4.0), libcupsys2 (>= 1.2.7), libfontconfig1 (>= 2.4.0), libglib2.0-0 (>= 2.12.9), libgnutls13 (>= 1.6.3-0), libgtk2.0-common (= 2.10.13-1), libjpeg62, python (<< 2.5)";
 
15
 
 
16
my $dep_multiline = Dpkg::Deps::parse($field_multiline);
 
17
$dep_multiline->sort();
 
18
is($dep_multiline->dump(), $field_multiline_sorted, "Parse, sort and dump");
 
19
 
 
20
my $dep_subset = Dpkg::Deps::parse("libatk1.0-0 (>> 1.10), libc6, libcairo2");
 
21
is($dep_multiline->implies($dep_subset), 1, "Dep implies subset of itself");
 
22
is($dep_subset->implies($dep_multiline), undef, "Subset doesn't imply superset");
 
23
my $dep_opposite = Dpkg::Deps::parse("python (>= 2.5)");
 
24
is($dep_opposite->implies($dep_multiline), 0, "Opposite condition implies NOT the depends");
 
25
 
 
26
my $dep_or1 = Dpkg::Deps::parse("a|b (>=1.0)|c (>= 2.0)");
 
27
my $dep_or2 = Dpkg::Deps::parse("x|y|a|b|c (<= 0.5)|c (>=1.5)|d|e");
 
28
is($dep_or1->implies($dep_or2), 1, "Implication between OR 1/2");
 
29
is($dep_or2->implies($dep_or1), undef, "Implication between OR 2/2");
 
30
 
 
31
my $field_arch = "libc6 (>= 2.5) [!alpha !hurd-i386], libc6.1 [alpha], libc0.1 [hurd-i386]";
 
32
my $dep_i386 = Dpkg::Deps::parse($field_arch, reduce_arch => 1, host_arch => 'i386');
 
33
my $dep_alpha = Dpkg::Deps::parse($field_arch, reduce_arch => 1, host_arch => 'alpha');
 
34
my $dep_hurd = Dpkg::Deps::parse($field_arch, reduce_arch => 1, host_arch => 'hurd-i386');
 
35
is($dep_i386->dump(), "libc6 (>= 2.5)", "Arch reduce 1/3");
 
36
is($dep_alpha->dump(), "libc6.1", "Arch reduce 2/3");
 
37
is($dep_hurd->dump(), "libc0.1", "Arch reduce 3/3");
 
38
 
 
39
 
 
40
my $facts = Dpkg::Deps::KnownFacts->new();
 
41
$facts->add_installed_package("mypackage", "1.3.4-1");
 
42
$facts->add_provided_package("myvirtual", undef, undef, "mypackage");
 
43
 
 
44
my $field_duplicate = "libc6 (>= 2.3), libc6 (>= 2.6-1), mypackage (>=
 
45
1.3), myvirtual | something, python (>= 2.5)";
 
46
my $dep_dup = Dpkg::Deps::parse($field_duplicate);
 
47
$dep_dup->simplify_deps($facts, $dep_opposite);
 
48
is($dep_dup->dump(), "libc6 (>= 2.6-1)", "Simplify deps");
 
49
 
 
50
my $field_dup_union = "libc6 (>> 2.3), libc6 (>= 2.6-1), fake (<< 2.0),
 
51
fake(>> 3.0), fake (= 2.5), python (<< 2.5), python (= 2.4)";
 
52
my $dep_dup_union = Dpkg::Deps::parse($field_dup_union, union => 1);
 
53
$dep_dup_union->simplify_deps($facts);
 
54
is($dep_dup_union->dump(), "libc6 (>> 2.3), fake (<< 2.0), fake (>> 3.0), fake (= 2.5), python (<< 2.5)", "Simplify union deps");
 
55
 
 
56
my $dep_red = Dpkg::Deps::parse("abc | xyz, two, abc");
 
57
$dep_red->simplify_deps($facts, $dep_opposite);
 
58
is($dep_red->dump(), "abc, two", "Simplification respect order");
 
59
 
 
60
my $dep_empty1 = Dpkg::Deps::parse("");
 
61
is($dep_empty1->dump(), "", "Empty dependency");
 
62
 
 
63
my $dep_empty2 = Dpkg::Deps::parse(" , , ", union => 1);
 
64
is($dep_empty2->dump(), "", "' , , ' is also an empty dependency");
 
65