DEV: Fix command error message formatting (#31491)

a follow up to 51b0903f514c3c22569401e74ebd1215c317d787
This commit is contained in:
Jarek Radosz
2025-02-25 02:28:01 +01:00
committed by GitHub
parent 51b0903f51
commit d4e5d63d7e
2 changed files with 3 additions and 3 deletions

View File

@ -169,7 +169,7 @@ module Discourse
stdout, stderr, status = Open3.capture3(*args, chdir: chdir)
if !status.exited? || !success_status_codes.include?(status.exitstatus)
message = [command, failure_message, stderr].filter(&:present?).join("\n")
message = [command.join(" "), failure_message, stderr].filter(&:present?).join("\n")
raise CommandError.new(message, stdout: stdout, stderr: stderr, status: status)
end

View File

@ -553,8 +553,8 @@ RSpec.describe Discourse do
it "includes the command in the error message" do
expect do
Discourse::Utils.execute_command("false", failure_message: "oops")
end.to raise_error(RuntimeError, "false\noops")
Discourse::Utils.execute_command("false", "'foo'", failure_message: "oops")
end.to raise_error(RuntimeError, "false 'foo'\noops")
end
end