forked from jhoblitt/puppet-perlbrew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The flags param defaults to including the `--notest` flag which should dramatically shorten the time required to install a new perl version. + greatly improved test coverage of perlbrew::perl
- Loading branch information
Joshua Hoblitt
committed
Oct 17, 2014
1 parent
c20ffd3
commit de60e1f
Showing
3 changed files
with
127 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,129 @@ | ||
require 'spec_helper' | ||
|
||
describe 'perlbrew::perl', :type => :define do | ||
let(:title) { 'perl-5.18.2' } | ||
let(:params) {{ :target => 'foo' }} | ||
let(:pre_condition) { "perlbrew { 'foo': install_root => '/dne' }" } | ||
let(:facts) {{ :processorcount => 42 }} | ||
|
||
context 'default params' do | ||
it { should contain_exec('foo_install_perl-5.18.2').with( | ||
:command => 'perlbrew install perl-5.18.2', | ||
let(:install_root) { '/dne' } | ||
let(:version) { 'perl-5.18.2' } | ||
let(:target) { 'foo' } | ||
let(:flags) { "--notest -j #{facts[:processorcount]}" } | ||
|
||
let(:title) { version } | ||
let(:params) {{ :target => target }} | ||
let(:pre_condition) { "perlbrew { '#{target}': install_root => '#{install_root}' }" } | ||
|
||
let(:perlbrew_env) { [ | ||
"HOME=#{install_root}", | ||
'PERLBREW_VERSION=0.71', | ||
"PERLBREW_PERL=#{version}", | ||
'PERLBREW_BASHRC_VERSION=0.71', | ||
"PERLBREW_ROOT=#{install_root}/perl5/perlbrew", | ||
"PERLBREW_HOME=#{install_root}/.perlbrew", | ||
"PERLBREW_MANPATH=#{install_root}/perl5/perlbrew/perls/#{version}/man", | ||
"PERLBREW_PATH=#{install_root}/perl5/perlbrew/bin:#{install_root}/perl5/perlbrew/perls/#{version}/bin", | ||
]} | ||
let(:perlbrew_path) {[ | ||
"#{install_root}/perl5/perlbrew/bin", | ||
"#{install_root}/perl5/perlbrew/perls/#{version}/bin", | ||
'/bin', | ||
'/usr/bin', | ||
]} | ||
|
||
shared_examples 'guts' do | ||
it { should contain_perlbrew__perl(title).that_requires("Perlbrew[#{target}]") } | ||
|
||
it { should contain_exec("#{target}_install_#{version}").with( | ||
:command => "perlbrew install #{flags} #{version}", | ||
:path => perlbrew_path, | ||
:environment => perlbrew_env, | ||
:cwd => '/dne', | ||
:user => nil, | ||
:group => nil, | ||
:logoutput => true, | ||
:creates => "/dne/perl5/perlbrew/perls/#{version}", | ||
:timeout => 3600 | ||
) | ||
} | ||
|
||
it { should contain_exec("#{target}_install-cpanm-#{version}").with( | ||
:command => 'perlbrew install-cpanm', | ||
:path => perlbrew_path, | ||
:environment => perlbrew_env, | ||
:cwd => '/dne', | ||
:user => nil, | ||
:group => nil, | ||
:logoutput => true, | ||
:creates => '/dne/perl5/perlbrew/perls/perl-5.18.2' | ||
:unless => 'which cpanm' | ||
) | ||
} | ||
it { should contain_exec('foo_switch_perl-5.18.2').with( | ||
:command => 'perlbrew switch perl-5.18.2', | ||
it { should contain_exec("#{target}_install-cpanm-#{version}").that_requires("Exec[#{target}_install_#{version}]") } | ||
|
||
it { should contain_exec("#{target}_switch_#{version}").with( | ||
:command => "perlbrew switch #{version}", | ||
:path => perlbrew_path, | ||
:environment => perlbrew_env, | ||
:cwd => '/dne', | ||
:user => nil, | ||
:group => nil, | ||
:logoutput => true, | ||
:unless => "grep PERLBREW_PERL=\\\"perl-5.18.2\\\" /dne/.perlbrew/init" | ||
:unless => "grep PERLBREW_PERL=\\\"#{version}\\\" /dne/.perlbrew/init" | ||
) | ||
} | ||
end | ||
it { should contain_exec("#{target}_switch_#{version}").that_requires("Exec[#{target}_install-cpanm-#{version}]") } | ||
end # guts | ||
|
||
context 'default params' do | ||
it_behaves_like 'guts' | ||
end # default params | ||
|
||
context 'target =>' do | ||
context 'bar' do | ||
let(:target) { 'foo' } | ||
before { params[:target] = target } | ||
|
||
it_behaves_like 'guts' | ||
end | ||
|
||
context '[]' do | ||
let(:params) {{ :target => [] }} | ||
|
||
it 'should fail' do | ||
expect { should }.to raise_error(Puppet::Error, /is not a string/) | ||
end | ||
end | ||
end # target => | ||
|
||
context 'version =>' do | ||
context '2.18.5-lrep' do | ||
let(:version) { '2.18.5-lrep' } | ||
before { params[:version] = version } | ||
|
||
it_behaves_like 'guts' | ||
end | ||
|
||
context '[]' do | ||
before { params[:version] = [] } | ||
|
||
it 'should fail' do | ||
expect { should }.to raise_error(Puppet::Error, /is not a string/) | ||
end | ||
end | ||
end # version => | ||
|
||
context 'flags =>' do | ||
context '--ponies' do | ||
let(:flags) { '--ponies' } | ||
before { params[:flags] = flags } | ||
|
||
it_behaves_like 'guts' | ||
end | ||
|
||
context '[]' do | ||
before { params[:flags] = [] } | ||
|
||
it 'should fail' do | ||
expect { should }.to raise_error(Puppet::Error, /is not a string/) | ||
end | ||
end | ||
end # flags => | ||
end |