-
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.
do not try to add miniconda to path when its not in use
- Loading branch information
Showing
3 changed files
with
135 additions
and
45 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,31 +1,79 @@ | ||
require 'rspec/bash' | ||
require 'tempfile' | ||
|
||
describe 'n8l::generate_loader' do | ||
describe 'n8l::generate_loader_*' do | ||
include Rspec::Bash | ||
|
||
let(:stubbed_env) { create_stubbed_env } | ||
|
||
# Unfortunately, this example(s) needs to write to the filesystem. While | ||
# `cat` can be mocked out, bash i/o redirection can not. | ||
%w[bash csh ksh zsh].each do |sh| | ||
context sh do | ||
Tempfile.create(sh) do |f| | ||
it 'writes file' do | ||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
"n8l::generate_loader_#{sh} #{f.path} #{f.path}/python/banana", | ||
) | ||
|
||
expect(status.exitstatus).to be 0 | ||
expect(out).to eq('') | ||
expect(err).to eq('') | ||
|
||
expect(File.read(f)).to match( | ||
/This script is intended to be used with.*#{sh}/ | ||
) | ||
func = "n8l::generate_loader_#{sh}" | ||
|
||
describe func do | ||
context 'parameters' do | ||
context '$1/file_name' do | ||
it 'is required' do | ||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
) | ||
|
||
expect(out).to eq('') | ||
expect(err).to match('file_name is required') | ||
expect(status.exitstatus).to_not be 0 | ||
end | ||
end | ||
|
||
context '$2/eups_pkgroot' do | ||
it 'is required' do | ||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
"#{func} foo" | ||
) | ||
|
||
expect(out).to eq('') | ||
expect(err).to match('eups_pkgroot is required') | ||
expect(status.exitstatus).to_not be 0 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
context '$3/miniconda_path' do | ||
%w[with without].each do |have| | ||
Tempfile.create(sh) do |f| | ||
context have do | ||
have == 'with' && miniconda_path = "#{f.path}/python/banana" | ||
|
||
it "writes loadLSST script #{have} PATH" do | ||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
"#{func} #{f.path} /dne/banana #{miniconda_path}" | ||
) | ||
|
||
expect(out).to eq('') | ||
expect(err).to eq('') | ||
expect(status.exitstatus).to be 0 | ||
|
||
loader = File.read(f) | ||
|
||
expect(loader).to match( | ||
"This script is intended to be used with.*#{sh}" | ||
) | ||
expect(loader).to match('/dne/banana') | ||
|
||
case have | ||
when 'with' | ||
expect(loader).to match('PATH') | ||
when 'without' | ||
expect(loader).to_not match('PATH') | ||
end | ||
end | ||
end | ||
end # $3/miniconda_path | ||
end # Tempfile | ||
end # have | ||
end # parameters | ||
end # func | ||
end # shell | ||
end |