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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
use strict;
use warnings;
use Test::More 0.88;
use Test::Fatal;
use lib 't/lib';
use Test::DZil;
use JSON::MaybeXS;
# protect from dzil's own release environment
local $ENV{RELEASE_STATUS};
local $ENV{TRIAL};
# TestReleaseProvider sets 'unstable'
subtest "TestReleaseProvider" => sub {
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
'GatherDir',
'MetaJSON',
'TestReleaseProvider',
),
},
},
);
$tzil->build;
is($tzil->release_status, 'unstable', "release status set from provider");
ok($tzil->is_trial, "is_trial is true");
like($tzil->archive_filename, qr/-TRIAL/, "-TRIAL in archive filename");
my $json = $tzil->slurp_file('build/META.json');
my $meta = JSON::MaybeXS->new(utf8 => 0)->decode($json);
is( $meta->{release_status}, 'unstable', "release status set in META" );
};
for my $c ( qw/true false/ ) {
subtest "is_trial in dist.ini $c" => sub {
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
{ is_trial => $c eq 'true' ? '1' : '0' },
'GatherDir',
),
},
},
);
$tzil->build;
my $expect = $c eq 'true' ? 'testing' : 'stable';
my $is_trial = $expect eq 'testing' ? 1 : 0;
is($tzil->release_status, $expect, "release status set from is_trial");
if ( $is_trial ) {
is($tzil->is_trial, 1, "is_trial is true, represented as 1");
like($tzil->archive_filename, qr/-TRIAL/, "-TRIAL in archive filename");
}
else {
is($tzil->is_trial, 0, "is_trial is not true, represented as 0");
unlike($tzil->archive_filename, qr/-TRIAL/, "-TRIAL not in archive filename");
}
};
}
subtest "RELEASE_STATUS" => sub {
local $ENV{RELEASE_STATUS} = 'stable';
local $ENV{TRIAL} = 1;
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
'GatherDir',
'TestReleaseProvider',
),
},
},
);
$tzil->build;
is($tzil->release_status, 'stable', "release status set from environment");
ok(! $tzil->is_trial, "is_trial is not true");
unlike($tzil->archive_filename, qr/-TRIAL/, "-TRIAL not in archive filename");
};
subtest "TRIAL" => sub {
local $ENV{TRIAL} = 1;
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
'GatherDir',
'TestReleaseProvider',
),
},
},
);
$tzil->build;
is($tzil->release_status, 'testing', "release status set from environment");
ok($tzil->is_trial, "is_trial is true");
like($tzil->archive_filename, qr/-TRIAL/, "-TRIAL in archive filename");
};
subtest "too many providers" => sub {
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
{ is_trial => '1' }, 'GatherDir', 'TestReleaseProvider',
),
},
},
);
like(
exception { $tzil->build },
qr/attempted to set release status twice/,
"setting too many times is fatal",
);
};
subtest "from version (stable)" => sub {
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
{ version => 1.23 }, 'GatherDir',
),
},
},
);
$tzil->build;
is($tzil->release_status, 'stable', "release status set from version (stable)");
ok(!$tzil->is_trial, "is_trial is false");
unlike($tzil->archive_filename, qr/-TRIAL/, "no -TRIAL in archive filename");
};
subtest "from version (testing)" => sub {
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
{ version => "1.23_45" }, 'GatherDir',
),
},
},
);
$tzil->build;
is($tzil->release_status, 'testing', "release status set from version (testing)");
ok($tzil->is_trial, "is_trial is true");
unlike($tzil->archive_filename, qr/-TRIAL/, "no -TRIAL in archive filename");
};
done_testing;
|