{"thread":{"id":"27332","subject":"[PATCHv1] git-p4: test harness directory handling tidyup","startedAt":"2011-05-12T05:14:58Z","lastAt":"2011-05-12T11:29:37Z","messageCount":3,"participants":["Luke Diamand","Pete Wyckoff"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"167705","messageId":"1305177299-27130-1-git-send-email-luke@diamand.org","threadId":"27332","inReplyTo":null,"subject":"[PATCHv1] git-p4: test harness directory handling tidyup","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2011-05-12T05:14:58Z","receivedAt":"2011-05-12T05:14:58Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Junio pointed out that the git-p4 test harness (t9800-git-p4.sh) has\ntests that 'cd' into a directory, do stuff, and then cd back out. If\nthe tests fail partway through then the process is left in the wrong\ndirectory for the next test.\n\nThis patch changes it to use the \"(cd dir && do_test)\" pattern instead.\n\nLuke Diamand (1):\n  git-p4: test harness directory changing tidyup\n\n t/t9800-git-p4.sh |   37 ++++++++++++++++++++++---------------\n 1 files changed, 22 insertions(+), 15 deletions(-)\n"},{"id":"167704","messageId":"1305177299-27130-2-git-send-email-luke@diamand.org","threadId":"27332","inReplyTo":"1305177299-27130-1-git-send-email-luke@diamand.org","subject":"[PATCHv1] git-p4: test harness directory handling tidyup","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2011-05-12T05:14:59Z","receivedAt":"2011-05-12T05:14:59Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"The git-p4 test harness relied a lot on cd'ing to the target directory\nand then cd'ing back explicitly. That caused problems if the test failed\npartway through. i.e.\n  cd $git && stuff && cd \"$TRASH_DIRECTORY\"\n\nInstead, use:\n  (cd $git && stuff)\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\nSuggested-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t9800-git-p4.sh |   37 ++++++++++++++++++++++---------------\n 1 files changed, 22 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 888ad54..122e91d 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -28,6 +28,8 @@ test_expect_success setup '\n '\n \n test_expect_success 'add p4 files' '\n+\texport P4CLIENT=client &&\n+\t(\n \tcd \"$cli\" &&\n \tp4 client -i <<-EOF &&\n \tClient: client\n@@ -35,14 +37,13 @@ test_expect_success 'add p4 files' '\n \tRoot: $cli\n \tView: //depot/... //client/...\n \tEOF\n-\texport P4CLIENT=client &&\n \techo file1 >file1 &&\n \tp4 add file1 &&\n \tp4 submit -d \"file1\" &&\n \techo file2 >file2 &&\n \tp4 add file2 &&\n-\tp4 submit -d \"file2\" &&\n-\tcd \"$TRASH_DIRECTORY\"\n+\tp4 submit -d \"file2\"\n+\t)\n '\n \n test_expect_success 'basic git-p4 clone' '\n@@ -100,34 +101,37 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '\n '\n \n test_expect_success 'add p4 files with wildcards in the names' '\n+\t(\n \tcd \"$cli\" &&\n \techo file-wild-hash >file-wild#hash &&\n \techo file-wild-star >file-wild\\*star &&\n \techo file-wild-at >file-wild@at &&\n \techo file-wild-percent >file-wild%percent &&\n \tp4 add -f file-wild* &&\n-\tp4 submit -d \"file wildcards\" &&\n-\tcd \"$TRASH_DIRECTORY\"\n+\tp4 submit -d \"file wildcards\"\n+\t)\n '\n \n test_expect_success 'wildcard files git-p4 clone' '\n \t\"$GITP4\" clone --dest=\"$git\" //depot &&\n+\t(\n \tcd \"$git\" &&\n \ttest -f file-wild#hash &&\n \ttest -f file-wild\\*star &&\n \ttest -f file-wild@at &&\n-\ttest -f file-wild%percent &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n+\ttest -f file-wild%percent\n+\t)\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n test_expect_success 'clone bare' '\n \t\"$GITP4\" clone --dest=\"$git\" --bare //depot &&\n+\t(\n \tcd \"$git\" &&\n \ttest ! -d .git &&\n \tbare=`git config --get core.bare` &&\n-\ttest \"$bare\" = true &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n+\ttest \"$bare\" = true\n+\t)\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n@@ -175,6 +179,7 @@ test_expect_success 'preserve users' '\n \tp4_add_user bob Bob &&\n \tp4_grant_admin alice &&\n \t\"$GITP4\" clone --dest=\"$git\" //depot &&\n+\t(\n \tcd \"$git\" &&\n \techo \"username: a change by alice\" >> file1 &&\n \techo \"username: a change by bob\" >> file2 &&\n@@ -183,8 +188,8 @@ test_expect_success 'preserve users' '\n \tgit config git-p4.skipSubmitEditCheck true &&\n \tP4EDITOR=touch P4USER=alice P4PASSWD=secret \"$GITP4\" commit --preserve-user &&\n \tp4_check_commit_author file1 alice &&\n-\tp4_check_commit_author file2 bob &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n+\tp4_check_commit_author file2 bob\n+\t)\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n@@ -192,18 +197,20 @@ test_expect_success 'preserve users' '\n # not submit change to p4 (git diff should show deltas).\n test_expect_success 'refuse to preserve users without perms' '\n \t\"$GITP4\" clone --dest=\"$git\" //depot &&\n+\t(\n \tcd \"$git\" &&\n \techo \"username-noperms: a change by alice\" >> file1 &&\n \tgit commit --author \"Alice <alice@localhost>\" -m \"perms: a change by alice\" file1 &&\n \t! P4EDITOR=touch P4USER=bob P4PASSWD=secret \"$GITP4\" commit --preserve-user &&\n-\t! git diff --exit-code HEAD..p4/master > /dev/null &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n+\t! git diff --exit-code HEAD..p4/master > /dev/null\n+\t)\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n # What happens with unknown author? Without allowMissingP4Users it should fail.\n test_expect_success 'preserve user where author is unknown to p4' '\n \t\"$GITP4\" clone --dest=\"$git\" //depot &&\n+\t(\n \tcd \"$git\" &&\n \tgit config git-p4.skipSubmitEditCheck true\n \techo \"username-bob: a change by bob\" >> file1 &&\n@@ -217,8 +224,8 @@ test_expect_success 'preserve user where author is unknown to p4' '\n \tgit config git-p4.preserveUser true &&\n \tP4EDITOR=touch P4USER=alice P4PASSWD=secret \"$GITP4\" commit &&\n \tgit diff --exit-code HEAD..p4/master > /dev/null &&\n-\tp4_check_commit_author file1 alice &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n+\tp4_check_commit_author file1 alice\n+\t)\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n-- \n1.7.1\n"},{"id":"167724","messageId":"20110512112937.GA3128@arf.padd.com","threadId":"27332","inReplyTo":"1305177299-27130-2-git-send-email-luke@diamand.org","subject":"Re: [PATCHv1] git-p4: test harness directory handling tidyup","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-05-12T11:29:37Z","receivedAt":"2011-05-12T11:29:37Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"luke@diamand.org wrote on Thu, 12 May 2011 06:14 +0100:\n> The git-p4 test harness relied a lot on cd'ing to the target directory\n> and then cd'ing back explicitly. That caused problems if the test failed\n> partway through. i.e.\n>   cd $git && stuff && cd \"$TRASH_DIRECTORY\"\n> \n> Instead, use:\n>   (cd $git && stuff)\n> \n> Signed-off-by: Luke Diamand <luke@diamand.org>\n> Suggested-by: Junio C Hamano <gitster@pobox.com>\n\nI'm glad that Junio noticed and that you took the time to fix\nthis.  It was indeed a problem.\n\nAcked-by: Pete Wyckoff <pw@padd.com>\n"}]}