diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-04-14 19:29:44 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-04-15 15:18:47 -0500 |
commit | 7c5305c7ab0284c6d1674a6476da5df4f1f9194b (patch) | |
tree | b220ab52842337ecf2c9554d001cbbbdfc5f69ba | |
parent | 2cc0439892d4a6adfa4169f7c3e0569c235c2c6c (diff) | |
download | bundler-7c5305c7ab0284c6d1674a6476da5df4f1f9194b.tar.gz |
[Exec] Allow executables to exit non-zero via at_exit
-rw-r--r-- | lib/bundler/cli/exec.rb | 3 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 9162d54913..013ba51076 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -21,7 +21,7 @@ module Bundler validate_cmd! SharedHelpers.set_bundle_environment if bin_path = Bundler.which(cmd) - kernel_load(bin_path, *args) if ruby_shebang?(bin_path) + return kernel_load(bin_path, *args) if ruby_shebang?(bin_path) # First, try to exec directly to something in PATH kernel_exec([bin_path, cmd], *args) else @@ -61,7 +61,6 @@ module Bundler Bundler.ui = nil require "bundler/setup" Kernel.load(file) - exit rescue SystemExit raise rescue Exception => e # rubocop:disable Lint/RescueException diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 29f5927c14..e2ae0aabbb 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -395,7 +395,7 @@ describe "bundle exec" do subject { bundle "exec #{path} arg1 arg2", :expect_err => true } shared_examples_for "it runs" do - it "like a normally executed executable like a normally executed executable" do + it "like a normally executed executable" do subject expect(exitstatus).to eq(exit_code) if exitstatus expect(err).to eq(expected_err) @@ -450,5 +450,12 @@ describe "bundle exec" do it_behaves_like "it runs" end + + context "when the executable exits non-zero via at_exit" do + let(:executable) { super() + "\n\nat_exit { $! ? raise($!) : exit(1) }" } + let(:exit_code) { 1 } + + it_behaves_like "it runs" + end end end |