From 5d88f2c1907def10eaa90353ea9bdb5cbea6d7f7 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 30 May 2020 17:35:17 +0100 Subject: [PATCH] [core] Merge pull request rspec/rspec-core#2732 from rspec/fix-return-status-for-bisect Fix bug with bisect and custom error codes --- This commit was imported from https://github.com/rspec/rspec-core/commit/fa04fdb5f087b78666e7dda7873246335f41d3d2. --- rspec-core/lib/rspec/core/invocations.rb | 2 +- rspec-core/spec/rspec/core/invocations_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rspec-core/lib/rspec/core/invocations.rb b/rspec-core/lib/rspec/core/invocations.rb index 24e8234e3..7e5049f68 100644 --- a/rspec-core/lib/rspec/core/invocations.rb +++ b/rspec-core/lib/rspec/core/invocations.rb @@ -37,7 +37,7 @@ def call(options, err, out) runner, options.args, formatter ) - success ? 0 : 1 + success ? 0 : runner.configuration.failure_exit_code end private diff --git a/rspec-core/spec/rspec/core/invocations_spec.rb b/rspec-core/spec/rspec/core/invocations_spec.rb index 6edbe4a5f..a925fb0b6 100644 --- a/rspec-core/spec/rspec/core/invocations_spec.rb +++ b/rspec-core/spec/rspec/core/invocations_spec.rb @@ -111,6 +111,16 @@ def run_invocation expect(exit_code).to eq(1) end + + context "with a custom failure code set" do + it "returns the custom failure code" do + in_sub_process do + RSpec.configuration.failure_exit_code = 42 + exit_code = run_invocation + expect(exit_code).to eq(42) + end + end + end end context "and the verbose option is specified" do