From: Jacob Keller <jacob.keller@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git mailing list <git@vger.kernel.org>,
Christian Couder <christian.couder@gmail.com>,
Jeff King <peff@peff.net>,
Jacob Keller <jacob.e.keller@intel.com>
Subject: Re: [PATCH v2 7/7] t4045: test 'diff --relative' for real
Date: Thu, 7 Dec 2017 11:06:29 -0800 [thread overview]
Message-ID: <CA+P7+xoYEQ8sD+hSk+N95xAaRkMo15+kDRNB5rH5dgbGCfPieQ@mail.gmail.com> (raw)
In-Reply-To: <20171207173034.12865-4-gitster@pobox.com>
On Thu, Dec 7, 2017 at 9:30 AM, Junio C Hamano <gitster@pobox.com> wrote:
> The existing tests only checked how well -relative=<dir> work,
> without testing --relative (without any value).
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> t/t4045-diff-relative.sh | 24 ++++++++++++++++++++----
> 1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh
> index fefd2f3f81..815cdd7295 100755
> --- a/t/t4045-diff-relative.sh
> +++ b/t/t4045-diff-relative.sh
> @@ -25,7 +25,10 @@ check_diff () {
> +other content
> EOF
> test_expect_success "-p $*" "
> - git diff -p $* HEAD^ >actual &&
> + (
> + test -z "$in_there" || cd "$in_there"
> + git diff -p $* HEAD^
> + ) >actual &&
> test_cmp expected actual
> "
> }
> @@ -38,7 +41,10 @@ check_numstat () {
> EOF
> test_expect_success "--numstat $*" "
> echo '1 0 $expect' >expected &&
> - git diff --numstat $* HEAD^ >actual &&
> + (
> + test -z "$in_there" || cd "$in_there"
> + git diff --numstat $* HEAD^
> + ) >actual &&
> test_cmp expected actual
> "
> }
> @@ -51,7 +57,10 @@ check_stat () {
> 1 file changed, 1 insertion(+)
> EOF
> test_expect_success "--stat $*" "
> - git diff --stat $* HEAD^ >actual &&
> + (
> + test -z "$in_there" || cd "$in_there"
> + git diff --stat $* HEAD^
> + ) >actual &&
> test_i18ncmp expected actual
> "
> }
> @@ -63,15 +72,22 @@ check_raw () {
> :000000 100644 0000000000000000000000000000000000000000 25c05ef3639d2d270e7fe765a67668f098092bc5 A $expect
> EOF
> test_expect_success "--raw $*" "
> - git diff --no-abbrev --raw $* HEAD^ >actual &&
> + (
> + test -z "$in_there" || cd "$in_there"
> + git diff --no-abbrev --raw $* HEAD^ >actual
> + ) &&
You could avoid the subshell by just passing $in_there to -C on the
git commands. Same for the other tests. If you quote it, -C
'$in_there', then it will work regardless of if in_there is set or
not, (-C with an empty string doesn't cd anywhere). I think this is
generally preferable for tests given it helps avoid unnecessary
subshells when testing on Windows..?
> test_cmp expected actual
> "
> }
>
> for type in diff numstat stat raw
> do
> + in_there=
> check_$type file2 --relative=subdir/
> check_$type file2 --relative=subdir
> + in_there=subdir
> + check_$type file2 --relative
> + in_there=
> check_$type dir/file2 --relative=sub
> done
>
This isn't quite what I had in mind for the directory parameter. I
passed it as an extra argument, but I think this is probably more
sensible.
> --
> 2.15.1-480-gbc5668f98a
>
prev parent reply other threads:[~2017-12-07 19:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 0:35 [PATCH] diff: add test showing regression to --relative Jacob Keller
2017-12-07 1:04 ` Jeff King
2017-12-07 1:21 ` Jacob Keller
2017-12-07 17:30 ` [PATCH v2 0/7] reroll of cc/skip-to-optional-val Junio C Hamano
2017-12-07 17:30 ` [PATCH v2 5/7] diff: use skip-to-optional-val in parsing --relative Junio C Hamano
2017-12-07 19:03 ` Jacob Keller
2017-12-07 21:11 ` Jeff King
2017-12-07 21:59 ` Junio C Hamano
2017-12-07 22:21 ` Jeff King
2017-12-07 22:31 ` Junio C Hamano
2017-12-08 9:05 ` Jeff King
2017-12-08 21:09 ` Junio C Hamano
2017-12-07 17:30 ` [PATCH v2 6/7] t4045: reindent to make helpers readable Junio C Hamano
2017-12-07 17:30 ` [PATCH v2 7/7] t4045: test 'diff --relative' for real Junio C Hamano
2017-12-07 19:06 ` Jacob Keller [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+P7+xoYEQ8sD+hSk+N95xAaRkMo15+kDRNB5rH5dgbGCfPieQ@mail.gmail.com \
--to=jacob.keller@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.e.keller@intel.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).