From 7a10b64cf7e4df3261dec94f3c609a64a04998ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Tue, 2 Apr 2013 02:48:27 +0200 Subject: [PATCH] better emulate `ruby -S` behavior in testing Per https://github.com/ruby/ruby/blob/7d3db3c/ruby.c#L1383-1391 --- test/exec.bats | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/test/exec.bats b/test/exec.bats index 9b163689..45e7f731 100644 --- a/test/exec.bats +++ b/test/exec.bats @@ -67,16 +67,29 @@ SH @test "supports ruby -S " { 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" </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" }