mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
better emulate ruby -S
behavior in testing
Per https://github.com/ruby/ruby/blob/7d3db3c/ruby.c#L1383-1391
This commit is contained in:
parent
f6db678b20
commit
7a10b64cf7
1 changed files with 22 additions and 9 deletions
|
@ -67,16 +67,29 @@ SH
|
||||||
|
|
||||||
@test "supports ruby -S <cmd>" {
|
@test "supports ruby -S <cmd>" {
|
||||||
export RBENV_VERSION="2.0"
|
export RBENV_VERSION="2.0"
|
||||||
create_executable "ruby" "#!$BASH
|
|
||||||
if [[ \$1 = '-S' ]]; then
|
# emulate `ruby -S' behavior
|
||||||
head -1 \$(which \$2) | grep ruby >/dev/null
|
create_executable "ruby" <<SH
|
||||||
exit \$?
|
#!$BASH
|
||||||
else
|
if [[ \$1 == "-S"* ]]; then
|
||||||
echo 'ruby 2.0 (rbenv test)'
|
found="\$(PATH="\${RUBYPATH:-\$PATH}" which \$2)"
|
||||||
fi"
|
# assert that the found executable has ruby for shebang
|
||||||
create_executable "rake" "#!/usr/bin/env ruby"
|
if head -1 "\$found" | grep ruby >/dev/null; then
|
||||||
|
\$BASH "\$found"
|
||||||
|
else
|
||||||
|
echo "ruby: no Ruby script found in input (LoadError)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'ruby 2.0 (rbenv test)'
|
||||||
|
fi
|
||||||
|
SH
|
||||||
|
|
||||||
|
create_executable "rake" "\
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
echo hello rake"
|
||||||
|
|
||||||
rbenv-rehash
|
rbenv-rehash
|
||||||
run ruby -S rake
|
run ruby -S rake
|
||||||
assert_success
|
assert_success "hello rake"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue