App-CISetup
view release on metacpan or search on metacpan
t/lib/T/Travis.pm view on Meta::CPAN
my $travis = Load($yaml);
is(
$travis,
{
addons => {
apt => {
packages => [ 'aspell', 'aspell-en' ],
},
},
language => 'perl',
perl => [
qw(
blead
dev
5.30
5.28
5.26
5.24
5.22
5.20
5.18
5.16
5.14
)
],
cache => {
directories => ['$HOME/perl5'],
},
matrix => {
allow_failures => [ { perl => 'blead' } ],
fast_finish => 1,
include => [
{
env => 'COVERAGE=1',
perl => '5.30'
}
],
},
env => { global => [ 'AUTHOR_TESTING=1', 'RELEASE_TESTING=1' ] },
before_install => [
'eval $(curl https://travis-perl.github.io/init) --auto --always-upgrade-modules'
],
},
'travis config contains expected content'
);
$self->_test_cisetup_flags_comment(
$file,
{
force_threaded_perls => 0,
perl_caching => 1,
}
);
App::CISetup::Travis::ConfigFile->new(
file => $file,
force_threaded_perls => 0,
)->update_file;
my $updated = LoadFile($file);
is( $travis, $updated, 'file was not changed by update' );
}
sub test_force_threaded_perls {
my $self = shift;
my $dir = tempdir();
my $file = $dir->child('.travis.yml');
App::CISetup::Travis::ConfigFile->new(
file => $file,
force_threaded_perls => 1,
)->create_file;
my $yaml = $file->slurp;
for my $v (qw( 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.30 )) {
for my $t ( $v, "$v-thr" ) {
like(
$yaml,
qr/^ +- '?\Q$t\E'?$/ms,
"created file includes Perl $t"
);
}
}
$self->_test_cisetup_flags_comment(
$file,
{
force_threaded_perls => 1,
perl_caching => 1,
}
);
}
sub test_no_perl_caching {
my $self = shift;
my $dir = tempdir();
my $file = $dir->child('.travis.yml');
App::CISetup::Travis::ConfigFile->new(
file => $file,
force_threaded_perls => 0,
perl_caching => 0,
)->create_file;
my $yaml = $file->slurp;
my $travis = Load($yaml);
is(
$travis,
hash {
field cache => DNE();
etc();
},
'no cache block when perl_caching is disabled'
);
is(
$travis->{before_install},
['eval $(curl https://travis-perl.github.io/init) --auto'],
t/lib/T/Travis.pm view on Meta::CPAN
);
}
sub test_maybe_disable_sudo {
my $self = shift;
my $dir = tempdir();
my $file = $dir->child('.travis.yml');
DumpFile(
$file, {
sudo => 'true',
language => 'perl',
before_install => [
'eval $(curl https://travis-perl.github.io/init) --auto --always-upgrade-modules'
],
perl => ['5.26'],
}
);
App::CISetup::Travis::ConfigFile->new(
file => $file,
force_threaded_perls => 0,
)->update_file;
ok(
!exists LoadFile($file)->{sudo},
'sudo key is deleted',
);
}
sub test_coverity_email {
my $self = shift;
my $dir = tempdir();
my $file = $dir->child('.travis.yml');
DumpFile(
$file, {
sudo => 'true',
language => 'perl',
addons => {
coverity_scan => { notification_email => 'foo@example.com' }
},
before_install => [
'eval $(curl https://travis-perl.github.io/init) --auto --always-upgrade-modules'
],
perl => ['5.26'],
}
);
App::CISetup::Travis::ConfigFile->new(
file => $file,
force_threaded_perls => 0,
email_address => 'bar@example.com',
)->update_file;
is(
LoadFile($file)->{addons}{coverity_scan},
{ notification_email => 'bar@example.com' },
'email address for coverity_scan is updated',
);
$self->_test_cisetup_flags_comment(
$file,
{
email_address => 'bar@example.com',
force_threaded_perls => 0,
perl_caching => 1,
}
);
}
sub test_email_notifications {
my $self = shift;
my $dir = tempdir();
my $file = $dir->child('.travis.yml');
DumpFile(
$file, {
sudo => 'true',
language => 'perl',
before_install => [
'eval $(curl https://travis-perl.github.io/init) --auto --always-upgrade-modules'
],
perl => ['5.26'],
}
);
App::CISetup::Travis::ConfigFile->new(
file => $file,
force_threaded_perls => 0,
email_address => 'bar@example.com',
)->update_file;
is(
LoadFile($file)->{notifications},
{
email => {
recipients => ['bar@example.com'],
on_success => 'change',
on_failure => 'always',
},
},
'email address for notifications is added when email is provided',
);
}
sub test_slack_notifications {
my $self = shift;
my $dir = tempdir();
my $file = $dir->child('.travis.yml');
DumpFile(
$file, {
sudo => 'true',
language => 'perl',
before_install => [
'eval $(curl https://travis-perl.github.io/init) --auto --always-upgrade-modules'
( run in 0.703 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )