From: Jeff King <peff@peff.net>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Michael Rappazzo" <rappazzo@gmail.com>,
"Git List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [PATCH v2 1/2] test-lib: add a function to compare an expection with stdout from a command
Date: Sat, 16 Apr 2016 23:54:15 -0400 [thread overview]
Message-ID: <20160417035414.GA30002@sigill.intra.peff.net> (raw)
In-Reply-To: <CAPig+cSOuFygsScGn_Nu0_d8mvRik1hQJuanrb-Nvw3ozyt7JQ@mail.gmail.com>
On Sat, Apr 16, 2016 at 11:07:02PM -0400, Eric Sunshine wrote:
> > test_stdout accepts an expection and a command to execute. It will execute
> > the command and then compare the stdout from that command to an expectation.
> > If the expectation is not met, a mock diff output is written to stderr.
>
> I wonder if this deserves more flexibility by accepting a comparison
> operator, such as = and !=, similar to test_line_count()? Although, I
> suppose such functionality could be added later if deemed useful.
IMHO the funny syntax would outweigh the readability benefits. Unlike
test_line_count(), which is abstracting a portability solution, this is
mostly just about trying to save a few lines.
Though I do actually find that:
test_stdout false git rev-parse --whatever
isn't great, because there's no syntactic separator between the expected
output and the actual command to run. So I dunno, maybe it would be
better as:
test_stdout false = git rev-parse --whatever
and then you get "!=" for free later on if you want it.
We could also do:
test_stdout git rev-parse --whatever <<-\EOF
false
EOF
which is more robust for multi-line output, but I think part of the
point is to keep these as simple one-liners. You're not buying all that
much over:
cat >expect <<-\EOF &&
false
EOF
git rev-parse --whatever >actual &&
test_cmp expect actual
Though I do admit I've considered such a helper for some tests where
that pattern is repeated ad nauseam.
> > Based-on-a-patch-by: Jeff King <peff@peff.net>
>
> Since Peff wrote the actual code[1], it might be worthwhile to give
> him authorship by prepending the commit message with a "From: Jeff
> King <peff@peff.net>" header.
Michael contacted me offline asking how to credit, and I actually
suggested the "Based-on" route. I'm OK with it either way.
And for the record, my contribution is:
Signed-off-by: Jeff King <peff@peff.net>
in case there are any DCO questions.
-Peff
next prev parent reply other threads:[~2016-04-17 4:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-16 16:13 [PATCH v2 0/2] t1500-rev-parse: re-write t1500 Michael Rappazzo
2016-04-16 16:13 ` [PATCH v2 1/2] test-lib: add a function to compare an expection with stdout from a command Michael Rappazzo
2016-04-17 3:07 ` Eric Sunshine
2016-04-17 3:54 ` Jeff King [this message]
2016-04-17 6:36 ` Eric Sunshine
2016-04-17 6:41 ` Jeff King
2016-04-17 15:19 ` Johannes Sixt
2016-04-17 16:22 ` Eric Sunshine
2016-04-16 16:13 ` [PATCH v2 2/2] t1500-rev-parse: rewrite each test to run in isolation Michael Rappazzo
2016-04-17 5:59 ` Eric Sunshine
2016-04-17 15:05 ` Johannes Sixt
2016-04-17 9:42 ` SZEDER Gábor
2016-04-17 16:15 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160417035414.GA30002@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=rappazzo@gmail.com \
--cc=sunshine@sunshineco.com \
--cc=szeder@ira.uka.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).