Skip to content
Myr

Tests for PROFILE detection

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Xavier Cambar · committed by Xavier Cambar · parent d30c0fe · Browse files · 3 files+100 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+100 added−26 removed

  • tests:+69 added−1 removed
  • other:+31 added−25 removed

3 files+100 added−26 removed

added:test/install_script/nvm_detect_profile+67 added
1#!/bin/sh23cleanup () {4 unset -f setup cleanup die5 unset _PROFILE6 rm -f .bashrc .bash_profile .zshrc .profile test_profile > /dev/null 2>&17}8die () { echo $@ ; cleanup ; exit 1; }910NVM_ENV=testing . ../../install.sh1112setup () {13 touch .bashrc14 touch .bash_profile15 touch .zshrc16 touch .profile17 touch test_profile18}1920#Let's hack $HOME21HOME="."2223setup242526# $PROFILE points to a valid file, its path must be returned27PROFILE="test_profile"28_PROFILE=$(nvm_detect_profile)29[ "_$_PROFILE" = "_$PROFILE" ] || die "nvm_detect_profile didn't pick \$PROFILE"3031# $PROFILE doesn't point to a valid file, its path must not be returned32PROFILE="invalid_profile"33_PROFILE=$(nvm_detect_profile)34[ "_$_PROFILE" != "_$PROFILE" ] || die "nvm_detect_profile shouldn't pick \$PROFILE when it's not a valid file"353637# Below are tests for when $PROFILE is undefined38rm test_profile39unset PROFILE4041# It should favor .bashrc if file exists42_PROFILE=$(nvm_detect_profile)43[ "_$_PROFILE" = "_$HOME/.bashrc" ] || die "nvm_detect_profile should have selected .bashrc"4445rm .bashrc46# Otherwise, it should favor .bash_profile if file exists47_PROFILE=$(nvm_detect_profile)48[ "_$_PROFILE" = "_$HOME/.bash_profile" ] || die "nvm_detect_profile should have selected .bash_profile"4950rm .bash_profile51# Otherwise, it should favor .zshrc if file exists52_PROFILE=$(nvm_detect_profile)53[ "_$_PROFILE" = "_$HOME/.zshrc" ] || die "nvm_detect_profile should have selected .zshrc"5455rm .zshrc56# Otherwise, it should favor .profile if file exists57_PROFILE=$(nvm_detect_profile)58[ "_$_PROFILE" = "_$HOME/.profile" ] || die "nvm_detect_profile should have selected .profile"5960rm .profile61# It should be empty if none is found62_PROFILE=$(nvm_detect_profile)63[ -z "$_PROFILE" ] || die "nvm_detect_profile should have echo'ed an empty value"646566cleanup67
modified:test/install_script/nvm_reset+2 added-1 removed
1#!/bin/sh23cleanup () {4 unset -f safe_type4 unset -f safe_type die cleanup5}6die () { echo $@ ; cleanup ; exit 1; }78NVM_ENV=testing . ../../install.sh
14 unmodified lines
23! safe_type nvm_download || die 'nvm_download is still available'24! safe_type install_nvm_as_script || die 'install_nvm_as_script is still available'25! safe_type install_nvm_from_git || die 'install_nvm_from_git is still available'26! safe_type nvm_reset || die 'nvm_reset is still available'27! safe_type nvm_detect_profile || die 'nvm_detect_profile is still available'2829cleanup30
modified:install.sh+31 added-25 removed