|
| 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; |
0 commit comments