Skip to content

Commit

Permalink
Merge pull request #71 from lsst/tickets/DM-11946-ignore-pkgroot
Browse files Browse the repository at this point in the history
do not preserve EUPS_PKGROOT by default
  • Loading branch information
jhoblitt committed Sep 19, 2017
2 parents 7940a23 + a331762 commit 14d95ad
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
18 changes: 15 additions & 3 deletions scripts/newinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ n8l::has_cmd() {
n8l::usage() {
n8l::fail "$(cat <<-EOF
usage: newinstall.sh [-b] [-f] [-h] [-n] [-3|-2] [-t|-T] [-s|-S] [-P <path-to-python>]
usage: newinstall.sh [-b] [-f] [-h] [-n] [-3|-2] [-t|-T] [-s|-S] [-p]
[-P <path-to-python>]
-b -- Run in batch mode. Don\'t ask any questions and install all extra
packages.
-c -- Attempt to continue a previously failed install.
Expand All @@ -116,6 +117,7 @@ n8l::usage() {
-T -- DO NOT use pre-compiled EUPS "tarball" packages.
-s -- Use EUPS source "eupspkg" packages, if available.
-S -- DO NOT use EUPS source "eupspkg" packages.
-p -- Preserve EUPS_PKGROOT environment variable.
-h -- Display this help message.
EOF
Expand Down Expand Up @@ -163,7 +165,7 @@ n8l::parse_args() {
local OPTIND
local opt

while getopts cbhnP:32tTsS opt; do
while getopts cbhnP:32tTsSp opt; do
case $opt in
b)
BATCH_FLAG=true
Expand Down Expand Up @@ -195,6 +197,9 @@ n8l::parse_args() {
S)
EUPS_USE_EUPSPKG=false
;;
p)
PRESERVE_EUPS_PKGROOT_FLAG=true
;;
h|*)
n8l::usage
;;
Expand Down Expand Up @@ -951,6 +956,7 @@ n8l::main() {
CONT_FLAG=false
BATCH_FLAG=false
NOOP_FLAG=false
PRESERVE_EUPS_PKGROOT_FLAG=false

n8l::parse_args "$@"

Expand Down Expand Up @@ -1006,7 +1012,13 @@ n8l::main() {
# being used to build the stack itself.
EUPS_PYTHON=${EUPS_PYTHON:-$(which python)}

EUPS_PKGROOT=${EUPS_PKGROOT:-$(n8l::default_eups_pkgroot $EUPS_USE_EUPSPKG $EUPS_USE_TARBALLS)}
if [[ $PRESERVE_EUPS_PKGROOT_FLAG == true ]]; then
EUPS_PKGROOT=${EUPS_PKGROOT:-$(
n8l::default_eups_pkgroot $EUPS_USE_EUPSPKG $EUPS_USE_TARBALLS)}
else
EUPS_PKGROOT=$(
n8l::default_eups_pkgroot $EUPS_USE_EUPSPKG $EUPS_USE_TARBALLS)
fi
n8l::print_error "Configured EUPS_PKGROOT: ${EUPS_PKGROOT}\n"

# Install EUPS
Expand Down
46 changes: 39 additions & 7 deletions spec/unit/n8l/parse_args_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
include Rspec::Bash

let(:stubbed_env) { create_stubbed_env }
subject(:func) { 'n8l::parse_args' }

context 'cli options' do
context 'without arguments' do
%w[b c n 2 3 t T s S].each do |flag|
%w[b c n 2 3 t T s S 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}",
"#{func} -#{flag}",
)

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

expect(status.exitstatus).to be 0
end
end # context "-#{flag}"
Expand All @@ -30,12 +30,11 @@
it 'should not die' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
"n8l::parse_args -#{flag} foo",
"#{func} -#{flag} foo",
)

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

expect(status.exitstatus).to be 0
end
end # context "-#{flag}"
Expand All @@ -48,16 +47,49 @@
it 'should die' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
"n8l::parse_args -#{flag}",
"#{func} -#{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'

context '-p' do
context 'unset' do
it 'should not set PRESERVE_EUPS_PKGROOT_FLAG' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
<<-SCRIPT
#{func}
echo -n PRESERVE_EUPS_PKGROOT_FLAG=$PRESERVE_EUPS_PKGROOT_FLAG
SCRIPT
)

expect(out).to eq('PRESERVE_EUPS_PKGROOT_FLAG=')
expect(err).to eq('')
expect(status.exitstatus).to be 0
end
end

context 'set' do
it 'should set PRESERVE_EUPS_PKGROOT_FLAG=true' do
out, err, status = stubbed_env.execute_function(
'scripts/newinstall.sh',
<<-SCRIPT
#{func} -p
echo -n PRESERVE_EUPS_PKGROOT_FLAG=$PRESERVE_EUPS_PKGROOT_FLAG
SCRIPT
)

expect(out).to eq('PRESERVE_EUPS_PKGROOT_FLAG=true')
expect(err).to eq('')
expect(status.exitstatus).to be 0
end
end
end # context "-p"
end # context 'cli options'
end

0 comments on commit 14d95ad

Please sign in to comment.