From b3f7c9f60f5d011df2ce86235c6c829a13244e51 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 7 Nov 2024 11:16:47 -0800 Subject: [PATCH] Change command output instead --- Library/Homebrew/cmd/outdated.rb | 4 +++- Library/Homebrew/test/cmd/outdated_spec.rb | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index 9427fc0c5f424..aac8556f77e3a 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -65,7 +65,9 @@ def run formulae: json_info(formulae), casks: json_info(casks), } - puts JSON.pretty_generate(json) + # json v2.8.1 is inconsistent it how it renders empty arrays, + # so we use `[]` for consistency: + puts JSON.pretty_generate(json).gsub("[\n\n]", "[]") outdated = formulae + casks else diff --git a/Library/Homebrew/test/cmd/outdated_spec.rb b/Library/Homebrew/test/cmd/outdated_spec.rb index 94749286423c0..c2af5d43b9aa2 100644 --- a/Library/Homebrew/test/cmd/outdated_spec.rb +++ b/Library/Homebrew/test/cmd/outdated_spec.rb @@ -20,12 +20,9 @@ }], casks: [], }) - # json v2.8.1 is inconsistent it how it renders empty arrays, - # for now we allow multiple outputs: - alternate_json = expected_json.gsub("[]", "[\n\n]") expect { brew "outdated", "--json=v2" } - .to output(match(/\A(#{Regexp.escape(expected_json)}|#{Regexp.escape(alternate_json)})\n\z/)).to_stdout + .to output("#{expected_json}\n").to_stdout .and be_a_success end end