cmd/upgrade: fix output regex in test

The "upgrades with asking for user prompts with dependants checks"
test for `cmd/upgrade` has been failing on CI. The regex in the test
doesn't match expected output because the negative lookaheads aren't
working as expected. The intention is to make sure that the names
aren't repeated (i.e., second shouldn't match first, third shouldn't
match first or second) but the negative lookaheads should be
_inside_ the second/third capture group for this to work as intended.

This updated regex should work as expected. I manually tested it
using the output from CI to make sure that it matches when no formula
names are repeated (e.g., `Formulae (3): testball, testball4,
testball5`) and does not match if formula names are repeated (e.g.,
`Formulae (3): testball5, testball4, testball5`).
This commit is contained in:
Sam Ford 2025-04-09 12:44:31 -04:00
parent 35897fe49c
commit 7b2d84337e
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -54,19 +54,11 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
regex = /
Formulae\s*\(3\):\s*
(
testball|testball5|testball4
)
(testball|testball5|testball4)
\s*,\s*
(?!\1)
(
testball|testball5|testball4
)
((?!\1)testball|testball5|testball4)
\s*,\s*
(?!\1|\2)
(
testball|testball5|testball4
)
((?!\1|\2)testball|testball5|testball4)
/x
expect do
brew "upgrade", "--ask"