mirror of
https://github.com/rbenv/rbenv.git
synced 2024-12-28 20:55:38 +01:00
undo assert_output_lines
in tests
It was a dumb idea and it wasn't even implemented perfectly.
This commit is contained in:
parent
969af1567a
commit
7fc5f46bbb
8 changed files with 67 additions and 58 deletions
|
@ -38,7 +38,9 @@ else
|
|||
exit 1
|
||||
fi"
|
||||
run rbenv-completions hello happy world
|
||||
assert_success "\
|
||||
happy
|
||||
world"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
happy
|
||||
world
|
||||
OUT
|
||||
}
|
||||
|
|
|
@ -27,9 +27,11 @@ create_executable() {
|
|||
|
||||
rbenv-rehash
|
||||
run rbenv-completions exec
|
||||
assert_success "\
|
||||
rake
|
||||
ruby"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
rake
|
||||
ruby
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "supports hook path with spaces" {
|
||||
|
@ -50,19 +52,20 @@ create_executable() {
|
|||
echo \$0
|
||||
for arg; do
|
||||
# hack to avoid bash builtin echo which can't output '-e'
|
||||
printf "%s\\n" "\$arg"
|
||||
printf " %s\\n" "\$arg"
|
||||
done
|
||||
SH
|
||||
|
||||
run rbenv-exec ruby -w -e "puts 'hello world'" -- extra args
|
||||
assert_success "\
|
||||
${RBENV_ROOT}/versions/2.0/bin/ruby
|
||||
-w
|
||||
-e
|
||||
puts 'hello world'
|
||||
--
|
||||
extra
|
||||
args"
|
||||
run rbenv-exec ruby -w "/path to/ruby script.rb" -- extra args
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
${RBENV_ROOT}/versions/2.0/bin/ruby
|
||||
-w
|
||||
/path to/ruby script.rb
|
||||
--
|
||||
extra
|
||||
args
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "supports ruby -S <cmd>" {
|
||||
|
@ -85,9 +88,10 @@ else
|
|||
fi
|
||||
SH
|
||||
|
||||
create_executable "rake" "\
|
||||
#!/usr/bin/env ruby
|
||||
echo hello rake"
|
||||
create_executable "rake" <<SH
|
||||
#!/usr/bin/env ruby
|
||||
echo hello rake
|
||||
SH
|
||||
|
||||
rbenv-rehash
|
||||
run ruby -S rake
|
||||
|
|
|
@ -22,10 +22,12 @@ create_hook() {
|
|||
create_hook "$path2" exec "bueno.bash"
|
||||
|
||||
RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec
|
||||
assert_success "\
|
||||
${RBENV_TEST_DIR}/rbenv.d/exec/ahoy.bash
|
||||
${RBENV_TEST_DIR}/rbenv.d/exec/hello.bash
|
||||
${RBENV_TEST_DIR}/etc/rbenv_hooks/exec/bueno.bash"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
${RBENV_TEST_DIR}/rbenv.d/exec/ahoy.bash
|
||||
${RBENV_TEST_DIR}/rbenv.d/exec/hello.bash
|
||||
${RBENV_TEST_DIR}/etc/rbenv_hooks/exec/bueno.bash
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "supports hook paths with spaces" {
|
||||
|
@ -35,9 +37,11 @@ create_hook() {
|
|||
create_hook "$path2" exec "ahoy.bash"
|
||||
|
||||
RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec
|
||||
assert_success "\
|
||||
${RBENV_TEST_DIR}/my hooks/rbenv.d/exec/hello.bash
|
||||
${RBENV_TEST_DIR}/etc/rbenv hooks/exec/ahoy.bash"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
${RBENV_TEST_DIR}/my hooks/rbenv.d/exec/hello.bash
|
||||
${RBENV_TEST_DIR}/etc/rbenv hooks/exec/ahoy.bash
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "resolves relative paths" {
|
||||
|
|
|
@ -45,8 +45,10 @@ create_executable() {
|
|||
assert_success ""
|
||||
|
||||
run ls "${RBENV_ROOT}/shims"
|
||||
assert_success "\
|
||||
rake
|
||||
rspec
|
||||
ruby"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
rake
|
||||
rspec
|
||||
ruby
|
||||
OUT
|
||||
}
|
||||
|
|
|
@ -22,9 +22,11 @@ load test_helper
|
|||
|
||||
@test "shell change invalid version" {
|
||||
run rbenv-sh-shell 1.2.3
|
||||
assert_failure "\
|
||||
rbenv: version \`1.2.3' not installed
|
||||
return 1"
|
||||
assert_failure
|
||||
assert_output <<SH
|
||||
rbenv: version \`1.2.3' not installed
|
||||
return 1
|
||||
SH
|
||||
}
|
||||
|
||||
@test "shell change version" {
|
||||
|
|
|
@ -26,7 +26,7 @@ assert_success() {
|
|||
if [ "$status" -ne 0 ]; then
|
||||
flunk "command failed with exit status $status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
assert_output_lines "$1"
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ assert_failure() {
|
|||
if [ "$status" -eq 0 ]; then
|
||||
flunk "expected failed exit status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
assert_output_lines "$1"
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -47,21 +47,11 @@ assert_equal() {
|
|||
}
|
||||
|
||||
assert_output() {
|
||||
assert_equal "$1" "$output"
|
||||
}
|
||||
|
||||
# compares lines with leading whitespace trimmed
|
||||
assert_output_lines() {
|
||||
local -a expected
|
||||
IFS=$'\n' expected=($1)
|
||||
for (( i=0; i < ${#expected[@]}; i++ )); do
|
||||
local wants="${expected[$i]}"
|
||||
local got="${lines[$i]}"
|
||||
assert_equal \
|
||||
"${wants#"${wants%%[![:space:]]*}"}" \
|
||||
"${got#"${got%%[![:space:]]*}"}"
|
||||
done
|
||||
assert_equal "${expected[$i]}" "${lines[$i]}"
|
||||
local expected
|
||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||
else expected="$1"
|
||||
fi
|
||||
assert_equal "$expected" "$output"
|
||||
}
|
||||
|
||||
assert_line() {
|
||||
|
|
|
@ -16,9 +16,11 @@ create_executable() {
|
|||
create_executable "2.0" "rspec"
|
||||
|
||||
run rbenv-whence ruby
|
||||
assert_success "\
|
||||
1.8
|
||||
2.0"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
1.8
|
||||
2.0
|
||||
OUT
|
||||
|
||||
run rbenv-whence rake
|
||||
assert_success "1.8"
|
||||
|
|
|
@ -49,9 +49,12 @@ create_executable() {
|
|||
create_executable "2.0" "rspec"
|
||||
|
||||
RBENV_VERSION=1.8 run rbenv-which rspec
|
||||
assert_failure "\
|
||||
rbenv: rspec: command not found
|
||||
The \`rspec' command exists in these Ruby versions:
|
||||
1.9
|
||||
2.0"
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
rbenv: rspec: command not found
|
||||
|
||||
The \`rspec' command exists in these Ruby versions:
|
||||
1.9
|
||||
2.0
|
||||
OUT
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue