add tests for exec
This commit is contained in:
parent
baf7656d2f
commit
4b6ab0389b
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
|
create_executable() {
|
||||||
|
bin="${RBENV_ROOT}/versions/${RBENV_VERSION}/bin"
|
||||||
|
mkdir -p "$bin"
|
||||||
|
echo "$2" > "${bin}/$1"
|
||||||
|
chmod +x "${bin}/$1"
|
||||||
|
}
|
||||||
|
|
||||||
@test "supports hook path with spaces" {
|
@test "supports hook path with spaces" {
|
||||||
hook_path="${RBENV_TEST_DIR}/custom stuff/rbenv hooks"
|
hook_path="${RBENV_TEST_DIR}/custom stuff/rbenv hooks"
|
||||||
mkdir -p "${hook_path}/exec"
|
mkdir -p "${hook_path}/exec"
|
||||||
@ -12,3 +19,41 @@ load test_helper
|
|||||||
assert_success
|
assert_success
|
||||||
assert_line "HELLO=from hook"
|
assert_line "HELLO=from hook"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "forwards all arguments" {
|
||||||
|
export RBENV_VERSION="2.0"
|
||||||
|
create_executable "ruby" "#!$BASH
|
||||||
|
echo \$0
|
||||||
|
while [[ \$# -gt 0 ]]; do
|
||||||
|
# hack to avoid bash builtin echo which can't output '-e'
|
||||||
|
\$(which echo) \$1
|
||||||
|
shift 1
|
||||||
|
done
|
||||||
|
"
|
||||||
|
|
||||||
|
run rbenv-exec ruby -w -e "puts 'hello world'" -- extra args
|
||||||
|
assert_line 0 "${RBENV_ROOT}/versions/2.0/bin/ruby"
|
||||||
|
assert_line 1 "-w"
|
||||||
|
assert_line 2 "-e"
|
||||||
|
assert_line 3 "puts 'hello world'"
|
||||||
|
assert_line 4 "--"
|
||||||
|
assert_line 5 "extra"
|
||||||
|
assert_line 6 "args"
|
||||||
|
refute_line 7
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "supports ruby -S <cmd>" {
|
||||||
|
export RBENV_VERSION="2.0"
|
||||||
|
create_executable "ruby" "#!$BASH
|
||||||
|
if [[ \$1 = '-S' ]]; then
|
||||||
|
head -1 \$(which \$2) | grep ruby >/dev/null
|
||||||
|
exit \$?
|
||||||
|
else
|
||||||
|
echo 'ruby 2.0 (rbenv test)'
|
||||||
|
fi"
|
||||||
|
create_executable "rake" "#!/usr/bin/env ruby"
|
||||||
|
|
||||||
|
rbenv-rehash
|
||||||
|
run ruby -S rake
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
@ -62,9 +62,18 @@ assert_line() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refute_line() {
|
refute_line() {
|
||||||
for line in "${lines[@]}"; do
|
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||||
if [ "$line" = "$1" ]; then flunk "expected to not find line \`$line'"; fi
|
num_lines="${#lines[@]}"
|
||||||
done
|
if [ "$1" -lt "$num_lines" ]; then
|
||||||
|
flunk "output has $num_lines lines"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
if [ "$line" = "$1" ]; then
|
||||||
|
flunk "expected to not find line \`$line'"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
assert() {
|
assert() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user