Skip to content

Commit

Permalink
Write tests for 'brew list --version [--cask]'.
Browse files Browse the repository at this point in the history
HELP WANTED! How can I create test packages in the 'Caskroom'?

I can only run 'brew tests' on Linux, because my Mac Mini (macOS 14.7.2)
fails due to missing "mutex.h" (or some such).

At least the new test for 'brew list --version' succeeds (on Linux).

Squashed commits to (partial) success:
Try 'brew style list_spec.rb'.
Try 'rubocop -a'.
Generic OS fails.
Generic OS fails again.
The 'Caskroom' is not yet populated.
  • Loading branch information
ascherer committed Dec 24, 2024
1 parent 882bb52 commit c1546e0
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Library/Homebrew/test/cmd/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,44 @@
require "cmd/shared_examples/args_parse"

RSpec.describe Homebrew::Cmd::List do
let(:formulae) { %w[bar foo qux] }
let(:formulae) { %w[bar qux foo] }
let(:casks) { %w[tex git sgb] }

it_behaves_like "parseable arguments"

it "prints all installed Formulae", :integration_test do
formulae.each do |f|
(HOMEBREW_CELLAR/f/"1.0/somedir").mkpath
end
# casks.each do |f|
# (HOMEBREW_CELLAR/"../Caskroom"/f/"42.0/somedir").mkpath
# end

expect { brew "list", "--formula" }
.to output("#{formulae.join("\n")}\n").to_stdout
.to output("#{formulae.sort.join("\n")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

# expect { brew "list", "--cask" }
# .to output("#{casks.sort.join("\n")}\n").to_stdout
# .and not_to_output.to_stderr
# .and be_a_success

expect { brew "list", "--formula", "--version" }
.to output("#{formulae.sort.map { |name| "#{name} 1.0" }.join("\n")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

# expect { brew "list", "--cask", "--version" }
# .to output("#{casks.sort.map { |name| "#{name} 42.0" }.join("\n")}\n").to_stdout
# .and not_to_output.to_stderr
# .and be_a_success

# expect { brew "list", "--version" }
# .to output("#{formulae.sort.map { |name| "#{name} 1.0" }.join("\n")}\n" +
# "#{casks.sort.map { |name| "#{name} 42.0" }.join("\n")}\n").to_stdout
# .and not_to_output.to_stderr
# .and be_a_success
end

# TODO: add a test for the shell fast-path (`brew_sh`)
Expand Down

0 comments on commit c1546e0

Please sign in to comment.