diff options
author | Homu <homu@barosl.com> | 2016-08-11 16:00:20 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-08-11 16:00:20 +0900 |
commit | 2c1931429d59e1d701bf27c7e3c186fc47f63333 (patch) | |
tree | 352ef31b01aa744276c727ace3152a032cf38f7c | |
parent | 0e94f1746de55224f1640d0d20efd573c4294f66 (diff) | |
parent | 19e9d85836ce4400cbcc15ceed2a5c356c352da9 (diff) | |
download | bundler-2c1931429d59e1d701bf27c7e3c186fc47f63333.tar.gz |
Auto merge of #4863 - bundler:pr/4589, r=indirect
Manually set a process title when using load
Closes #4589.
See https://github.com/bundler/bundler/issues/4852.
-rw-r--r-- | lib/bundler/cli/exec.rb | 5 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index f0ce450959..8240fc2342 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -63,6 +63,7 @@ module Bundler args.pop if args.last.is_a?(Hash) ARGV.replace(args) $0 = file + Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle) ui = Bundler.ui Bundler.ui = nil require "bundler/setup" @@ -78,6 +79,10 @@ module Bundler abort "#{e.class}: #{e.message}\n #{backtrace.join("\n ")}" end + def process_title(file, args) + "#{file} #{args.join(" ")}".strip + end + def ruby_shebang?(file) possibilities = [ "#!/usr/bin/env ruby\n", diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 4e2bdbbb7a..8163fc7725 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -462,6 +462,8 @@ describe "bundle exec" do puts "EXEC: \#{caller.grep(/load/).empty? ? 'exec' : 'load'}" puts "ARGS: \#{$0} \#{ARGV.join(' ')}" puts "RACK: \#{RACK}" + process_title = `ps -o args -p \#{Process.pid}`.split("\n", 2).last.strip + puts "PROCESS: \#{process_title}" RUBY before do @@ -476,8 +478,13 @@ describe "bundle exec" do let(:exec) { "EXEC: load" } let(:args) { "ARGS: #{path} arg1 arg2" } let(:rack) { "RACK: 1.0.0" } + 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].join("\n") } + let(:expected) { [exec, args, rack, process].join("\n") } let(:expected_err) { "" } subject { bundle "exec #{path} arg1 arg2" } @@ -511,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}:7" + + "RuntimeError: ERROR\n #{path}:10" + (Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'") end it_behaves_like "it runs" |