2014-07-15 02:12:58 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
rm tmp/node
|
|
|
|
rmdir tmp
|
|
|
|
rm tmp2/node
|
|
|
|
rmdir tmp2
|
|
|
|
}
|
2016-11-07 03:34:36 +08:00
|
|
|
die () { echo "$@" ; cleanup; exit 1; }
|
2014-07-15 02:12:58 +08:00
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../../../nvm.sh
|
2014-07-15 02:12:58 +08:00
|
|
|
|
|
|
|
mkdir -p tmp
|
2014-08-22 08:19:43 +08:00
|
|
|
touch tmp/node
|
2014-07-15 02:12:58 +08:00
|
|
|
mkdir -p tmp2
|
2014-08-22 08:19:43 +08:00
|
|
|
touch tmp2/node
|
2014-07-15 02:12:58 +08:00
|
|
|
|
2014-08-22 08:15:53 +08:00
|
|
|
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
|
|
|
|
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
|
|
|
|
[ "$(nvm_tree_contains_path tmp 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with one arg'
|
|
|
|
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with one arg'
|
|
|
|
|
2014-07-15 02:12:58 +08:00
|
|
|
nvm_tree_contains_path tmp tmp/node || die '"tmp" should contain "tmp/node"'
|
|
|
|
|
|
|
|
nvm_tree_contains_path tmp tmp2/node && die '"tmp" should not contain "tmp2/node"'
|
|
|
|
|
|
|
|
nvm_tree_contains_path tmp2 tmp2/node || die '"tmp2" should contain "tmp2/node"'
|
|
|
|
|
|
|
|
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
|
|
|
|
|
|
|
|
cleanup
|