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>" {
|
||||
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"
|
||||
|
||||
# emulate `ruby -S' behavior
|
||||
create_executable "ruby" <<SH
|
||||
#!$BASH
|
||||
if [[ \$1 == "-S"* ]]; then
|
||||
found="\$(PATH="\${RUBYPATH:-\$PATH}" which \$2)"
|
||||
# assert that the found executable has ruby for shebang
|
||||
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
|
||||
run ruby -S rake
|
||||
assert_success
|
||||
assert_success "hello rake"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue