{"thread":{"id":"30914","subject":"[PATCHv2 00/10] git p4 test fixes","startedAt":"2012-06-27T12:00:53Z","lastAt":"2012-06-28T04:05:52Z","messageCount":14,"participants":["Pete Wyckoff","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"194343","messageId":"1340798463-14499-1-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":null,"subject":"[PATCHv2 00/10] git p4 test fixes","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:53Z","receivedAt":"2012-06-27T12:00:53Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"Changes from v1 are:\n\n    * Extend p4d start time to 5 min, modifiable by an\n      environment variable.  Add a \"kill -0\" mechanism\n      to detect early if the p4d we started died.\n      (Thanks Junio)\n\n    * Rewrite the badp4dir PATH and return value handling\n      to make sure that earlier commands in the && chain\n      are checked properly.  (Thanks Hannes)\n\nThis is a series of accumulated minor annoyances in\nthe \"git p4\" tests.  I've been carrying these around for\na while, now.\n\nThe big line count change here is from splitting big chunks\nof t9800 out into logically separate tests.\n\nPete Wyckoff (10):\n  git p4 test: wait longer for p4d to start and test its pid\n  git p4 test: use real_path to resolve p4 client symlinks\n  git p4 test: simplify quoting involving TRASH_DIRECTORY\n  git p4 test: never create default test repo\n  git p4 test: rename some \"git-p4 command\" strings\n  git p4 test: check for error message in failed test\n  git p4 test: copy source indeterminate\n  git p4 test: cleanup_git should make a new $git\n  git p4 test: split up big t9800 test\n  git p4 test: fix badp4dir test\n\n t/lib-git-p4.sh                    |  26 ++-\n t/t9800-git-p4-basic.sh            | 416 ++-----------------------------------\n t/t9805-git-p4-skip-submit-edit.sh |   9 +-\n t/t9806-git-p4-options.sh          |  17 +-\n t/t9808-git-p4-chdir.sh            |   4 +-\n t/t9810-git-p4-rcs.sh              |   8 +-\n t/t9812-git-p4-wildcards.sh        | 147 +++++++++++++\n t/t9813-git-p4-preserve-users.sh   | 153 ++++++++++++++\n t/t9814-git-p4-rename.sh           | 206 ++++++++++++++++++\n 9 files changed, 557 insertions(+), 429 deletions(-)\n create mode 100755 t/t9812-git-p4-wildcards.sh\n create mode 100755 t/t9813-git-p4-preserve-users.sh\n create mode 100755 t/t9814-git-p4-rename.sh\n\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194344","messageId":"1340798463-14499-2-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 01/10] git p4 test: wait longer for p4d to start and test its pid","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:54Z","receivedAt":"2012-06-27T12:00:54Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"Running tests at high parallelism on a slow machine, 5 sec is\nnot enough to wait for p4d to start.  Change it to 5 minutes,\nadding an environment variable P4D_START_PATIENCE to shrink\nthat if needed in automated test environments.\n\nAlso check if the pid of the p4d that we started is still\naround.  If not, quit waiting for it immediately.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/lib-git-p4.sh | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 121e380..2e3706a 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -33,14 +33,27 @@ pidfile=\"$TRASH_DIRECTORY/p4d.pid\"\n \n start_p4d() {\n \tmkdir -p \"$db\" \"$cli\" \"$git\" &&\n+\trm -f \"$pidfile\" &&\n \t(\n \t\tp4d -q -r \"$db\" -p $P4DPORT &\n \t\techo $! >\"$pidfile\"\n \t) &&\n-\tfor i in 1 2 3 4 5 ; do\n+\t# This gives p4d a long time to start up, as it can be\n+\t# quite slow depending on the machine.  Set this environment\n+\t# variable to something smaller to fail faster in, say,\n+\t# an automated test setup.\n+\ti=${P4D_START_PATIENCE:-300} &&\n+\twhile [ $i -gt 0 ]; do\n+\t\t# succeed when p4 client commands start to work\n \t\tp4 info >/dev/null 2>&1 && break || true &&\n+\t\t# fail if pid goes away\n+\t\tif [ -f \"$pidfile\" ] ; then\n+\t\t    kill -0 $(cat \"$pidfile\") || break\n+\t\tfi &&\n+\t\t# else keep waiting\n \t\techo waiting for p4d to start &&\n-\t\tsleep 1\n+\t\tsleep 1 &&\n+\t\ti=$(($i - 1))\n \tdone &&\n \t# complain if it never started\n \tp4 info >/dev/null &&\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194345","messageId":"1340798463-14499-3-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 02/10] git p4 test: use real_path to resolve p4 client symlinks","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:55Z","receivedAt":"2012-06-27T12:00:55Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"The p4 program is finicky about making sure the recorded client Root\nmatches the current working directory.  The way it discovers the latter\nseems to be to inspect shell variable $PWD.  This could involve symlinks,\nthat while leading to the same place as the client Root, look different,\nand cause p4 to fail.\n\nResolve all client paths using \"test-path-utils real_path $path\".  This\nremoves \"..\" and resolves all symlinks.\n\nDiscovered while running with --root=/dev/shm, which is a link to\n/run/shm.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/lib-git-p4.sh           | 2 +-\n t/t9806-git-p4-options.sh | 2 +-\n t/t9810-git-p4-rcs.sh     | 2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 2e3706a..0b09735 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -27,7 +27,7 @@ export P4CLIENT=client\n export P4EDITOR=:\n \n db=\"$TRASH_DIRECTORY/db\"\n-cli=\"$TRASH_DIRECTORY/cli\"\n+cli=$(test-path-utils real_path \"$TRASH_DIRECTORY/cli\")\n git=\"$TRASH_DIRECTORY/git\"\n pidfile=\"$TRASH_DIRECTORY/p4d.pid\"\n \ndiff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh\nindex 2892367..83738fa 100755\n--- a/t/t9806-git-p4-options.sh\n+++ b/t/t9806-git-p4-options.sh\n@@ -128,7 +128,7 @@ test_expect_success 'clone --use-client-spec' '\n \t\texec >/dev/null &&\n \t\ttest_must_fail git p4 clone --dest=\"$git\" --use-client-spec\n \t) &&\n-\tcli2=\"$TRASH_DIRECTORY/cli2\" &&\n+\tcli2=$(test-path-utils real_path \"$TRASH_DIRECTORY/cli2\") &&\n \tmkdir -p \"$cli2\" &&\n \ttest_when_finished \"rmdir \\\"$cli2\\\"\" &&\n \t(\ndiff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh\nindex d8d9ca4..c7313b0 100755\n--- a/t/t9810-git-p4-rcs.sh\n+++ b/t/t9810-git-p4-rcs.sh\n@@ -244,7 +244,7 @@ test_expect_success 'cope with rcs keyword expansion damage' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\t(cd ../cli && p4_append_to_file kwfile1.c) &&\n+\t\t(cd \"$cli\" && p4_append_to_file kwfile1.c) &&\n \t\told_lines=$(wc -l <kwfile1.c) &&\n \t\tperl -n -i -e \"print unless m/Revision:/\" kwfile1.c &&\n \t\tnew_lines=$(wc -l <kwfile1.c) &&\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194346","messageId":"1340798463-14499-4-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 03/10] git p4 test: simplify quoting involving TRASH_DIRECTORY","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:56Z","receivedAt":"2012-06-27T12:00:56Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"For temporary files that are created in the top-level TRASH_DIRECTORY,\ntrust that the tests do not chdir except in subshells, and avoid some\nquoting.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4-basic.sh            | 11 +++++------\n t/t9805-git-p4-skip-submit-edit.sh |  9 ++++-----\n t/t9806-git-p4-options.sh          | 14 ++++++--------\n t/t9808-git-p4-chdir.sh            |  4 ++--\n 4 files changed, 17 insertions(+), 21 deletions(-)\n\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex 0f410c4..7401c21 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -126,15 +126,14 @@ test_expect_success 'clone two dirs, @all, conflicting files' '\n '\n \n test_expect_success 'exit when p4 fails to produce marshaled output' '\n-\tbadp4dir=\"$TRASH_DIRECTORY/badp4dir\" &&\n-\tmkdir \"$badp4dir\" &&\n-\ttest_when_finished \"rm \\\"$badp4dir/p4\\\" && rmdir \\\"$badp4dir\\\"\" &&\n-\tcat >\"$badp4dir\"/p4 <<-EOF &&\n+\tmkdir badp4dir &&\n+\ttest_when_finished \"rm badp4dir/p4 && rmdir badp4dir\" &&\n+\tcat >badp4dir/p4 <<-EOF &&\n \t#!$SHELL_PATH\n \texit 1\n \tEOF\n-\tchmod 755 \"$badp4dir\"/p4 &&\n-\tPATH=\"$badp4dir:$PATH\" git p4 clone --dest=\"$git\" //depot >errs 2>&1 ; retval=$? &&\n+\tchmod 755 badp4dir/p4 &&\n+\tPATH=\"$TRASH_DIRECTORY/badp4dir:$PATH\" git p4 clone --dest=\"$git\" //depot >errs 2>&1 ; retval=$? &&\n \ttest $retval -eq 1 &&\n \ttest_must_fail grep -q Traceback errs\n '\ndiff --git a/t/t9805-git-p4-skip-submit-edit.sh b/t/t9805-git-p4-skip-submit-edit.sh\nindex 353dcfb..fb3c8ec 100755\n--- a/t/t9805-git-p4-skip-submit-edit.sh\n+++ b/t/t9805-git-p4-skip-submit-edit.sh\n@@ -78,20 +78,19 @@ test_expect_success 'skipSubmitEditCheck' '\n test_expect_success 'no config, edited' '\n \tgit p4 clone --dest=\"$git\" //depot &&\n \ttest_when_finished cleanup_git &&\n-\ted=\"$TRASH_DIRECTORY/ed.sh\" &&\n-\ttest_when_finished \"rm \\\"$ed\\\"\" &&\n-\tcat >\"$ed\" <<-EOF &&\n+\ttest_when_finished \"rm ed.sh\" &&\n+\tcat >ed.sh <<-EOF &&\n \t\t#!$SHELL_PATH\n \t\tsleep 1\n \t\ttouch \"\\$1\"\n \t\texit 0\n \tEOF\n-\tchmod 755 \"$ed\" &&\n+\tchmod 755 ed.sh &&\n \t(\n \t\tcd \"$git\" &&\n \t\techo line >>file1 &&\n \t\tgit commit -a -m \"change 5\" &&\n-\t\tP4EDITOR=\"\" EDITOR=\"\\\"$ed\\\"\" git p4 submit &&\n+\t\tP4EDITOR=\"\" EDITOR=\"\\\"$TRASH_DIRECTORY/ed.sh\\\"\" git p4 submit &&\n \t\tp4 changes //depot/... >wc &&\n \t\ttest_line_count = 5 wc\n \t)\ndiff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh\nindex 83738fa..a37c6cb 100755\n--- a/t/t9806-git-p4-options.sh\n+++ b/t/t9806-git-p4-options.sh\n@@ -39,10 +39,9 @@ test_expect_success 'clone --branch' '\n '\n \n test_expect_success 'clone --changesfile' '\n-\tcf=\"$TRASH_DIRECTORY/cf\" &&\n-\ttest_when_finished \"rm \\\"$cf\\\"\" &&\n-\tprintf \"1\\n3\\n\" >\"$cf\" &&\n-\tgit p4 clone --changesfile=\"$cf\" --dest=\"$git\" //depot &&\n+\ttest_when_finished \"rm cf\" &&\n+\tprintf \"1\\n3\\n\" >cf &&\n+\tgit p4 clone --changesfile=\"$TRASH_DIRECTORY/cf\" --dest=\"$git\" //depot &&\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tcd \"$git\" &&\n@@ -55,10 +54,9 @@ test_expect_success 'clone --changesfile' '\n '\n \n test_expect_success 'clone --changesfile, @all' '\n-\tcf=\"$TRASH_DIRECTORY/cf\" &&\n-\ttest_when_finished \"rm \\\"$cf\\\"\" &&\n-\tprintf \"1\\n3\\n\" >\"$cf\" &&\n-\ttest_must_fail git p4 clone --changesfile=\"$cf\" --dest=\"$git\" //depot@all\n+\ttest_when_finished \"rm cf\" &&\n+\tprintf \"1\\n3\\n\" >cf &&\n+\ttest_must_fail git p4 clone --changesfile=\"$TRASH_DIRECTORY/cf\" --dest=\"$git\" //depot@all\n '\n \n # imports both master and p4/master in refs/heads\ndiff --git a/t/t9808-git-p4-chdir.sh b/t/t9808-git-p4-chdir.sh\nindex 2f8014a..dc92e60 100755\n--- a/t/t9808-git-p4-chdir.sh\n+++ b/t/t9808-git-p4-chdir.sh\n@@ -21,7 +21,7 @@ test_expect_success 'init depot' '\n # environment variable is set\n test_expect_success 'P4CONFIG and absolute dir clone' '\n \tprintf \"P4PORT=$P4PORT\\nP4CLIENT=$P4CLIENT\\n\" >p4config &&\n-\ttest_when_finished \"rm \\\"$TRASH_DIRECTORY/p4config\\\"\" &&\n+\ttest_when_finished \"rm p4config\" &&\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tP4CONFIG=p4config && export P4CONFIG &&\n@@ -33,7 +33,7 @@ test_expect_success 'P4CONFIG and absolute dir clone' '\n # same thing, but with relative directory name, note missing $ on --dest\n test_expect_success 'P4CONFIG and relative dir clone' '\n \tprintf \"P4PORT=$P4PORT\\nP4CLIENT=$P4CLIENT\\n\" >p4config &&\n-\ttest_when_finished \"rm \\\"$TRASH_DIRECTORY/p4config\\\"\" &&\n+\ttest_when_finished \"rm p4config\" &&\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tP4CONFIG=p4config && export P4CONFIG &&\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194347","messageId":"1340798463-14499-5-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 04/10] git p4 test: never create default test repo","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:57Z","receivedAt":"2012-06-27T12:00:57Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/lib-git-p4.sh | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 0b09735..4c5b1f6 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -2,6 +2,10 @@\n # Library code for git p4 tests\n #\n \n+# p4 tests never use the top-level repo; always build/clone into\n+# a subdirectory called \"$git\"\n+TEST_NO_CREATE_REPO=NoThanks\n+\n . ./test-lib.sh\n \n if ! test_have_prereq PYTHON; then\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194348","messageId":"1340798463-14499-6-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 05/10] git p4 test: rename some \"git-p4 command\" strings","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:58Z","receivedAt":"2012-06-27T12:00:58Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"Use the actual command name; git-p4 is gone.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9810-git-p4-rcs.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh\nindex c7313b0..d8bb3d0 100755\n--- a/t/t9810-git-p4-rcs.sh\n+++ b/t/t9810-git-p4-rcs.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-test_description='git-p4 rcs keywords'\n+test_description='git p4 rcs keywords'\n \n . ./lib-git-p4.sh\n \n@@ -147,7 +147,7 @@ test_expect_success 'scrub ko files differently' '\n \t)\n '\n \n-# hack; git-p4 submit should do it on its own\n+# hack; git p4 submit should do it on its own\n test_expect_success 'cleanup after failure' '\n \t(\n \t\tcd \"$cli\" &&\n@@ -193,7 +193,7 @@ test_expect_success 'do not scrub plain text' '\n \t)\n '\n \n-# hack; git-p4 submit should do it on its own\n+# hack; git p4 submit should do it on its own\n test_expect_success 'cleanup after failure 2' '\n \t(\n \t\tcd \"$cli\" &&\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194349","messageId":"1340798463-14499-7-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 06/10] git p4 test: check for error message in failed test","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:00:59Z","receivedAt":"2012-06-27T12:00:59Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"Make sure the test fails for the expected reason.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4-basic.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex 7401c21..84676a1 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -45,7 +45,8 @@ test_expect_success 'git p4 sync uninitialized repo' '\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tcd \"$git\" &&\n-\t\ttest_must_fail git p4 sync\n+\t\ttest_must_fail git p4 sync 2>errs &&\n+\t\ttest_i18ngrep \"Perhaps you never did\" errs\n \t)\n '\n \n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194350","messageId":"1340798463-14499-8-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 07/10] git p4 test: copy source indeterminate","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:01:00Z","receivedAt":"2012-06-27T12:01:00Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"Msysgit testing showed that the source file found by copy\ndetection is indeterminate when there are multiple sources\nto choose from.  This appears to be valid.  Adjust the test\nso that it passes if it finds any of the potential copy sources.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4-basic.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex 84676a1..60c1f57 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -547,7 +547,7 @@ test_expect_success 'detect copies' '\n \t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n \t\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n \t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n-\t\ttest \"$src\" = file10 &&\n+\t\ttest \"$src\" = file10 -o \"$src\" = file11 &&\n \t\tgit config git-p4.detectCopies $(($level + 2)) &&\n \t\tgit p4 submit &&\n \t\tp4 filelog //depot/file12 &&\n@@ -561,7 +561,7 @@ test_expect_success 'detect copies' '\n \t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n \t\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n \t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n-\t\ttest \"$src\" = file10 &&\n+\t\ttest \"$src\" = file10 -o \"$src\" = file11 -o \"$src\" = file12 &&\n \t\tgit config git-p4.detectCopies $(($level - 2)) &&\n \t\tgit p4 submit &&\n \t\tp4 filelog //depot/file13 &&\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194351","messageId":"1340798463-14499-9-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 08/10] git p4 test: cleanup_git should make a new $git","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:01:01Z","receivedAt":"2012-06-27T12:01:01Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"For convenience, leave one in place at the end of each\ntest so that it is not necessary to build a new one.  This\nmakes it consistent with $cli.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/lib-git-p4.sh           | 3 ++-\n t/t9800-git-p4-basic.sh   | 1 +\n t/t9806-git-p4-options.sh | 1 -\n 3 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 4c5b1f6..0bc3566 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -86,5 +86,6 @@ kill_p4d() {\n }\n \n cleanup_git() {\n-\trm -rf \"$git\"\n+\trm -rf \"$git\" &&\n+\tmkdir \"$git\"\n }\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex 60c1f57..234f727 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -270,6 +270,7 @@ test_expect_success 'wildcard files submit back to p4, delete' '\n '\n \n test_expect_success 'clone bare' '\n+\trm -rf \"$git\" &&\n \tgit p4 clone --dest=\"$git\" --bare //depot &&\n \ttest_when_finished cleanup_git &&\n \t(\ndiff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh\nindex a37c6cb..fa40cc8 100755\n--- a/t/t9806-git-p4-options.sh\n+++ b/t/t9806-git-p4-options.sh\n@@ -149,7 +149,6 @@ test_expect_success 'clone --use-client-spec' '\n \tcleanup_git &&\n \n \t# same thing again, this time with variable instead of option\n-\tmkdir \"$git\" &&\n \t(\n \t\tcd \"$git\" &&\n \t\tgit init &&\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194352","messageId":"1340798463-14499-10-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 09/10] git p4 test: split up big t9800 test","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:01:02Z","receivedAt":"2012-06-27T12:01:02Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"The original t9800 test code has a mix of assorted topics, some\nof which are big enough to deserve their own homes.\nInterdependencies between the topics make it confusing when\ntrying to study one in isolation.  And it takes so long to run\nthat debugging an individual test is difficult.\n\nSplit out three big chunks of tests into their own files:\n\n    t9812-git-p4-wildcards.sh gets the 8 p4 wildcard tests\n\n    t9813-git-p4-preserve-users.sh gets the 4 --preserve-user tests\n\n    t9814-git-p4-rename.sh gets the 2 copy and rename tests\n\nTest 9800 execution time drops from 29 sec to 9 sec.  The\nsequential time to run all tests is a slower due to the three\nextra p4d startup/shutdown sequences, but the overall parallel\nexecution time is about the same, at 52 sec.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4-basic.sh          | 397 ---------------------------------------\n t/t9812-git-p4-wildcards.sh      | 147 +++++++++++++++\n t/t9813-git-p4-preserve-users.sh | 153 +++++++++++++++\n t/t9814-git-p4-rename.sh         | 206 ++++++++++++++++++++\n 4 files changed, 506 insertions(+), 397 deletions(-)\n create mode 100755 t/t9812-git-p4-wildcards.sh\n create mode 100755 t/t9813-git-p4-preserve-users.sh\n create mode 100755 t/t9814-git-p4-rename.sh\n\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex 234f727..befd823 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -139,136 +139,6 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '\n \ttest_must_fail grep -q Traceback errs\n '\n \n-test_expect_success 'add p4 files with wildcards in the names' '\n-\t(\n-\t\tcd \"$cli\" &&\n-\t\techo file-wild-hash >file-wild#hash &&\n-\t\techo file-wild-star >file-wild\\*star &&\n-\t\techo file-wild-at >file-wild@at &&\n-\t\techo file-wild-percent >file-wild%percent &&\n-\t\tp4 add -f file-wild* &&\n-\t\tp4 submit -d \"file wildcards\"\n-\t)\n-'\n-\n-test_expect_success 'wildcard files git p4 clone' '\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\ttest -f file-wild#hash &&\n-\t\ttest -f file-wild\\*star &&\n-\t\ttest -f file-wild@at &&\n-\t\ttest -f file-wild%percent\n-\t)\n-'\n-\n-test_expect_success 'wildcard files submit back to p4, add' '\n-\ttest_when_finished cleanup_git &&\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\techo git-wild-hash >git-wild#hash &&\n-\t\techo git-wild-star >git-wild\\*star &&\n-\t\techo git-wild-at >git-wild@at &&\n-\t\techo git-wild-percent >git-wild%percent &&\n-\t\tgit add git-wild* &&\n-\t\tgit commit -m \"add some wildcard filenames\" &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tgit p4 submit\n-\t) &&\n-\t(\n-\t\tcd \"$cli\" &&\n-\t\ttest_path_is_file git-wild#hash &&\n-\t\ttest_path_is_file git-wild\\*star &&\n-\t\ttest_path_is_file git-wild@at &&\n-\t\ttest_path_is_file git-wild%percent\n-\t)\n-'\n-\n-test_expect_success 'wildcard files submit back to p4, modify' '\n-\ttest_when_finished cleanup_git &&\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\techo new-line >>git-wild#hash &&\n-\t\techo new-line >>git-wild\\*star &&\n-\t\techo new-line >>git-wild@at &&\n-\t\techo new-line >>git-wild%percent &&\n-\t\tgit add git-wild* &&\n-\t\tgit commit -m \"modify the wildcard files\" &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tgit p4 submit\n-\t) &&\n-\t(\n-\t\tcd \"$cli\" &&\n-\t\ttest_line_count = 2 git-wild#hash &&\n-\t\ttest_line_count = 2 git-wild\\*star &&\n-\t\ttest_line_count = 2 git-wild@at &&\n-\t\ttest_line_count = 2 git-wild%percent\n-\t)\n-'\n-\n-test_expect_success 'wildcard files submit back to p4, copy' '\n-\ttest_when_finished cleanup_git &&\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tcp file2 git-wild-cp#hash &&\n-\t\tgit add git-wild-cp#hash &&\n-\t\tcp git-wild\\*star file-wild-3 &&\n-\t\tgit add file-wild-3 &&\n-\t\tgit commit -m \"wildcard copies\" &&\n-\t\tgit config git-p4.detectCopies true &&\n-\t\tgit config git-p4.detectCopiesHarder true &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tgit p4 submit\n-\t) &&\n-\t(\n-\t\tcd \"$cli\" &&\n-\t\ttest_path_is_file git-wild-cp#hash &&\n-\t\ttest_path_is_file file-wild-3\n-\t)\n-'\n-\n-test_expect_success 'wildcard files submit back to p4, rename' '\n-\ttest_when_finished cleanup_git &&\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit mv git-wild@at file-wild-4 &&\n-\t\tgit mv file-wild-3 git-wild-cp%percent &&\n-\t\tgit commit -m \"wildcard renames\" &&\n-\t\tgit config git-p4.detectRenames true &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tgit p4 submit\n-\t) &&\n-\t(\n-\t\tcd \"$cli\" &&\n-\t\ttest_path_is_missing git-wild@at &&\n-\t\ttest_path_is_file git-wild-cp%percent\n-\t)\n-'\n-\n-test_expect_success 'wildcard files submit back to p4, delete' '\n-\ttest_when_finished cleanup_git &&\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit rm git-wild* &&\n-\t\tgit commit -m \"delete the wildcard files\" &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tgit p4 submit\n-\t) &&\n-\t(\n-\t\tcd \"$cli\" &&\n-\t\ttest_path_is_missing git-wild#hash &&\n-\t\ttest_path_is_missing git-wild\\*star &&\n-\t\ttest_path_is_missing git-wild@at &&\n-\t\ttest_path_is_missing git-wild%percent\n-\t)\n-'\n-\n test_expect_success 'clone bare' '\n \trm -rf \"$git\" &&\n \tgit p4 clone --dest=\"$git\" --bare //depot &&\n@@ -281,133 +151,6 @@ test_expect_success 'clone bare' '\n \t)\n '\n \n-p4_add_user() {\n-\tname=$1 fullname=$2 &&\n-\tp4 user -f -i <<-EOF &&\n-\tUser: $name\n-\tEmail: $name@localhost\n-\tFullName: $fullname\n-\tEOF\n-\tp4 passwd -P secret $name\n-}\n-\n-p4_grant_admin() {\n-\tname=$1 &&\n-\t{\n-\t\tp4 protect -o &&\n-\t\techo \"    admin user $name * //depot/...\"\n-\t} | p4 protect -i\n-}\n-\n-p4_check_commit_author() {\n-\tfile=$1 user=$2 &&\n-\tp4 changes -m 1 //depot/$file | grep -q $user\n-}\n-\n-make_change_by_user() {\n-\tfile=$1 name=$2 email=$3 &&\n-\techo \"username: a change by $name\" >>\"$file\" &&\n-\tgit add \"$file\" &&\n-\tgit commit --author \"$name <$email>\" -m \"a change by $name\"\n-}\n-\n-# Test username support, submitting as user 'alice'\n-test_expect_success 'preserve users' '\n-\tp4_add_user alice Alice &&\n-\tp4_add_user bob Bob &&\n-\tp4_grant_admin alice &&\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\techo \"username: a change by alice\" >>file1 &&\n-\t\techo \"username: a change by bob\" >>file2 &&\n-\t\tgit commit --author \"Alice <alice@localhost>\" -m \"a change by alice\" file1 &&\n-\t\tgit commit --author \"Bob <bob@localhost>\" -m \"a change by bob\" file2 &&\n-\t\tgit config git-p4.skipSubmitEditCheck true &&\n-\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret git p4 commit --preserve-user &&\n-\t\tp4_check_commit_author file1 alice &&\n-\t\tp4_check_commit_author file2 bob\n-\t)\n-'\n-\n-# Test username support, submitting as bob, who lacks admin rights. Should\n-# not submit change to p4 (git diff should show deltas).\n-test_expect_success 'refuse to preserve users without perms' '\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit config git-p4.skipSubmitEditCheck true &&\n-\t\techo \"username-noperms: a change by alice\" >>file1 &&\n-\t\tgit commit --author \"Alice <alice@localhost>\" -m \"perms: a change by alice\" file1 &&\n-\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret &&\n-\t\texport P4EDITOR P4USER P4PASSWD &&\n-\t\ttest_must_fail git p4 commit --preserve-user &&\n-\t\t! git diff --exit-code HEAD..p4/master\n-\t)\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-\tgit p4 clone --dest=\"$git\" //depot &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit config git-p4.skipSubmitEditCheck true &&\n-\t\techo \"username-bob: a change by bob\" >>file1 &&\n-\t\tgit commit --author \"Bob <bob@localhost>\" -m \"preserve: a change by bob\" file1 &&\n-\t\techo \"username-unknown: a change by charlie\" >>file1 &&\n-\t\tgit commit --author \"Charlie <charlie@localhost>\" -m \"preserve: a change by charlie\" file1 &&\n-\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret &&\n-\t\texport P4EDITOR P4USER P4PASSWD &&\n-\t\ttest_must_fail git p4 commit --preserve-user &&\n-\t\t! git diff --exit-code HEAD..p4/master &&\n-\n-\t\techo \"$0: repeat with allowMissingP4Users enabled\" &&\n-\t\tgit config git-p4.allowMissingP4Users true &&\n-\t\tgit config git-p4.preserveUser true &&\n-\t\tgit p4 commit &&\n-\t\tgit diff --exit-code HEAD..p4/master &&\n-\t\tp4_check_commit_author file1 alice\n-\t)\n-'\n-\n-# If we're *not* using --preserve-user, git p4 should warn if we're submitting\n-# changes that are not all ours.\n-# Test: user in p4 and user unknown to p4.\n-# Test: warning disabled and user is the same.\n-test_expect_success 'not preserving user with mixed authorship' '\n-\tgit p4 clone --dest=\"$git\" //depot &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit config git-p4.skipSubmitEditCheck true &&\n-\t\tp4_add_user derek Derek &&\n-\n-\t\tmake_change_by_user usernamefile3 Derek derek@localhost &&\n-\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret &&\n-\t\texport P4EDITOR P4USER P4PASSWD &&\n-\t\tgit p4 commit |\\\n-\t\tgrep \"git author derek@localhost does not match\" &&\n-\n-\t\tmake_change_by_user usernamefile3 Charlie charlie@localhost &&\n-\t\tgit p4 commit |\\\n-\t\tgrep \"git author charlie@localhost does not match\" &&\n-\n-\t\tmake_change_by_user usernamefile3 alice alice@localhost &&\n-\t\tgit p4 commit |\\\n-\t\ttest_must_fail grep \"git author.*does not match\" &&\n-\n-\t\tgit config git-p4.skipUserNameCheck true &&\n-\t\tmake_change_by_user usernamefile3 Charlie charlie@localhost &&\n-\t\tgit p4 commit |\\\n-\t\ttest_must_fail grep \"git author.*does not match\" &&\n-\n-\t\tp4_check_commit_author usernamefile3 alice\n-\t)\n-'\n-\n marshal_dump() {\n \twhat=$1\n \t\"$PYTHON_PATH\" -c 'import marshal, sys; d = marshal.load(sys.stdin); print d[\"'$what'\"]'\n@@ -430,146 +173,6 @@ test_expect_success 'initial import time from top change time' '\n \t)\n '\n \n-# Rename a file and confirm that rename is not detected in P4.\n-# Rename the new file again with detectRenames option enabled and confirm that\n-# this is detected in P4.\n-# Rename the new file again adding an extra line, configure a big threshold in\n-# detectRenames and confirm that rename is not detected in P4.\n-# Repeat, this time with a smaller threshold and confirm that the rename is\n-# detected in P4.\n-test_expect_success 'detect renames' '\n-\tgit p4 clone --dest=\"$git\" //depot@all &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\n-\t\tgit mv file1 file4 &&\n-\t\tgit commit -a -m \"Rename file1 to file4\" &&\n-\t\tgit diff-tree -r -M HEAD &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file4 &&\n-\t\tp4 filelog //depot/file4 | test_must_fail grep -q \"branch from\" &&\n-\n-\t\tgit mv file4 file5 &&\n-\t\tgit commit -a -m \"Rename file4 to file5\" &&\n-\t\tgit diff-tree -r -M HEAD &&\n-\t\tgit config git-p4.detectRenames true &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file5 &&\n-\t\tp4 filelog //depot/file5 | grep -q \"branch from //depot/file4\" &&\n-\n-\t\tgit mv file5 file6 &&\n-\t\techo update >>file6 &&\n-\t\tgit add file6 &&\n-\t\tgit commit -a -m \"Rename file5 to file6 with changes\" &&\n-\t\tgit diff-tree -r -M HEAD &&\n-\t\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/R0*//\") &&\n-\t\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n-\t\tgit config git-p4.detectRenames $(($level + 2)) &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file6 &&\n-\t\tp4 filelog //depot/file6 | test_must_fail grep -q \"branch from\" &&\n-\n-\t\tgit mv file6 file7 &&\n-\t\techo update >>file7 &&\n-\t\tgit add file7 &&\n-\t\tgit commit -a -m \"Rename file6 to file7 with changes\" &&\n-\t\tgit diff-tree -r -M HEAD &&\n-\t\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/R0*//\") &&\n-\t\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n-\t\tgit config git-p4.detectRenames $(($level - 2)) &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file7 &&\n-\t\tp4 filelog //depot/file7 | grep -q \"branch from //depot/file6\"\n-\t)\n-'\n-\n-# Copy a file and confirm that copy is not detected in P4.\n-# Copy a file with detectCopies option enabled and confirm that copy is not\n-# detected in P4.\n-# Modify and copy a file with detectCopies option enabled and confirm that copy\n-# is detected in P4.\n-# Copy a file with detectCopies and detectCopiesHarder options enabled and\n-# confirm that copy is detected in P4.\n-# Modify and copy a file, configure a bigger threshold in detectCopies and\n-# confirm that copy is not detected in P4.\n-# Modify and copy a file, configure a smaller threshold in detectCopies and\n-# confirm that copy is detected in P4.\n-test_expect_success 'detect copies' '\n-\tgit p4 clone --dest=\"$git\" //depot@all &&\n-\ttest_when_finished cleanup_git &&\n-\t(\n-\t\tcd \"$git\" &&\n-\t\tgit config git-p4.skipSubmitEdit true &&\n-\n-\t\tcp file2 file8 &&\n-\t\tgit add file8 &&\n-\t\tgit commit -a -m \"Copy file2 to file8\" &&\n-\t\tgit diff-tree -r -C HEAD &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file8 &&\n-\t\tp4 filelog //depot/file8 | test_must_fail grep -q \"branch from\" &&\n-\n-\t\tcp file2 file9 &&\n-\t\tgit add file9 &&\n-\t\tgit commit -a -m \"Copy file2 to file9\" &&\n-\t\tgit diff-tree -r -C HEAD &&\n-\t\tgit config git-p4.detectCopies true &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file9 &&\n-\t\tp4 filelog //depot/file9 | test_must_fail grep -q \"branch from\" &&\n-\n-\t\techo \"file2\" >>file2 &&\n-\t\tcp file2 file10 &&\n-\t\tgit add file2 file10 &&\n-\t\tgit commit -a -m \"Modify and copy file2 to file10\" &&\n-\t\tgit diff-tree -r -C HEAD &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file10 &&\n-\t\tp4 filelog //depot/file10 | grep -q \"branch from //depot/file\" &&\n-\n-\t\tcp file2 file11 &&\n-\t\tgit add file11 &&\n-\t\tgit commit -a -m \"Copy file2 to file11\" &&\n-\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n-\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n-\t\ttest \"$src\" = file10 &&\n-\t\tgit config git-p4.detectCopiesHarder true &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file11 &&\n-\t\tp4 filelog //depot/file11 | grep -q \"branch from //depot/file\" &&\n-\n-\t\tcp file2 file12 &&\n-\t\techo \"some text\" >>file12 &&\n-\t\tgit add file12 &&\n-\t\tgit commit -a -m \"Copy file2 to file12 with changes\" &&\n-\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n-\t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n-\t\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n-\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n-\t\ttest \"$src\" = file10 -o \"$src\" = file11 &&\n-\t\tgit config git-p4.detectCopies $(($level + 2)) &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file12 &&\n-\t\tp4 filelog //depot/file12 | test_must_fail grep -q \"branch from\" &&\n-\n-\t\tcp file2 file13 &&\n-\t\techo \"different text\" >>file13 &&\n-\t\tgit add file13 &&\n-\t\tgit commit -a -m \"Copy file2 to file13 with changes\" &&\n-\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n-\t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n-\t\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n-\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n-\t\ttest \"$src\" = file10 -o \"$src\" = file11 -o \"$src\" = file12 &&\n-\t\tgit config git-p4.detectCopies $(($level - 2)) &&\n-\t\tgit p4 submit &&\n-\t\tp4 filelog //depot/file13 &&\n-\t\tp4 filelog //depot/file13 | grep -q \"branch from //depot/file\"\n-\t)\n-'\n-\n test_expect_success 'kill p4d' '\n \tkill_p4d\n '\ndiff --git a/t/t9812-git-p4-wildcards.sh b/t/t9812-git-p4-wildcards.sh\nnew file mode 100755\nindex 0000000..143d413\n--- /dev/null\n+++ b/t/t9812-git-p4-wildcards.sh\n@@ -0,0 +1,147 @@\n+#!/bin/sh\n+\n+test_description='git p4 wildcards'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tstart_p4d\n+'\n+\n+test_expect_success 'add p4 files with wildcards in the names' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tprintf \"file2\\nhas\\nsome\\nrandom\\ntext\\n\" >file2 &&\n+\t\tp4 add file2 &&\n+\t\techo file-wild-hash >file-wild#hash &&\n+\t\techo file-wild-star >file-wild\\*star &&\n+\t\techo file-wild-at >file-wild@at &&\n+\t\techo file-wild-percent >file-wild%percent &&\n+\t\tp4 add -f file-wild* &&\n+\t\tp4 submit -d \"file wildcards\"\n+\t)\n+'\n+\n+test_expect_success 'wildcard files git p4 clone' '\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\ttest -f file-wild#hash &&\n+\t\ttest -f file-wild\\*star &&\n+\t\ttest -f file-wild@at &&\n+\t\ttest -f file-wild%percent\n+\t)\n+'\n+\n+test_expect_success 'wildcard files submit back to p4, add' '\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\techo git-wild-hash >git-wild#hash &&\n+\t\techo git-wild-star >git-wild\\*star &&\n+\t\techo git-wild-at >git-wild@at &&\n+\t\techo git-wild-percent >git-wild%percent &&\n+\t\tgit add git-wild* &&\n+\t\tgit commit -m \"add some wildcard filenames\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tgit p4 submit\n+\t) &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\ttest_path_is_file git-wild#hash &&\n+\t\ttest_path_is_file git-wild\\*star &&\n+\t\ttest_path_is_file git-wild@at &&\n+\t\ttest_path_is_file git-wild%percent\n+\t)\n+'\n+\n+test_expect_success 'wildcard files submit back to p4, modify' '\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\techo new-line >>git-wild#hash &&\n+\t\techo new-line >>git-wild\\*star &&\n+\t\techo new-line >>git-wild@at &&\n+\t\techo new-line >>git-wild%percent &&\n+\t\tgit add git-wild* &&\n+\t\tgit commit -m \"modify the wildcard files\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tgit p4 submit\n+\t) &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\ttest_line_count = 2 git-wild#hash &&\n+\t\ttest_line_count = 2 git-wild\\*star &&\n+\t\ttest_line_count = 2 git-wild@at &&\n+\t\ttest_line_count = 2 git-wild%percent\n+\t)\n+'\n+\n+test_expect_success 'wildcard files submit back to p4, copy' '\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tcp file2 git-wild-cp#hash &&\n+\t\tgit add git-wild-cp#hash &&\n+\t\tcp git-wild\\*star file-wild-3 &&\n+\t\tgit add file-wild-3 &&\n+\t\tgit commit -m \"wildcard copies\" &&\n+\t\tgit config git-p4.detectCopies true &&\n+\t\tgit config git-p4.detectCopiesHarder true &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tgit p4 submit\n+\t) &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\ttest_path_is_file git-wild-cp#hash &&\n+\t\ttest_path_is_file file-wild-3\n+\t)\n+'\n+\n+test_expect_success 'wildcard files submit back to p4, rename' '\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit mv git-wild@at file-wild-4 &&\n+\t\tgit mv file-wild-3 git-wild-cp%percent &&\n+\t\tgit commit -m \"wildcard renames\" &&\n+\t\tgit config git-p4.detectRenames true &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tgit p4 submit\n+\t) &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\ttest_path_is_missing git-wild@at &&\n+\t\ttest_path_is_file git-wild-cp%percent\n+\t)\n+'\n+\n+test_expect_success 'wildcard files submit back to p4, delete' '\n+\ttest_when_finished cleanup_git &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit rm git-wild* &&\n+\t\tgit commit -m \"delete the wildcard files\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tgit p4 submit\n+\t) &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\ttest_path_is_missing git-wild#hash &&\n+\t\ttest_path_is_missing git-wild\\*star &&\n+\t\ttest_path_is_missing git-wild@at &&\n+\t\ttest_path_is_missing git-wild%percent\n+\t)\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\ndiff --git a/t/t9813-git-p4-preserve-users.sh b/t/t9813-git-p4-preserve-users.sh\nnew file mode 100755\nindex 0000000..f2e85e5\n--- /dev/null\n+++ b/t/t9813-git-p4-preserve-users.sh\n@@ -0,0 +1,153 @@\n+#!/bin/sh\n+\n+test_description='git p4 preserve users'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tstart_p4d\n+'\n+\n+test_expect_success 'create files' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tp4 client -o | sed \"/LineEnd/s/:.*/:unix/\" | p4 client -i &&\n+\t\techo file1 >file1 &&\n+\t\techo file2 >file2 &&\n+\t\tp4 add file1 file2 &&\n+\t\tp4 submit -d \"add files\"\n+\t)\n+'\n+\n+p4_add_user() {\n+\tname=$1 fullname=$2 &&\n+\tp4 user -f -i <<-EOF &&\n+\tUser: $name\n+\tEmail: $name@localhost\n+\tFullName: $fullname\n+\tEOF\n+\tp4 passwd -P secret $name\n+}\n+\n+p4_grant_admin() {\n+\tname=$1 &&\n+\t{\n+\t\tp4 protect -o &&\n+\t\techo \"    admin user $name * //depot/...\"\n+\t} | p4 protect -i\n+}\n+\n+p4_check_commit_author() {\n+\tfile=$1 user=$2 &&\n+\tp4 changes -m 1 //depot/$file | grep -q $user\n+}\n+\n+make_change_by_user() {\n+\tfile=$1 name=$2 email=$3 &&\n+\techo \"username: a change by $name\" >>\"$file\" &&\n+\tgit add \"$file\" &&\n+\tgit commit --author \"$name <$email>\" -m \"a change by $name\"\n+}\n+\n+# Test username support, submitting as user 'alice'\n+test_expect_success 'preserve users' '\n+\tp4_add_user alice Alice &&\n+\tp4_add_user bob Bob &&\n+\tp4_grant_admin alice &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\techo \"username: a change by alice\" >>file1 &&\n+\t\techo \"username: a change by bob\" >>file2 &&\n+\t\tgit commit --author \"Alice <alice@localhost>\" -m \"a change by alice\" file1 &&\n+\t\tgit commit --author \"Bob <bob@localhost>\" -m \"a change by bob\" file2 &&\n+\t\tgit config git-p4.skipSubmitEditCheck true &&\n+\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret git p4 commit --preserve-user &&\n+\t\tp4_check_commit_author file1 alice &&\n+\t\tp4_check_commit_author file2 bob\n+\t)\n+'\n+\n+# Test username support, submitting as bob, who lacks admin rights. Should\n+# not submit change to p4 (git diff should show deltas).\n+test_expect_success 'refuse to preserve users without perms' '\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.skipSubmitEditCheck true &&\n+\t\techo \"username-noperms: a change by alice\" >>file1 &&\n+\t\tgit commit --author \"Alice <alice@localhost>\" -m \"perms: a change by alice\" file1 &&\n+\t\tP4EDITOR=touch P4USER=bob P4PASSWD=secret &&\n+\t\texport P4EDITOR P4USER P4PASSWD &&\n+\t\ttest_must_fail git p4 commit --preserve-user &&\n+\t\t! git diff --exit-code HEAD..p4/master\n+\t)\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+\tgit p4 clone --dest=\"$git\" //depot &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.skipSubmitEditCheck true &&\n+\t\techo \"username-bob: a change by bob\" >>file1 &&\n+\t\tgit commit --author \"Bob <bob@localhost>\" -m \"preserve: a change by bob\" file1 &&\n+\t\techo \"username-unknown: a change by charlie\" >>file1 &&\n+\t\tgit commit --author \"Charlie <charlie@localhost>\" -m \"preserve: a change by charlie\" file1 &&\n+\t\tP4EDITOR=touch P4USER=alice P4PASSWD=secret &&\n+\t\texport P4EDITOR P4USER P4PASSWD &&\n+\t\ttest_must_fail git p4 commit --preserve-user &&\n+\t\t! git diff --exit-code HEAD..p4/master &&\n+\n+\t\techo \"$0: repeat with allowMissingP4Users enabled\" &&\n+\t\tgit config git-p4.allowMissingP4Users true &&\n+\t\tgit config git-p4.preserveUser true &&\n+\t\tgit p4 commit &&\n+\t\tgit diff --exit-code HEAD..p4/master &&\n+\t\tp4_check_commit_author file1 alice\n+\t)\n+'\n+\n+# If we're *not* using --preserve-user, git-p4 should warn if we're submitting\n+# changes that are not all ours.\n+# Test: user in p4 and user unknown to p4.\n+# Test: warning disabled and user is the same.\n+test_expect_success 'not preserving user with mixed authorship' '\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.skipSubmitEditCheck true &&\n+\t\tp4_add_user derek Derek &&\n+\n+\t\tmake_change_by_user usernamefile3 Derek derek@localhost &&\n+\t\tP4EDITOR=cat P4USER=alice P4PASSWD=secret &&\n+\t\texport P4EDITOR P4USER P4PASSWD &&\n+\t\tgit p4 commit |\\\n+\t\tgrep \"git author derek@localhost does not match\" &&\n+\n+\t\tmake_change_by_user usernamefile3 Charlie charlie@localhost &&\n+\t\tgit p4 commit |\\\n+\t\tgrep \"git author charlie@localhost does not match\" &&\n+\n+\t\tmake_change_by_user usernamefile3 alice alice@localhost &&\n+\t\tgit p4 commit |\\\n+\t\ttest_must_fail grep \"git author.*does not match\" &&\n+\n+\t\tgit config git-p4.skipUserNameCheck true &&\n+\t\tmake_change_by_user usernamefile3 Charlie charlie@localhost &&\n+\t\tgit p4 commit |\\\n+\t\ttest_must_fail grep \"git author.*does not match\" &&\n+\n+\t\tp4_check_commit_author usernamefile3 alice\n+\t)\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\ndiff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh\nnew file mode 100755\nindex 0000000..84fffb3\n--- /dev/null\n+++ b/t/t9814-git-p4-rename.sh\n@@ -0,0 +1,206 @@\n+#!/bin/sh\n+\n+test_description='git p4 rename'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tstart_p4d\n+'\n+\n+# We rely on this behavior to detect for p4 move availability.\n+test_expect_success 'p4 help unknown returns 1' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\t(\n+\t\t\tp4 help client >errs 2>&1\n+\t\t\techo $? >retval\n+\t\t)\n+\t\techo 0 >expected &&\n+\t\ttest_cmp expected retval &&\n+\t\trm retval &&\n+\t\t(\n+\t\t\tp4 help nosuchcommand >errs 2>&1\n+\t\t\techo $? >retval\n+\t\t)\n+\t\techo 1 >expected &&\n+\t\ttest_cmp expected retval &&\n+\t\trm retval\n+\t)\n+'\n+\n+test_expect_success 'create files' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tp4 client -o | sed \"/LineEnd/s/:.*/:unix/\" | p4 client -i &&\n+\t\tcat >file1 <<-EOF &&\n+\t\tA large block of text\n+\t\tin file1 that will generate\n+\t\tenough context so that rename\n+\t\tand copy detection will find\n+\t\tsomething interesting to do.\n+\t\tEOF\n+\t\tcat >file2 <<-EOF &&\n+\t\t/*\n+\t\t * This blob looks a bit\n+\t\t * different.\n+\t\t */\n+\t\tint main(int argc, char **argv)\n+\t\t{\n+\t\t\tchar text[200];\n+\n+\t\t\tstrcpy(text, \"copy/rename this\");\n+\t\t\tprintf(\"text is %s\\n\", text);\n+\t\t\treturn 0;\n+\t\t}\n+\t\tEOF\n+\t\tp4 add file1 file2 &&\n+\t\tp4 submit -d \"add files\"\n+\t)\n+'\n+\n+# Rename a file and confirm that rename is not detected in P4.\n+# Rename the new file again with detectRenames option enabled and confirm that\n+# this is detected in P4.\n+# Rename the new file again adding an extra line, configure a big threshold in\n+# detectRenames and confirm that rename is not detected in P4.\n+# Repeat, this time with a smaller threshold and confirm that the rename is\n+# detected in P4.\n+test_expect_success 'detect renames' '\n+\tgit p4 clone --dest=\"$git\" //depot@all &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\n+\t\tgit mv file1 file4 &&\n+\t\tgit commit -a -m \"Rename file1 to file4\" &&\n+\t\tgit diff-tree -r -M HEAD &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file4 &&\n+\t\tp4 filelog //depot/file4 | test_must_fail grep -q \"branch from\" &&\n+\n+\t\tgit mv file4 file5 &&\n+\t\tgit commit -a -m \"Rename file4 to file5\" &&\n+\t\tgit diff-tree -r -M HEAD &&\n+\t\tgit config git-p4.detectRenames true &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file5 &&\n+\t\tp4 filelog //depot/file5 | grep -q \"branch from //depot/file4\" &&\n+\n+\t\tgit mv file5 file6 &&\n+\t\techo update >>file6 &&\n+\t\tgit add file6 &&\n+\t\tgit commit -a -m \"Rename file5 to file6 with changes\" &&\n+\t\tgit diff-tree -r -M HEAD &&\n+\t\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/R0*//\") &&\n+\t\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n+\t\tgit config git-p4.detectRenames $(($level + 2)) &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file6 &&\n+\t\tp4 filelog //depot/file6 | test_must_fail grep -q \"branch from\" &&\n+\n+\t\tgit mv file6 file7 &&\n+\t\techo update >>file7 &&\n+\t\tgit add file7 &&\n+\t\tgit commit -a -m \"Rename file6 to file7 with changes\" &&\n+\t\tgit diff-tree -r -M HEAD &&\n+\t\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/R0*//\") &&\n+\t\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n+\t\tgit config git-p4.detectRenames $(($level - 2)) &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file7 &&\n+\t\tp4 filelog //depot/file7 | grep -q \"branch from //depot/file6\"\n+\t)\n+'\n+\n+# Copy a file and confirm that copy is not detected in P4.\n+# Copy a file with detectCopies option enabled and confirm that copy is not\n+# detected in P4.\n+# Modify and copy a file with detectCopies option enabled and confirm that copy\n+# is detected in P4.\n+# Copy a file with detectCopies and detectCopiesHarder options enabled and\n+# confirm that copy is detected in P4.\n+# Modify and copy a file, configure a bigger threshold in detectCopies and\n+# confirm that copy is not detected in P4.\n+# Modify and copy a file, configure a smaller threshold in detectCopies and\n+# confirm that copy is detected in P4.\n+test_expect_success 'detect copies' '\n+\tgit p4 clone --dest=\"$git\" //depot@all &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\n+\t\tcp file2 file8 &&\n+\t\tgit add file8 &&\n+\t\tgit commit -a -m \"Copy file2 to file8\" &&\n+\t\tgit diff-tree -r -C HEAD &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file8 &&\n+\t\tp4 filelog //depot/file8 | test_must_fail grep -q \"branch from\" &&\n+\n+\t\tcp file2 file9 &&\n+\t\tgit add file9 &&\n+\t\tgit commit -a -m \"Copy file2 to file9\" &&\n+\t\tgit diff-tree -r -C HEAD &&\n+\t\tgit config git-p4.detectCopies true &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file9 &&\n+\t\tp4 filelog //depot/file9 | test_must_fail grep -q \"branch from\" &&\n+\n+\t\techo \"file2\" >>file2 &&\n+\t\tcp file2 file10 &&\n+\t\tgit add file2 file10 &&\n+\t\tgit commit -a -m \"Modify and copy file2 to file10\" &&\n+\t\tgit diff-tree -r -C HEAD &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file10 &&\n+\t\tp4 filelog //depot/file10 | grep -q \"branch from //depot/file\" &&\n+\n+\t\tcp file2 file11 &&\n+\t\tgit add file11 &&\n+\t\tgit commit -a -m \"Copy file2 to file11\" &&\n+\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n+\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n+\t\ttest \"$src\" = file10 &&\n+\t\tgit config git-p4.detectCopiesHarder true &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file11 &&\n+\t\tp4 filelog //depot/file11 | grep -q \"branch from //depot/file\" &&\n+\n+\t\tcp file2 file12 &&\n+\t\techo \"some text\" >>file12 &&\n+\t\tgit add file12 &&\n+\t\tgit commit -a -m \"Copy file2 to file12 with changes\" &&\n+\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n+\t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n+\t\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n+\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n+\t\ttest \"$src\" = file10 -o \"$src\" = file11 &&\n+\t\tgit config git-p4.detectCopies $(($level + 2)) &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file12 &&\n+\t\tp4 filelog //depot/file12 | test_must_fail grep -q \"branch from\" &&\n+\n+\t\tcp file2 file13 &&\n+\t\techo \"different text\" >>file13 &&\n+\t\tgit add file13 &&\n+\t\tgit commit -a -m \"Copy file2 to file13 with changes\" &&\n+\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n+\t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n+\t\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n+\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n+\t\ttest \"$src\" = file10 -o \"$src\" = file11 -o \"$src\" = file12 &&\n+\t\tgit config git-p4.detectCopies $(($level - 2)) &&\n+\t\tgit p4 submit &&\n+\t\tp4 filelog //depot/file13 &&\n+\t\tp4 filelog //depot/file13 | grep -q \"branch from //depot/file\"\n+\t)\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194353","messageId":"1340798463-14499-11-git-send-email-pw@padd.com","threadId":"30914","inReplyTo":"1340798463-14499-1-git-send-email-pw@padd.com","subject":"[PATCHv2 10/10] git p4 test: fix badp4dir test","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-27T12:01:03Z","receivedAt":"2012-06-27T12:01:03Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"The construct used to get the return code was flawed, in that\nerrors in the &&-chain before the semicolon were not caught.  Use\nthe standard test_expect_code instead.\n\nSet PATH in a subshell instead of relying on the bashism of\nsetting it just for a single command.\n\nAnd fix the grep line so it doesn't worry about grep segfaults,\nand doesn't fail for i18n issues.\n\nReported-by: Johannes Sixt <j.sixt@viscovery.net>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4-basic.sh | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh\nindex befd823..07c2e15 100755\n--- a/t/t9800-git-p4-basic.sh\n+++ b/t/t9800-git-p4-basic.sh\n@@ -134,9 +134,13 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '\n \texit 1\n \tEOF\n \tchmod 755 badp4dir/p4 &&\n-\tPATH=\"$TRASH_DIRECTORY/badp4dir:$PATH\" git p4 clone --dest=\"$git\" //depot >errs 2>&1 ; retval=$? &&\n-\ttest $retval -eq 1 &&\n-\ttest_must_fail grep -q Traceback errs\n+\t(\n+\t\tPATH=\"$TRASH_DIRECTORY/badp4dir:$PATH\" &&\n+\t\texport PATH &&\n+\t\ttest_expect_code 1 git p4 clone --dest=\"$git\" //depot >errs 2>&1\n+\t) &&\n+\tcat errs &&\n+\t! test_i18ngrep Traceback errs\n '\n \n test_expect_success 'clone bare' '\n-- \n1.7.11.1.69.gd505fd2\n"},{"id":"194381","messageId":"7vfw9g78w5.fsf@alter.siamese.dyndns.org","threadId":"30914","inReplyTo":"1340798463-14499-2-git-send-email-pw@padd.com","subject":"Re: [PATCHv2 01/10] git p4 test: wait longer for p4d to start and test its pid","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-27T21:16:42Z","receivedAt":"2012-06-27T21:16:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pete Wyckoff <pw@padd.com> writes:\n\n> diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\n> index 121e380..2e3706a 100644\n> --- a/t/lib-git-p4.sh\n> +++ b/t/lib-git-p4.sh\n> @@ -33,14 +33,27 @@ pidfile=\"$TRASH_DIRECTORY/p4d.pid\"\n>  \n>  start_p4d() {\n>  \tmkdir -p \"$db\" \"$cli\" \"$git\" &&\n> +\trm -f \"$pidfile\" &&\n>  \t(\n>  \t\tp4d -q -r \"$db\" -p $P4DPORT &\n>  \t\techo $! >\"$pidfile\"\n>  \t) &&\n> -\tfor i in 1 2 3 4 5 ; do\n> +\t# This gives p4d a long time to start up, as it can be\n> +\t# quite slow depending on the machine.  Set this environment\n> +\t# variable to something smaller to fail faster in, say,\n> +\t# an automated test setup.\n> +\ti=${P4D_START_PATIENCE:-300} &&\n> +\twhile [ $i -gt 0 ]; do\n\nDon't write \"test\" as \"[\".\n\n> +\t\t# succeed when p4 client commands start to work\n>  \t\tp4 info >/dev/null 2>&1 && break || true &&\n\nThis is not a new problem but isn't it much clearer to write this as\n\n\t\tp4 info >/dev/null 2>&1 && break\n\nwithout the fake && cascade that does not help anybody?\n\n> +\t\t# fail if pid goes away\n> +\t\tif [ -f \"$pidfile\" ] ; then\n> +\t\t    kill -0 $(cat \"$pidfile\") || break\n> +\t\tfi &&\n\nI am not sure what you are trying to do here.  What happens if\n$pidfile goes away?\n\nIn other words, I think it would make it much more clear to write\nthis part like this:\n\n\tpid=$(cat \"$pidfile\") ready=\n        while test $i -gt 0\n        do\n\t\tif p4 info >/dev/null 2>&1\n                then\n\t\t\tready=true\n                        break\n\t\tfi\n        \tkill -0 $pid || break\n\t\techo waiting for p4d to start\n\t\tsleep 1\n\t\ti=$(( $i - 1 ))\n\tdone\n\n        if test -z \"$ready\"\n        then\n\t\t... p4d failed to start ...\n\t\t... clean up and kill the whole thing ...\n\tfi\n"},{"id":"194399","messageId":"20120628024807.GA16349@padd.com","threadId":"30914","inReplyTo":"7vfw9g78w5.fsf@alter.siamese.dyndns.org","subject":"[PATCHv3 01/10] git p4 test: wait longer for p4d to start and test its pid","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-06-28T02:48:07Z","receivedAt":"2012-06-28T02:48:07Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"Running tests at high parallelism on a slow machine, 5 sec is\nnot enough to wait for p4d to start.  Change it to 5 minutes,\nadding an environment variable P4D_START_PATIENCE to shrink\nthat if needed in automated test environments.\n\nAlso check if the pid of the p4d that we started is still\naround.  If not, quit waiting for it immediately.\n\nRemove all the confusing && chaining and simplify the code.\n\nThanks-to: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/lib-git-p4.sh | 38 ++++++++++++++++++++++++++++++++------\n 1 file changed, 32 insertions(+), 6 deletions(-)\n\ngitster@pobox.com wrote on Wed, 27 Jun 2012 14:16 -0700:\n> In other words, I think it would make it much more clear to write\n> this part like this:\n[..]\n\nMuch nicer.  I think I got hung up on always &&-chaining\ninstead of writing the code so it works.  This version steals\nyour suggestions almost verbatim.  Tested under scenarios\nwhere p4d was slow, hung or died, as well as when it works as\nusual.\n\nJust this patch changed; if it's easy to replace one in the\nseries?  Else I could resend all 10.\n\n\t\t-- Pete\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 121e380..eea46a4 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -33,17 +33,42 @@ pidfile=\"$TRASH_DIRECTORY/p4d.pid\"\n \n start_p4d() {\n \tmkdir -p \"$db\" \"$cli\" \"$git\" &&\n+\trm -f \"$pidfile\" &&\n \t(\n \t\tp4d -q -r \"$db\" -p $P4DPORT &\n \t\techo $! >\"$pidfile\"\n \t) &&\n-\tfor i in 1 2 3 4 5 ; do\n-\t\tp4 info >/dev/null 2>&1 && break || true &&\n-\t\techo waiting for p4d to start &&\n+\n+\t# This gives p4d a long time to start up, as it can be\n+\t# quite slow depending on the machine.  Set this environment\n+\t# variable to something smaller to fail faster in, say,\n+\t# an automated test setup.  If the p4d process dies, that\n+\t# will be caught with the \"kill -0\" check below.\n+\ti=${P4D_START_PATIENCE:-300}\n+\tpid=$(cat \"$pidfile\")\n+\tready=\n+\twhile test $i -gt 0\n+\tdo\n+\t\t# succeed when p4 client commands start to work\n+\t\tif p4 info >/dev/null 2>&1\n+\t\tthen\n+\t\t\tready=true\n+\t\t\tbreak\n+\t\tfi\n+\t\t# fail if p4d died\n+\t\tkill -0 $pid 2>/dev/null || break\n+\t\techo waiting for p4d to start\n \t\tsleep 1\n-\tdone &&\n-\t# complain if it never started\n-\tp4 info >/dev/null &&\n+\t\ti=$(( $i - 1 ))\n+\tdone\n+\n+\tif test -z \"$ready\"\n+\tthen\n+\t\t# p4d failed to start\n+\t\treturn 1\n+\tfi\n+\n+\t# build a client\n \t(\n \t\tcd \"$cli\" &&\n \t\tp4 client -i <<-EOF\n@@ -53,6 +78,7 @@ start_p4d() {\n \t\tView: //depot/... //client/...\n \t\tEOF\n \t)\n+\treturn 0\n }\n \n kill_p4d() {\n-- \n1.7.11.1.69.g485c1e0\n"},{"id":"194400","messageId":"7vsjdg5bdr.fsf@alter.siamese.dyndns.org","threadId":"30914","inReplyTo":"20120628024807.GA16349@padd.com","subject":"Re: [PATCHv3 01/10] git p4 test: wait longer for p4d to start and test its pid","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-28T04:05:52Z","receivedAt":"2012-06-28T04:05:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pete Wyckoff <pw@padd.com> writes:\n\n> Just this patch changed; if it's easy to replace one in the\n> series?  Else I could resend all 10.\n\nThanks, sending only this one is just fine.\n"}]}