Skip to content
Myr

[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

1 file+14 added−14 removed

modified:test/install_script/nvm_detect_profile+14 added-14 removed
33 unmodified lines
34# Confirm profile detection via $SHELL works and that $PROFILE overrides profile detection35#3637# setting $PROFILE to /dev/null should return no detected profile38NVM_DETECT_PROFILE="$(PROFILE='/dev/null'; nvm_detect_profile)"38NVM_DETECT_PROFILE="$(PROFILE='/dev/null' nvm_detect_profile)"39if [ -n "$NVM_DETECT_PROFILE" ]; then40 die "nvm_detect_profile still detected a profile even though PROFILE=/dev/null"41fi4243# .bashrc should be detected for bash44NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; unset PROFILE; nvm_detect_profile)"44NVM_DETECT_PROFILE="$(SHELL="/bin/bash" PROFILE= nvm_detect_profile)"45if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then46 die "nvm_detect_profile didn't pick \$HOME/.bashrc for bash"47fi4849# $PROFILE should override .bashrc profile detection50NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; PROFILE="test_profile"; nvm_detect_profile)"50NVM_DETECT_PROFILE="$(SHELL="/bin/bash" PROFILE="test_profile" nvm_detect_profile)"51if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then52 die "nvm_detect_profile ignored \$PROFILE"53fi5455# zdotdir/.zshrc should be detected for zsh56NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"56NVM_DETECT_PROFILE="$(SHELL="/bin/zsh" PROFILE= nvm_detect_profile)"57if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then58 die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"59fi6061# .zshrc should be detected for zsh62NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; unset ZDOTDIR; nvm_detect_profile)"62NVM_DETECT_PROFILE="$(SHELL="/bin/zsh" PROFILE= ZDOTDIR= nvm_detect_profile)"63if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then64 die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"65fi66
7 unmodified lines
74# Confirm $PROFILE is only returned when it points to a valid file75#7677# $PROFILE is a valid file78NVM_DETECT_PROFILE="$(PROFILE="test_profile"; unset SHELL; nvm_detect_profile)"78NVM_DETECT_PROFILE="$(PROFILE="test_profile" SHELL= nvm_detect_profile)"79if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then80 die "nvm_detect_profile didn't pick \$PROFILE when it was a valid file"81fi82
10 unmodified lines
93# return an empty value if everything fails94#9596# It should favor .profile if file exists97NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"97NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"98if [ "$NVM_DETECT_PROFILE" != "$HOME/.profile" ]; then99 die "nvm_detect_profile should have selected .profile"100fi101102# Otherwise, it should favor .bashrc if file exists103rm ".profile"104NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"104NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"105if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then106 die "nvm_detect_profile should have selected .bashrc"107fi108109# Otherwise, it should favor .bash_profile if file exists110rm ".bashrc"111NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"111NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"112if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then113 die "nvm_detect_profile should have selected .bash_profile"114fi115116# Otherwise, it should favor zdotdir/.zprofile if file exists117rm ".bash_profile"118NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"118NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"119if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then120 die "nvm_detect_profile should have selected zdotdir/.zprofile"121fi122123# Otherwise, it should favor .zprofile if file exists124rm "zdotdir/.zprofile"125NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"125NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"126if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then127 die "nvm_detect_profile should have selected .zprofile"128fi129130# Otherwise, it should favor zdotdir/.zshrc if file exists131rm ".zprofile"132NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"132NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"133if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then134 die "nvm_detect_profile should have selected zdotdir/.zshrc"135fi136137# Otherwise, it should favor .zshrc if file exists138rm "zdotdir/.zshrc"139NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"139NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"140if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then141 die "nvm_detect_profile should have selected .zshrc"142fi143144# It should be empty if none is found145rm ".zshrc"146NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"146NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"147if [ ! -z "$NVM_DETECT_PROFILE" ]; then148 die "nvm_detect_profile should have returned an empty value"149fi150
1 unmodified line