Re: [PATCH] t4069: test diff behavior with i-t-a paths
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Aug 10, 2020, 21:47 UTC
- Message-ID
- <CAPig+cQCMG3Dx99LWTOAe8wZ2ocdikQAzdDS=-APfYE9HVn+=A@mail.gmail.com>
- In-Reply-To
- <CAPig+cSn_wrBuMKzoUZ720Hy-Y9RuPpJtmZ1mr--cnyAP866-Q@mail.gmail.com>
On Mon, Aug 10, 2020 at 12:23 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 15 quoted lines
> To tighten this test, perhaps it makes sense to take a different > approach and check the exact output rather than merely grepping for a > particular string. In other words, something like this might be better > (typed in email, so untested): > > cat >expect <<-\EOF && > diff --git a/test-file b/test-file > index HEX..HEX HEX > --- a/test-file > +++ b/test-file > EOF > cat blueprint >test-file && > git diff --ita-visible-in-index -- test-file >raw && > sed "s/[0-9a-f][0-9a-f]*/HEX/g' raw >actual && > test_cmp expect actual
This can be improved by taking advantage of the OID_REGEX variable defined by the test suite for matching an OID. So something like this would be even better:
cat >expect <<-\EOF &&
diff --git a/test-file b/test-file
index OID..OID 100644
--- a/test-file
+++ b/test-file
EOF
cat blueprint >test-file &&
git diff --ita-visible-in-index -- test-file >raw &&
sed "s/$OID_REGEX/OID/g" raw >actual &&
test_cmp expect actual