-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathinstall.rakutest
96 lines (71 loc) · 3.49 KB
/
install.rakutest
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
96
use v6.d;
use Test;
plan 1;
use Zef;
use Zef::Install;
use Zef::Distribution;
my $cur = (class :: does CompUnit::Repository { method need { }; method loaded { }; method id { } }).new;
subtest 'Zef::Install.install' => {
subtest 'Two installers, first does not match/handle uri' => {
my class Mock::Installer::One does Installer {
method install-matcher(|--> False) { }
method install($) { die 'should not get called' }
}
my class Mock::Installer::Two does Installer {
method install-matcher(|--> True) { }
method install($ --> True) { }
}
my $save-to = $*TMPDIR.child(100000.rand).mkdir;
my $installer = Zef::Install.new but role :: { method plugins(|--> List) { Mock::Installer::One.new, Mock::Installer::Two.new } };
my $dist = Zef::Distribution.new(:name<Foo::Bar>) but role :: { method path { $save-to } };
ok $installer.install(Candidate.new(:$dist), :$cur);
try $save-to.rmdir;
}
subtest 'Two installers, first not capable of handling given uri' => {
my class Mock::Installer::One does Installer {
method install-matcher(|--> False) { }
method install($) { die 'should not get called' }
}
my class Mock::Installer::Two does Installer {
method install-matcher(|--> True) { }
method install($ --> True) { }
}
my $save-to = $*TMPDIR.child(100000.rand).mkdir;
my $installer = Zef::Install.new but role :: { method plugins(|--> List) { Mock::Installer::One.new, Mock::Installer::Two.new } };
my $dist = Zef::Distribution.new(:name<Foo::Bar>) but role :: { method path { $save-to } };
ok $installer.install(Candidate.new(:$dist), :$cur);
try $save-to.rmdir;
}
subtest 'Two installers, first fails and second is not tried' => {
my class Mock::Installer::One does Installer {
method install-matcher(|--> True) { }
method install($ --> False) { }
}
my class Mock::Installer::Two does Installer {
method install-matcher(|--> True) { }
method install($ --> True) { die 'should not get called' }
}
my $save-to = $*TMPDIR.child(100000.rand).mkdir;
my $installer = Zef::Install.new but role :: { method plugins(|--> List) { Mock::Installer::One.new, Mock::Installer::Two.new } };
my $dist = Zef::Distribution.new(:name<Foo::Bar>) but role :: { method path { $save-to } };
nok $installer.install(Candidate.new(:$dist), :$cur);
try $save-to.rmdir;
}
subtest 'Two installers, first times out and second is not tried' => {
my constant timeout = 1;
my class Mock::Installer::One does Installer {
method install-matcher(|--> True) { }
method install($) { sleep(timeout * 5); timeout; }
}
my class Mock::Installer::Two does Installer {
method install-matcher(|--> True) { }
method install($ --> True) { die 'should not get called' }
}
my $save-to = $*TMPDIR.child(100000.rand).mkdir;
my $installer = Zef::Install.new but role :: { method plugins(|--> List) { Mock::Installer::One.new, Mock::Installer::Two.new } };
my $dist = Zef::Distribution.new(:name<Foo::Bar>) but role :: { method path { $save-to } };
nok $installer.install(Candidate.new(:$dist), :$cur, :timeout(timeout));
try $save-to.rmdir;
}
}
done-testing;