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 use flavor cmd #162

Merged
merged 3 commits into from
May 7, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a unit test to ensure the behavior of use command is expected.


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
Loading