[Tests] `nvm_detect_profile`: refactor
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jordan Harband · committed by Jordan Harband · parent abd02e5 · Browse files · 1 file·+14 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+14 added−14 removed
- tests:+14 added−14 removed
Provenance
- Commit
9659af6- Tree
861c670- Author
Jordan Harband <ljharb@gmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
abd02e5
1 file changed+14 added−14 removed
modified:test/install_script/nvm_detect_profile+14 added-14 removed
33 unmodified lines34 # Confirm profile detection via $SHELL works and that $PROFILE overrides profile detection35 #36 37 # setting $PROFILE to /dev/null should return no detected profile38-NVM_DETECT_PROFILE="$(PROFILE='/dev/null'; nvm_detect_profile)"38+NVM_DETECT_PROFILE="$(PROFILE='/dev/null' nvm_detect_profile)"39 if [ -n "$NVM_DETECT_PROFILE" ]; then40 die "nvm_detect_profile still detected a profile even though PROFILE=/dev/null"41 fi42 43 # .bashrc should be detected for bash44-NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; unset PROFILE; nvm_detect_profile)"44+NVM_DETECT_PROFILE="$(SHELL="/bin/bash" PROFILE= nvm_detect_profile)"45 if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then46 die "nvm_detect_profile didn't pick \$HOME/.bashrc for bash"47 fi48 49 # $PROFILE should override .bashrc profile detection50-NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; PROFILE="test_profile"; nvm_detect_profile)"50+NVM_DETECT_PROFILE="$(SHELL="/bin/bash" PROFILE="test_profile" nvm_detect_profile)"51 if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then52 die "nvm_detect_profile ignored \$PROFILE"53 fi54 55 # zdotdir/.zshrc should be detected for zsh56-NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"56+NVM_DETECT_PROFILE="$(SHELL="/bin/zsh" PROFILE= nvm_detect_profile)"57 if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then58 die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"59 fi60 61 # .zshrc should be detected for zsh62-NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; unset ZDOTDIR; nvm_detect_profile)"62+NVM_DETECT_PROFILE="$(SHELL="/bin/zsh" PROFILE= ZDOTDIR= nvm_detect_profile)"63 if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then64 die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"65 fi66 7 unmodified lines74 # Confirm $PROFILE is only returned when it points to a valid file75 #76 77 # $PROFILE is a valid file78-NVM_DETECT_PROFILE="$(PROFILE="test_profile"; unset SHELL; nvm_detect_profile)"78+NVM_DETECT_PROFILE="$(PROFILE="test_profile" SHELL= nvm_detect_profile)"79 if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then80 die "nvm_detect_profile didn't pick \$PROFILE when it was a valid file"81 fi82 10 unmodified lines93 # return an empty value if everything fails94 #95 96 # It should favor .profile if file exists97-NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"97+NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"98 if [ "$NVM_DETECT_PROFILE" != "$HOME/.profile" ]; then99 die "nvm_detect_profile should have selected .profile"100 fi101 102 # Otherwise, it should favor .bashrc if file exists103 rm ".profile"104-NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"104+NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"105 if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then106 die "nvm_detect_profile should have selected .bashrc"107 fi108 109 # Otherwise, it should favor .bash_profile if file exists110 rm ".bashrc"111-NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"111+NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"112 if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then113 die "nvm_detect_profile should have selected .bash_profile"114 fi115 116 # Otherwise, it should favor zdotdir/.zprofile if file exists117 rm ".bash_profile"118-NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"118+NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"119 if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then120 die "nvm_detect_profile should have selected zdotdir/.zprofile"121 fi122 123 # Otherwise, it should favor .zprofile if file exists124 rm "zdotdir/.zprofile"125-NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"125+NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"126 if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then127 die "nvm_detect_profile should have selected .zprofile"128 fi129 130 # Otherwise, it should favor zdotdir/.zshrc if file exists131 rm ".zprofile"132-NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"132+NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"133 if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then134 die "nvm_detect_profile should have selected zdotdir/.zshrc"135 fi136 137 # Otherwise, it should favor .zshrc if file exists138 rm "zdotdir/.zshrc"139-NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"139+NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"140 if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then141 die "nvm_detect_profile should have selected .zshrc"142 fi143 144 # It should be empty if none is found145 rm ".zshrc"146-NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"146+NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"147 if [ ! -z "$NVM_DETECT_PROFILE" ]; then148 die "nvm_detect_profile should have returned an empty value"149 fi150 1 unmodified line