yahns Ruby server user/dev discussion
 help / color / Atom feed
* [PATCH] test_bin: use RbConfig.ruby for non-standard names
@ 2017-04-06  5:11 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-04-06  5:11 UTC (permalink / raw)
  To: yahns-public

It's possible to have "ruby" executables by other names
(e.g. "ruby24"), so use a supported API for finding our
executable.

This feature was added in Ruby 1.9.2, so it's safe to use
as we've always been 1.9.3+ (and nowadays 2.0+)
---
 test/test_bin.rb | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/test/test_bin.rb b/test/test_bin.rb
index af990ad..579e39c 100644
--- a/test/test_bin.rb
+++ b/test/test_bin.rb
@@ -9,7 +9,7 @@ class TestBin < Testcase
 
   def setup
     server_helper_setup
-    @cmd = %W(ruby -I lib bin/yahns)
+    @cmd = %W(#{RbConfig.ruby} -I lib bin/yahns)
   end
 
   def test_listen_fd3
@@ -19,7 +19,7 @@ def test_listen_fd3
 
     ru = tmpfile(%w(test_bin_daemon .ru))
     ru.write("require 'rack/lobster'; run Rack::Lobster.new\n")
-    cmd = %W(ruby -I lib bin/yahns-rackup
+    cmd = %W(#{RbConfig.ruby} -I lib bin/yahns-rackup
              -E none -p #{port} -o #{host} #{ru.path})
     pid = fork do # emulate a systemd environment
       env = {
@@ -159,10 +159,9 @@ def usr2_dir(tmpdir, preload, worker)
     # other processes which fork (but do not exec), causing ETXTBUSY on
     # Process.spawn
     pid = fork do
-      ruby = "#!#{`which ruby`}"
       File.open(exe, "w") { |y|
         lines = File.readlines("bin/yahns")
-        lines[0] = ruby
+        lines[0] = "#!#{RbConfig.ruby}\n"
         y.chmod(0755)
         y.syswrite(lines.join)
       }
-- 
EW


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06  5:11 [PATCH] test_bin: use RbConfig.ruby for non-standard names Eric Wong

yahns Ruby server user/dev discussion

Archives are clonable:
	git clone --mirror https://yhbt.net/yahns-public
	git clone --mirror http://ou63pmih66umazou.onion/yahns-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.yahns
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.yahns

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox