Skip to content

Commit facfda4

Browse files
committed
Add tests for $?DISTRIBUTION
1 parent 249bf80 commit facfda4

File tree

7 files changed

+157
-0
lines changed

7 files changed

+157
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
use v6;
2+
use Test;
3+
use lib $?FILE.IO.parent(2).add: 'packages/Test-Helpers';
4+
use Test::Util;
5+
6+
7+
subtest "CompUnit::Repository::FileSystem without META6.json" => {
8+
my $lib-one = $?FILE.IO.parent(2).add: 'packages/CurrentDistributionOne/lib';
9+
my $lib-two = $?FILE.IO.parent(2).add: 'packages/CurrentDistributionTwo/lib';
10+
11+
{
12+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
13+
'-I', $lib-one, '-I', $lib-two,
14+
'-M', 'CurrentDistributionOne', '-M', 'CurrentDistributionTwo',
15+
'-e',
16+
'exit(!$?DISTRIBUTION.defined)';
17+
is $proc.exitcode, 1;
18+
}
19+
20+
{
21+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
22+
'-I', $lib-one,
23+
'-M', 'CurrentDistributionOne',
24+
'-e',
25+
'exit(!CurrentDistributionOne::distribution.meta<provides><CurrentDistributionOne>.defined)';
26+
is $proc.exitcode, 0;
27+
}
28+
29+
{
30+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
31+
'-I', $lib-one, '-I', $lib-two,
32+
'-M', 'CurrentDistributionTwo',
33+
'-e',
34+
'exit(!CurrentDistributionTwo::distribution.meta<provides><CurrentDistributionTwo>.defined)';
35+
is $proc.exitcode, 0;
36+
}
37+
}
38+
39+
subtest "CompUnit::Repository::FileSystem with META6.json" => {
40+
my $lib-one = $?FILE.IO.parent(2).add: 'packages/CurrentDistributionOne';
41+
my $lib-two = $?FILE.IO.parent(2).add: 'packages/CurrentDistributionTwo';
42+
43+
{
44+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
45+
'-I', $lib-one, '-I', $lib-two,
46+
'-M', 'CurrentDistributionOne', '-M', 'CurrentDistributionTwo',
47+
'-e',
48+
'exit(!$?DISTRIBUTION.defined)';
49+
is $proc.exitcode, 1;
50+
}
51+
52+
{
53+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
54+
'-I', $lib-one,
55+
'-M', 'CurrentDistributionOne',
56+
'-e',
57+
'exit(!CurrentDistributionOne::distribution.meta<provides><CurrentDistributionOne>.defined)';
58+
is $proc.exitcode, 0;
59+
}
60+
61+
{
62+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
63+
'-I', $lib-one, '-I', $lib-two,
64+
'-M', 'CurrentDistributionTwo',
65+
'-e',
66+
'exit(!CurrentDistributionTwo::distribution.meta<provides><CurrentDistributionTwo>.defined)';
67+
is $proc.exitcode, 0;
68+
}
69+
}
70+
71+
subtest "CompUnit::Repository::Installation" => {
72+
my $dist-path-one = Distribution::Path.new($?FILE.IO.parent(2).add('packages/CurrentDistributionOne'));
73+
my $dist-path-two = Distribution::Path.new($?FILE.IO.parent(2).add('packages/CurrentDistributionTwo'));
74+
my $cur = CompUnit::Repository::Installation.new(prefix => make-temp-dir().absolute);
75+
my $lib = $cur.path-spec;
76+
77+
$cur.install($dist-path-one);
78+
$cur.install($dist-path-two);
79+
80+
{
81+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
82+
'-I', $lib,
83+
'-M', 'CurrentDistributionOne', '-M', 'CurrentDistributionTwo',
84+
'-e',
85+
'exit(!$?DISTRIBUTION.defined)';
86+
is $proc.exitcode, 1;
87+
}
88+
89+
{
90+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
91+
'-I', $lib,
92+
'-M', 'CurrentDistributionOne',
93+
'-e',
94+
'exit(!CurrentDistributionOne::distribution.meta<provides><CurrentDistributionOne>.defined)';
95+
is $proc.exitcode, 0;
96+
}
97+
98+
{
99+
my $proc = run :!out, :!err, $*EXECUTABLE.absolute,
100+
'-I', $lib,
101+
'-M', 'CurrentDistributionTwo',
102+
'-e',
103+
'exit(!CurrentDistributionTwo::distribution.meta<provides><CurrentDistributionTwo>.defined)';
104+
is $proc.exitcode, 0;
105+
}
106+
}
107+
108+
109+
done-testing;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"perl" : "6.c",
3+
"name" : "CurrentDistributionOne",
4+
"description" : "A distribution for basic testing of $?DISTRIBUTION and %?RESOURCES",
5+
"depends" : [ ],
6+
"provides" : {
7+
"CurrentDistributionOne" : "lib/CurrentDistributionOne.pm6"
8+
},
9+
"resources" : [
10+
"foo.txt"
11+
]
12+
}
13+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
unit module CurrentDistributionOne;
2+
3+
our sub distribution { $?DISTRIBUTION }
4+
5+
our sub resources { %?RESOURCES }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CurrentDistributionOne
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"perl" : "6.c",
3+
"name" : "CurrentDistributionTwo",
4+
"description" : "Like CurrentDistributionOne, but also depends on CurrentDistributionOne and its $?DISTRIBUTION",
5+
"depends" : [ "CurrentDistributionOne" ],
6+
"provides" : {
7+
"CurrentDistributionTwo" : "lib/CurrentDistributionTwo.pm6"
8+
},
9+
"resources" : [
10+
"foo.txt"
11+
]
12+
}
13+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
unit module CurrentDistributionTwo;
2+
3+
our sub distribution { $?DISTRIBUTION }
4+
5+
our sub resources { %?RESOURCES }
6+
7+
our sub dependency-distribution {
8+
use CurrentDistributionOne;
9+
CurrentDistributionOne::distribution;
10+
}
11+
12+
our sub dependency-resources {
13+
use CurrentDistributionOne;
14+
CurrentDistributionOne::resources;
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CurrentDistributionTwo

0 commit comments

Comments
 (0)