From: Luke Diamand <luke@diamand.org>
To: git@vger.kernel.org
Cc: Pete Wyckoff <pw@padd.com>, Luke Diamand <luke@diamand.org>
Subject: [PATCHv1] git-p4: test harness directory handling tidyup
Date: Thu, 12 May 2011 06:14:59 +0100 [thread overview]
Message-ID: <1305177299-27130-2-git-send-email-luke@diamand.org> (raw)
In-Reply-To: <1305177299-27130-1-git-send-email-luke@diamand.org>
The git-p4 test harness relied a lot on cd'ing to the target directory
and then cd'ing back explicitly. That caused problems if the test failed
partway through. i.e.
cd $git && stuff && cd "$TRASH_DIRECTORY"
Instead, use:
(cd $git && stuff)
Signed-off-by: Luke Diamand <luke@diamand.org>
Suggested-by: Junio C Hamano <gitster@pobox.com>
---
t/t9800-git-p4.sh | 37 ++++++++++++++++++++++---------------
1 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
index 888ad54..122e91d 100755
--- a/t/t9800-git-p4.sh
+++ b/t/t9800-git-p4.sh
@@ -28,6 +28,8 @@ test_expect_success setup '
'
test_expect_success 'add p4 files' '
+ export P4CLIENT=client &&
+ (
cd "$cli" &&
p4 client -i <<-EOF &&
Client: client
@@ -35,14 +37,13 @@ test_expect_success 'add p4 files' '
Root: $cli
View: //depot/... //client/...
EOF
- export P4CLIENT=client &&
echo file1 >file1 &&
p4 add file1 &&
p4 submit -d "file1" &&
echo file2 >file2 &&
p4 add file2 &&
- p4 submit -d "file2" &&
- cd "$TRASH_DIRECTORY"
+ p4 submit -d "file2"
+ )
'
test_expect_success 'basic git-p4 clone' '
@@ -100,34 +101,37 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '
'
test_expect_success 'add p4 files with wildcards in the names' '
+ (
cd "$cli" &&
echo file-wild-hash >file-wild#hash &&
echo file-wild-star >file-wild\*star &&
echo file-wild-at >file-wild@at &&
echo file-wild-percent >file-wild%percent &&
p4 add -f file-wild* &&
- p4 submit -d "file wildcards" &&
- cd "$TRASH_DIRECTORY"
+ p4 submit -d "file wildcards"
+ )
'
test_expect_success 'wildcard files git-p4 clone' '
"$GITP4" clone --dest="$git" //depot &&
+ (
cd "$git" &&
test -f file-wild#hash &&
test -f file-wild\*star &&
test -f file-wild@at &&
- test -f file-wild%percent &&
- cd "$TRASH_DIRECTORY" &&
+ test -f file-wild%percent
+ )
rm -rf "$git" && mkdir "$git"
'
test_expect_success 'clone bare' '
"$GITP4" clone --dest="$git" --bare //depot &&
+ (
cd "$git" &&
test ! -d .git &&
bare=`git config --get core.bare` &&
- test "$bare" = true &&
- cd "$TRASH_DIRECTORY" &&
+ test "$bare" = true
+ )
rm -rf "$git" && mkdir "$git"
'
@@ -175,6 +179,7 @@ test_expect_success 'preserve users' '
p4_add_user bob Bob &&
p4_grant_admin alice &&
"$GITP4" clone --dest="$git" //depot &&
+ (
cd "$git" &&
echo "username: a change by alice" >> file1 &&
echo "username: a change by bob" >> file2 &&
@@ -183,8 +188,8 @@ test_expect_success 'preserve users' '
git config git-p4.skipSubmitEditCheck true &&
P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
p4_check_commit_author file1 alice &&
- p4_check_commit_author file2 bob &&
- cd "$TRASH_DIRECTORY" &&
+ p4_check_commit_author file2 bob
+ )
rm -rf "$git" && mkdir "$git"
'
@@ -192,18 +197,20 @@ test_expect_success 'preserve users' '
# not submit change to p4 (git diff should show deltas).
test_expect_success 'refuse to preserve users without perms' '
"$GITP4" clone --dest="$git" //depot &&
+ (
cd "$git" &&
echo "username-noperms: a change by alice" >> file1 &&
git commit --author "Alice <alice@localhost>" -m "perms: a change by alice" file1 &&
! P4EDITOR=touch P4USER=bob P4PASSWD=secret "$GITP4" commit --preserve-user &&
- ! git diff --exit-code HEAD..p4/master > /dev/null &&
- cd "$TRASH_DIRECTORY" &&
+ ! git diff --exit-code HEAD..p4/master > /dev/null
+ )
rm -rf "$git" && mkdir "$git"
'
# What happens with unknown author? Without allowMissingP4Users it should fail.
test_expect_success 'preserve user where author is unknown to p4' '
"$GITP4" clone --dest="$git" //depot &&
+ (
cd "$git" &&
git config git-p4.skipSubmitEditCheck true
echo "username-bob: a change by bob" >> file1 &&
@@ -217,8 +224,8 @@ test_expect_success 'preserve user where author is unknown to p4' '
git config git-p4.preserveUser true &&
P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit &&
git diff --exit-code HEAD..p4/master > /dev/null &&
- p4_check_commit_author file1 alice &&
- cd "$TRASH_DIRECTORY" &&
+ p4_check_commit_author file1 alice
+ )
rm -rf "$git" && mkdir "$git"
'
--
1.7.1
next prev parent reply other threads:[~2011-05-12 5:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-12 5:14 [PATCHv1] git-p4: test harness directory handling tidyup Luke Diamand
2011-05-12 5:14 ` Luke Diamand [this message]
2011-05-12 11:29 ` Pete Wyckoff
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=1305177299-27130-2-git-send-email-luke@diamand.org \
--to=luke@diamand.org \
--cc=git@vger.kernel.org \
--cc=pw@padd.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).