Skip to content

Commit

Permalink
Merge pull request #162 from j8xixo12/fix_use_flavor_cmd
Browse files Browse the repository at this point in the history
Fix use flavor cmd
  • Loading branch information
yungyuc authored May 7, 2024
2 parents b1b5102 + 9ca221e commit 9f45123
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
29 changes: 14 additions & 15 deletions scripts/init
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ devenv() {
;;
use)
shift
# create subshell to isolate name space
(
. ${DEVENVROOT}/scripts/func.d/bash_utils
if [ ! -d "${DEVENVFLAVORROOT}/$1" ]; then
devenv_display "flavor $1 is not available"
return
if [ ! -d "${DEVENVFLAVORROOT}/$1" ]; then
# create subshell to isolate name space
(
. ${DEVENVROOT}/scripts/func.d/bash_utils
devenv_display -e "flavor $1 is not available"
)
else
# cmd use need to manipulate current session's env variables
# therefore subshell is not working here
if [ ! -z "${DEVENVFLAVOR}" ] ; then
devenv_act devenv_nameremove ${DEVENVFLAVOR}
fi
)
# cmd use need to manipulate current session's env variables
# therefore subshell is not working here
if [ ! -z "${DEVENVFLAVOR}" ] ; then
devenv_act devenv_nameremove ${DEVENVFLAVOR}
devenv_act devenv_namemunge $1
export DEVENVCURRENTROOT=${DEVENVFLAVORROOT}/${DEVENVFLAVOR}
echo "now using '${DEVENVFLAVOR}'"
fi

devenv_act devenv_namemunge $1
export DEVENVCURRENTROOT=${DEVENVFLAVORROOT}/${DEVENVFLAVOR}
echo "now using '${DEVENVFLAVOR}'"
;;
off)
# create subshell to isolate name space
Expand Down
1 change: 1 addition & 0 deletions tests/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ final_ret=0
./test_init_var.sh ; if [ $? != 0 ] ; then final_ret=1 ; fi
./test_bash_utils.sh ; if [ $? != 0 ] ; then final_ret=1 ; fi
./test_devenv_impl.sh ; if [ $? != 0 ] ; then final_ret=1 ; fi
./test_init.sh ; if [ $? != 0 ] ; then final_ret=1 ; fi

exit $final_ret
17 changes: 17 additions & 0 deletions tests/test_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
. ../scripts/init

echo "*** test file: $(basename ${BASH_SOURCE[0]})"

test_use_cmd() {
devenv add foo
devenv use foo
assertEquals ${DEVENVFLAVOR} "foo"
devenv off
devenv del foo
devenv use foo
assertNotContains "${DEVENVFLAVOR}" "foo"
}

# Load and run shUnit2.
. ./shunit2/shunit2

0 comments on commit 9f45123

Please sign in to comment.