From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Subject: [PATCH 1/3] t1506: factor out test for "Did you mean..."
Date: Thu, 31 Mar 2011 11:17:33 +0200 [thread overview]
Message-ID: <2590090d32e748932d988dff3897058b909e8358.1301562935.git.git@drmicha.warpmail.net> (raw)
In-Reply-To: <4D94322A.8030409@drmicha.warpmail.net>
With the current code, it's a "'"'"'" jungle, and we test only 1 line of
the 2 line response. Factor out and test both.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
t/t1506-rev-parse-diagnosis.sh | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 9f8adb1..f9cb202 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -6,6 +6,13 @@ exec </dev/null
. ./test-lib.sh
+test_did_you_mean ()
+{
+ printf "fatal: Path '$2$3' $4, but not ${5:-'$3'}.\n" >expected &&
+ printf "Did you mean '$1:$2$3'?\n" >>expected &&
+ test_cmp expected error
+}
+
HASH_file=
test_expect_success 'set up basic repo' '
@@ -106,7 +113,7 @@ test_expect_success 'incorrect file in sha1:path' '
grep "fatal: Path '"'"'index-only.txt'"'"' exists on disk, but not in '"'"'HEAD'"'"'." error &&
(cd subdir &&
test_must_fail git rev-parse HEAD:file2.txt 2> error &&
- grep "Did you mean '"'"'HEAD:subdir/file2.txt'"'"'?" error )
+ test_did_you_mean HEAD subdir/ file2.txt exists )
'
test_expect_success 'incorrect file in :path and :N:path' '
@@ -115,14 +122,14 @@ test_expect_success 'incorrect file in :path and :N:path' '
test_must_fail git rev-parse :1:nothing.txt 2> error &&
grep "Path '"'"'nothing.txt'"'"' does not exist (neither on disk nor in the index)." error &&
test_must_fail git rev-parse :1:file.txt 2> error &&
- grep "Did you mean '"'"':0:file.txt'"'"'?" error &&
+ test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&
(cd subdir &&
test_must_fail git rev-parse :1:file.txt 2> error &&
- grep "Did you mean '"'"':0:file.txt'"'"'?" error &&
+ test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&
test_must_fail git rev-parse :file2.txt 2> error &&
- grep "Did you mean '"'"':0:subdir/file2.txt'"'"'?" error &&
+ test_did_you_mean ":0" subdir/ file2.txt "is in the index" &&
test_must_fail git rev-parse :2:file2.txt 2> error &&
- grep "Did you mean '"'"':0:subdir/file2.txt'"'"'?" error) &&
+ test_did_you_mean :0 subdir/ file2.txt "is in the index") &&
test_must_fail git rev-parse :disk-only.txt 2> error &&
grep "fatal: Path '"'"'disk-only.txt'"'"' exists on disk, but not in the index." error
'
--
1.7.4.2.668.gba03a4
next prev parent reply other threads:[~2011-03-31 9:21 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 6:45 Usability improvement request: git show revision -- file Piotr Krukowiecki
2011-03-31 7:50 ` Michael J Gruber
2011-03-31 9:17 ` Michael J Gruber [this message]
2011-03-31 9:17 ` [PATCH 2/3] sha1_name: Suggest commit:./file for path in subdir Michael J Gruber
2011-03-31 19:26 ` Junio C Hamano
2011-04-01 6:52 ` Michael J Gruber
2011-04-01 19:11 ` Junio C Hamano
2011-03-31 9:17 ` [RFC/PATCH 3/3] builtin/show.c: do not prune by pathspec Michael J Gruber
2011-03-31 10:18 ` Johannes Sixt
2011-03-31 10:58 ` Michael J Gruber
2011-03-31 11:42 ` Johannes Sixt
2011-03-31 12:07 ` Michael J Gruber
2011-03-31 12:50 ` Nguyen Thai Ngoc Duy
2011-03-31 13:26 ` Michael J Gruber
2011-03-31 13:35 ` Nguyen Thai Ngoc Duy
2011-03-31 13:55 ` Michael J Gruber
2011-03-31 19:23 ` Junio C Hamano
2011-04-01 6:46 ` Michael J Gruber
2011-04-01 9:20 ` [PATCH 0/4] reflog, show and command line overrides Michael J Gruber
2011-04-01 9:20 ` [PATCH 1/4] builtin/log.c: separate default and setup of cmd_log_init() Michael J Gruber
2011-04-01 9:20 ` [PATCH 2/4] t/t1411: test reflog with formats Michael J Gruber
2011-04-01 9:20 ` [PATCH 3/4] reflog: fix overriding of command line options Michael J Gruber
2011-04-01 9:20 ` [PATCH 4/4] builtin/show: do not prune by pathspec Michael J Gruber
2011-04-01 21:50 ` Junio C Hamano
2011-04-01 22:59 ` Junio C Hamano
2011-04-03 13:16 ` Michael J Gruber
2011-04-04 21:49 ` Junio C Hamano
2011-04-05 6:06 ` Michael J Gruber
2011-03-31 19:59 ` Usability improvement request: git show revision -- file Piotr Krukowiecki
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=2590090d32e748932d988dff3897058b909e8358.1301562935.git.git@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=piotr.krukowiecki@gmail.com \
/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).