Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix -S and -T cli options #63

Merged
merged 3 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/newinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ eups_path() {
echo "${LSST_HOME}/stack/$(python_env_slug)"
}

parse_args() {
n8l::parse_args() {
local OPTIND
local opt

while getopts cbhnP:32t opt; do
while getopts cbhnP:32tTsS opt; do
case $opt in
b)
BATCH_FLAG=true
Expand Down Expand Up @@ -947,7 +947,7 @@ main() {
BATCH_FLAG=false
NOOP_FLAG=false

parse_args "$@"
n8l::parse_args "$@"

cat <<-EOF

Expand Down
63 changes: 63 additions & 0 deletions spec/unit/n8l/parse_args_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'rspec/bash'

describe 'n8l::parse_args' do
include Rspec::Bash

let(:stubbed_env) { create_stubbed_env }

context 'cli options' do
context 'without arguments' do
%w[ b c n 2 3 t T s S ].each do |flag|
context "-#{flag}" do
it 'should not die' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
"n8l::parse_args -#{flag}",
)

expect(out).to eq('')
expect(err).to eq('')

expect(status.exitstatus).to be 0
end
end # context "-#{flag}"
end
end # context 'without arguments'

context 'with arguments' do
%w[ P ].each do |flag|
context "-#{flag}" do
it 'should not die' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
"n8l::parse_args -#{flag} foo",
)

expect(out).to eq('')
expect(err).to eq('')

expect(status.exitstatus).to be 0
end
end # context "-#{flag}"
end
end # context 'with arguments'

context '-h or unknown option' do
%w[ h z ].each do |flag|
context "-#{flag}" do
it 'should die' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
"n8l::parse_args -#{flag}",
)

expect(out).to eq('')
expect(err).to match(/usage: newinstall.sh/)

expect(status.exitstatus).to_not be 0
end
end # context "-#{flag}"
end
end # context '-h or unknown option'
end # context 'cli options'
end