-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add warning for known problematic env vars
- Loading branch information
Showing
3 changed files
with
161 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'rspec/bash' | ||
|
||
describe 'n8l::problem_vars_check' do | ||
include Rspec::Bash | ||
|
||
let(:stubbed_env) { create_stubbed_env } | ||
subject(:func) { 'n8l::problem_vars_check' } | ||
|
||
let(:problems) do | ||
%w[ | ||
EUPS_PATH | ||
EUPS_PKGROOT | ||
LSST_HOME | ||
REPOSITORY_PATH | ||
] | ||
end | ||
|
||
context 'no problematic vars defined' do | ||
it 'reports nothing' do | ||
problem_vars = stubbed_env.stub_command('n8l::problem_vars') | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
) | ||
|
||
expect(out).to eq('') | ||
expect(err).to eq('') | ||
expect(status.exitstatus).to be 0 | ||
|
||
expect(problem_vars).to be_called | ||
end | ||
end | ||
|
||
context 'problematic vars defined' do | ||
it 'prints multiple params to stderr' do | ||
problem_vars = stubbed_env.stub_command('n8l::problem_vars').outputs( | ||
problems.join(' ') | ||
) | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
<<-SCRIPT | ||
#{problems.collect { |var| "#{var}=foo;" }.join(' ')} | ||
#{func} | ||
SCRIPT | ||
) | ||
|
||
expect(out).to eq('') | ||
problems.each { |var| expect(err).to match(/#{var}="foo"/) } | ||
expect(status.exitstatus).to_not be 0 | ||
|
||
expect(problem_vars).to be_called | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require 'rspec/bash' | ||
|
||
describe 'n8l::problem_vars' do | ||
include Rspec::Bash | ||
|
||
let(:stubbed_env) { create_stubbed_env } | ||
subject(:func) { 'n8l::problem_vars' } | ||
|
||
let(:problems) do | ||
%w[ | ||
EUPS_PATH | ||
EUPS_PKGROOT | ||
LSST_HOME | ||
REPOSITORY_PATH | ||
] | ||
end | ||
|
||
context 'no problematic vars defined' do | ||
it 'reports nothing' do | ||
problems.each { |var| ENV.delete(var) } | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
<<-SCRIPT | ||
unset #{problems.join(' ')} | ||
#{func} | ||
SCRIPT | ||
) | ||
|
||
expect(out).to eq('') | ||
expect(err).to eq('') | ||
expect(status.exitstatus).to be 0 | ||
end | ||
end | ||
|
||
context 'problematic vars defined' do | ||
it 'prints multiple params to stderr' do | ||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
<<-SCRIPT | ||
#{problems.collect { |var| "#{var}=foo;" }.join(' ')} | ||
#{func} | ||
SCRIPT | ||
) | ||
|
||
expect(out).to eq('EUPS_PATH EUPS_PKGROOT LSST_HOME REPOSITORY_PATH') | ||
expect(err).to eq('') | ||
expect(status.exitstatus).to be 0 | ||
end | ||
end | ||
end |