summaryrefslogtreecommitdiff
path: root/t/requires.t
blob: ab1f486597f405ca360a44b2c3a433256fba5a81 (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
#!/usr/bin/perl -w

use strict;
use Test::More tests => 20;

require 't/testlib.pm';

my $repo = <<'EOR';
P: a = 1-1
R: b
P: b = 1-1
P: c = 1-1
R: p
P: d = 1-1 p
P: e = 1-1 p
P: f = 1-1
R: n
P: ign2 = 1-1
R: ign1
P: ign3 = 1-1
R: ign4
P: ign5 = 1-1 ign4
P: ign6 = 1-1
R: ign7
P: ign8 = 1-1
R: ign7
P: g = 1-1 h
P: h = 1-1
EOR

my $config = setuptest($repo, 'Ignore: ign1 ign5 ign6:ign7');
my $config2 = setuptest($repo, 'Prefer: d');
my $config3 = setuptest($repo, 'Prefer: -d');
my @r;

@r = expand($config);
is_deeply(\@r, [1], 'install nothing');

@r = expand($config, 'n');
is_deeply(\@r, [undef, 'nothing provides n'], 'install n');

@r = expand($config, 'f');
is_deeply(\@r, [undef, 'nothing provides n needed by f'], 'install f');

@r = expand($config, "a");
is_deeply(\@r, [1, 'a', 'b'], 'install a');

@r = expand($config, "c");
is_deeply(\@r, [undef, 'have choice for p needed by c: d e'], 'install c');

@r = expand($config2, "c");
is_deeply(\@r, [1, 'c', 'd'], 'install c with prefer');

@r = expand($config3, "c");
is_deeply(\@r, [1, 'c', 'e'], 'install c with neg prefer');

@r = expand($config, "ign1");
is_deeply(\@r, [undef, 'nothing provides ign1'], 'install ign1');

@r = expand($config, "ign2");
is_deeply(\@r, [1, 'ign2'], 'install ign2');

@r = expand($config, "ign3");
is_deeply(\@r, [1, 'ign3'], 'install ign3');

@r = expand($config, "ign6");
is_deeply(\@r, [1, 'ign6'], 'install ign6');

@r = expand($config, "ign8");
is_deeply(\@r, [undef, 'nothing provides ign7 needed by ign8'], 'install ign8');

@r = expand($config, "ign2", "-ign2");
is_deeply(\@r, [1, 'ign2'], 'install ign2 -ign2');

@r = expand($config, "ign8", "-ign7");
is_deeply(\@r, [1, 'ign8'], 'install ign8 -ign7');

@r = expand($config2, "ign5", "-ign5");
is_deeply(\@r, [1, 'ign5'], 'install ign5 -ign5');

@r = expand($config2, "ign4", "-ign5");
is_deeply(\@r, [1, 'ign5'], 'install ign4 -ign5');

@r = expand($config, "ign5");
is_deeply(\@r, [1, 'ign5'], 'install ign5');

@r = expand($config, "ign4");
is_deeply(\@r, [1, 'ign5'], 'install ign4');

@r = expand($config, "h");
is_deeply(\@r, [1, 'h'], 'install h');

@r = expand($config, "--directdepsend--", "h");
is_deeply(\@r, [undef, 'have choice for h: g h'], 'install --directdepsend-- h');