Skip to content

Commit

Permalink
dev-cmd/livecheck: guard watchlist test
Browse files Browse the repository at this point in the history
The existing watchlist test in `dev-cmd/livecheck_spec.rb` will only
pass if the testing environment doesn't contain a livecheck watchlist
file. When a watchlist file is present, it ends up being treated as
empty (formulae and casks aren't available in tests) and produces an
`Invalid usage: No formulae or casks to check` error instead. We don't
have to worry about a watchlist file on CI but it's a potential issue
when running `brew test` locally.

This adds an `if` condition to the test, to ensure that it only runs
when a livecheck watchlist file doesn't exist.
  • Loading branch information
samford committed Aug 16, 2023
1 parent e475de2 commit f64ecf8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Library/Homebrew/test/dev-cmd/livecheck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@
.and be_a_success
end

it "gives an error when no arguments are given and there's no watchlist", :integration_test do
# When a watchlist file is present, livecheck parses the formula/cask names
# in the file and ignores any that aren't available. Since formulae and casks
# aren't available in the testing environment, the watchlist file will be
# treated as empty and this produces an `Invalid usage: No formulae or casks
# to check.` error instead. As such, this test will only pass when a
# watchlist file isn't present in the testing environment.
#
# Also note, any older `~/.brew_livecheck_watchlist` file won't be accessible
# from this test (as the home folder is `HOMEBREW_PREFIX/test/`), so we don't
# have to guard against its existence.
it "gives an error when no arguments are given and there's no watchlist",
:integration_test,
if: !File.exist?(Homebrew::EnvConfig.livecheck_watchlist) do
expect { brew "livecheck" }
.to output(/Invalid usage: A watchlist file is required when no arguments are given\./).to_stderr
.and not_to_output.to_stdout
Expand Down

0 comments on commit f64ecf8

Please sign in to comment.