diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-08-09 11:18:33 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-08-10 12:49:25 -0500 |
commit | 19e9d85836ce4400cbcc15ceed2a5c356c352da9 (patch) | |
tree | 61f9971e459792bcf722863b9ff9716677a01318 | |
parent | 9fcf54edea0370da23e7d84d135ea7a4d47024b9 (diff) | |
download | bundler-pr/4589.tar.gz |
[Exec] Only set process title on Ruby 2.1+pr/4589
The Process method is not available before then
-rw-r--r-- | lib/bundler/cli/exec.rb | 10 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 11 |
2 files changed, 11 insertions, 10 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index b02a610c21..8240fc2342 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -63,7 +63,7 @@ module Bundler args.pop if args.last.is_a?(Hash) ARGV.replace(args) $0 = file - Process.setproctitle(process_title(file, *args)) + Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle) ui = Bundler.ui Bundler.ui = nil require "bundler/setup" @@ -79,12 +79,8 @@ module Bundler abort "#{e.class}: #{e.message}\n #{backtrace.join("\n ")}" end - def process_title(file, *args) - if args.empty? - file - else - "#{file} #{args.join(" ")}".strip - end + def process_title(file, args) + "#{file} #{args.join(" ")}".strip end def ruby_shebang?(file) diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index e2283d7aa4..8163fc7725 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -462,7 +462,8 @@ describe "bundle exec" do puts "EXEC: \#{caller.grep(/load/).empty? ? 'exec' : 'load'}" puts "ARGS: \#{$0} \#{ARGV.join(' ')}" puts "RACK: \#{RACK}" - puts "PROCESS: \#{`ps --no-headers -oargs -p\#{Process.pid}`.strip}" + process_title = `ps -o args -p \#{Process.pid}`.split("\n", 2).last.strip + puts "PROCESS: \#{process_title}" RUBY before do @@ -477,7 +478,11 @@ describe "bundle exec" do let(:exec) { "EXEC: load" } let(:args) { "ARGS: #{path} arg1 arg2" } let(:rack) { "RACK: 1.0.0" } - let(:process) { "PROCESS: #{path} arg1 arg2" } + let(:process) do + title = "PROCESS: #{path}" + title += " arg1 arg2" if RUBY_VERSION >= "2.1" + title + end let(:exit_code) { 0 } let(:expected) { [exec, args, rack, process].join("\n") } let(:expected_err) { "" } @@ -513,7 +518,7 @@ describe "bundle exec" do let(:exit_code) { 1 } let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } let(:expected_err) do - "RuntimeError: ERROR\n #{path}:8" + + "RuntimeError: ERROR\n #{path}:10" + (Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'") end it_behaves_like "it runs" |