From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, Git List <git@vger.kernel.org>
Subject: [PATCH 15/15] t3040 (subprojects-basic): modernize style
Date: Thu, 8 Dec 2011 01:06:51 +0530 [thread overview]
Message-ID: <1323286611-4806-16-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1323286611-4806-1-git-send-email-artagnon@gmail.com>
Put the opening quote starting each test on the same line as the
test_expect_* invocation. While at it:
- Indent the file with tabs, not spaces.
- Guard commands that prepare test input for individual tests in the
same test_expect_success, so that their scope is clearer and errors
at that stage can be caught.
- Use <<\-EOF in preference to <<EOF to save readers the trouble of
looking for variable interpolations.
- Include "setup" in the titles of test assertions that prepare for
later ones to make it more obvious which tests can be skipped.
- Chain commands with &&. Breaks in a test assertion's && chain can
potentially hide failures from earlier commands in the chain.
- Use test_expect_code() in preference to checking the exit status of
various statements by hand.
Inspired-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
t/t3040-subprojects-basic.sh | 144 +++++++++++++++++++++---------------------
1 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh
index f6973e9..0a4ff6d 100755
--- a/t/t3040-subprojects-basic.sh
+++ b/t/t3040-subprojects-basic.sh
@@ -3,81 +3,81 @@
test_description='Basic subproject functionality'
. ./test-lib.sh
-test_expect_success 'Super project creation' \
- ': >Makefile &&
- git add Makefile &&
- git commit -m "Superproject created"'
-
-
-cat >expected <<EOF
-:000000 160000 00000... A sub1
-:000000 160000 00000... A sub2
-EOF
-test_expect_success 'create subprojects' \
- 'mkdir sub1 &&
- ( cd sub1 && git init && : >Makefile && git add * &&
- git commit -q -m "subproject 1" ) &&
- mkdir sub2 &&
- ( cd sub2 && git init && : >Makefile && git add * &&
- git commit -q -m "subproject 2" ) &&
- git update-index --add sub1 &&
- git add sub2 &&
- git commit -q -m "subprojects added" &&
- git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
- test_cmp expected current'
-
-git branch save HEAD
-
-test_expect_success 'check if fsck ignores the subprojects' \
- 'git fsck --full'
-
-test_expect_success 'check if commit in a subproject detected' \
- '( cd sub1 &&
- echo "all:" >>Makefile &&
- echo " true" >>Makefile &&
- git commit -q -a -m "make all" ) && {
- git diff-files --exit-code
- test $? = 1
- }'
-
-test_expect_success 'check if a changed subproject HEAD can be committed' \
- 'git commit -q -a -m "sub1 changed" && {
- git diff-tree --exit-code HEAD^ HEAD
- test $? = 1
- }'
-
-test_expect_success 'check if diff-index works for subproject elements' \
- 'git diff-index --exit-code --cached save -- sub1
- test $? = 1'
-
-test_expect_success 'check if diff-tree works for subproject elements' \
- 'git diff-tree --exit-code HEAD^ HEAD -- sub1
- test $? = 1'
-
-test_expect_success 'check if git diff works for subproject elements' \
- 'git diff --exit-code HEAD^ HEAD
- test $? = 1'
-
-test_expect_success 'check if clone works' \
- 'git ls-files -s >expected &&
- git clone -l -s . cloned &&
- ( cd cloned && git ls-files -s ) >current &&
- test_cmp expected current'
-
-test_expect_success 'removing and adding subproject' \
- 'git update-index --force-remove -- sub2 &&
- mv sub2 sub3 &&
- git add sub3 &&
- git commit -q -m "renaming a subproject" && {
- git diff -M --name-status --exit-code HEAD^ HEAD
- test $? = 1
- }'
+test_expect_success 'setup: create superproject' '
+ : >Makefile &&
+ git add Makefile &&
+ git commit -m "Superproject created"
+'
+
+test_expect_success 'setup: create subprojects' '
+ mkdir sub1 &&
+ ( cd sub1 && git init && : >Makefile && git add * &&
+ git commit -q -m "subproject 1" ) &&
+ mkdir sub2 &&
+ ( cd sub2 && git init && : >Makefile && git add * &&
+ git commit -q -m "subproject 2" ) &&
+ git update-index --add sub1 &&
+ git add sub2 &&
+ git commit -q -m "subprojects added" &&
+ git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
+ git branch save HEAD &&
+ cat >expected <<-\EOF &&
+ :000000 160000 00000... A sub1
+ :000000 160000 00000... A sub2
+ EOF
+ test_cmp expected current
+'
+
+test_expect_success 'check if fsck ignores the subprojects' '
+ git fsck --full
+'
+
+test_expect_success 'check if commit in a subproject detected' '
+ ( cd sub1 &&
+ echo "all:" >>Makefile &&
+ echo " true" >>Makefile &&
+ git commit -q -a -m "make all" ) &&
+ test_expect_code 1 git diff-files --exit-code
+'
+
+test_expect_success 'check if a changed subproject HEAD can be committed' '
+ git commit -q -a -m "sub1 changed" &&
+ test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD
+'
+
+test_expect_success 'check if diff-index works for subproject elements' '
+ test_expect_code 1 git diff-index --exit-code --cached save -- sub1
+'
+
+test_expect_success 'check if diff-tree works for subproject elements' '
+ test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD -- sub1
+'
+
+test_expect_success 'check if git diff works for subproject elements' '
+ test_expect_code 1 git diff --exit-code HEAD^ HEAD
+'
+
+test_expect_success 'check if clone works' '
+ git ls-files -s >expected &&
+ git clone -l -s . cloned &&
+ ( cd cloned && git ls-files -s ) >current &&
+ test_cmp expected current
+'
+
+test_expect_success 'removing and adding subproject' '
+ git update-index --force-remove -- sub2 &&
+ mv sub2 sub3 &&
+ git add sub3 &&
+ git commit -q -m "renaming a subproject" &&
+ test_expect_code 1 git diff -M --name-status --exit-code HEAD^ HEAD
+'
# the index must contain the object name the HEAD of the
# subproject sub1 was at the point "save"
-test_expect_success 'checkout in superproject' \
- 'git checkout save &&
- git diff-index --exit-code --raw --cached save -- sub1'
+test_expect_success 'checkout in superproject' '
+ git checkout save &&
+ git diff-index --exit-code --raw --cached save -- sub1
+'
# just interesting what happened...
# git diff --name-status -M save master
--
1.7.7.3
next prev parent reply other threads:[~2011-12-07 19:38 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 5:01 What's cooking in git.git (Dec 2011, #02; Mon, 5) Junio C Hamano
2011-12-06 5:35 ` Ramkumar Ramachandra
2011-12-06 18:20 ` Junio C Hamano
2011-12-06 20:30 ` Ramkumar Ramachandra
2011-12-07 10:08 ` &&-chaining tester Jonathan Nieder
2011-12-07 19:36 ` Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 01/15] t1013 (loose-object-format): fix && chaining Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 02/15] t1300 (repo-config): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 03/15] t1412 (reflog-loop): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 04/15] t1007 (hash-object): " Ramkumar Ramachandra
2011-12-07 21:47 ` Jonathan Nieder
2011-12-08 4:42 ` Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 05/15] t1510 (repo-setup): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 06/15] t1511 (rev-parse-caret): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 07/15] t1510 (worktree): " Ramkumar Ramachandra
2011-12-07 21:51 ` Jonathan Nieder
2011-12-08 4:39 ` Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 08/15] t3200 (branch): " Ramkumar Ramachandra
2011-12-07 21:55 ` Jonathan Nieder
2011-12-08 4:47 ` Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 09/15] t3418 (rebase-continue): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 10/15] t3400 (rebase): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 11/15] t3310 (notes-merge-manual-resolve): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 12/15] t3419 (rebase-patch-id): " Ramkumar Ramachandra
2011-12-07 19:36 ` [PATCH 13/15] t3030 (merge-recursive): use test_expect_code Ramkumar Ramachandra
2011-12-07 21:57 ` Jonathan Nieder
2011-12-07 19:36 ` [PATCH 14/15] t1006 (cat-file): use test_cmp Ramkumar Ramachandra
2011-12-07 22:01 ` Jonathan Nieder
2011-12-07 19:36 ` Ramkumar Ramachandra [this message]
2011-12-07 22:21 ` [PATCH 15/15] t3040 (subprojects-basic): modernize style Jonathan Nieder
2011-12-08 13:04 ` Ramkumar Ramachandra
2011-12-08 8:06 ` &&-chaining tester Matthieu Moy
2011-12-08 18:19 ` What's cooking in git.git (Dec 2011, #02; Mon, 5) Junio C Hamano
2011-12-06 5:52 ` Jeff King
2011-12-06 11:22 ` Erik Faye-Lund
2011-12-06 18:52 ` Jeff King
2011-12-08 19:44 ` Erik Faye-Lund
2011-12-08 21:25 ` Junio C Hamano
2011-12-06 18:35 ` Junio C Hamano
2011-12-06 18:47 ` Jeff King
2011-12-06 11:20 ` Nguyen Thai Ngoc Duy
2011-12-06 19:10 ` Junio C Hamano
2011-12-06 14:01 ` Nguyen Thai Ngoc Duy
2011-12-06 19:12 ` Junio C Hamano
2011-12-06 21:12 ` Luke Diamand
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=1323286611-4806-16-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@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.
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).