{"thread":{"id":"23406","subject":"[PATCH 0/3] t7400-submodule-basic.sh cleanups","startedAt":"2010-04-10T05:37:29Z","lastAt":"2010-04-10T05:39:41Z","messageCount":4,"participants":["Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"139112","messageId":"20100410053729.GA17595@progeny.tock","threadId":"23406","inReplyTo":null,"subject":"[PATCH 0/3] t7400-submodule-basic.sh cleanups","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-10T05:37:29Z","receivedAt":"2010-04-10T05:37:29Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The 'update --init' test from t7400 is failing on a few machines\nI don’t have access to.  It’s hard to say what the dangerous\ningredient is --- maybe a libc bug or something. [1]\n\nI took the opportunity to clarify what some of the tests do and to\nmake the output a little more helpful.\n\nThis series has three patches for easier review, but it might make\nsense to squash them; alternatively, it might make sense to split the\ntest into several files.\n\nWhat do you think?\n\nJonathan Nieder (3):\n  t7400: split setup into multiple tests\n  t7400: clarify 'submodule add' tests\n  t7400: clarify submodule update tests\n\n t/t7400-submodule-basic.sh |  331 +++++++++++++++++++++++++++-----------------\n 1 files changed, 201 insertions(+), 130 deletions(-)\n\n[1] You can see some logged test failures at [2] [3], though it isn’t\nvery illuminating.  Well, that’s more of something for a Debian\nDeveloper or someone with access to a similar machine to investigate.\n[2] <https://buildd.debian.org/build.cgi?pkg=git-core>\n[3] <http://bugs.debian.org/569594>.\n"},{"id":"139113","messageId":"20100410053837.GA17649@progeny.tock","threadId":"23406","inReplyTo":"20100410053729.GA17595@progeny.tock","subject":"[PATCH 1/3] t7400: split setup into multiple tests","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-10T05:38:37Z","receivedAt":"2010-04-10T05:38:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The setup in t7400-submodule-basic does a number of different\nthings to support different tests.  Splitting it up makes the\ntest a little easier to read and should provide an opportunity\nto move each piece of setup closer to the tests that require it.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7400-submodule-basic.sh |   58 ++++++++++++++++++++++---------------------\n 1 files changed, 30 insertions(+), 28 deletions(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 1a4dc5f..1f468e5 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -11,40 +11,42 @@ subcommands of git submodule.\n \n . ./test-lib.sh\n \n-#\n-# Test setup:\n-#  -create a repository in directory init\n-#  -add a couple of files\n-#  -add directory init to 'superproject', this creates a DIRLINK entry\n-#  -add a couple of regular files to enable testing of submodule filtering\n-#  -mv init subrepo\n-#  -add an entry to .gitmodules for submodule 'example'\n-#\n-test_expect_success 'Prepare submodule testing' '\n-\t: > t &&\n+test_expect_success 'setup - initial commit' '\n+\t>t &&\n \tgit add t &&\n \tgit commit -m \"initial commit\" &&\n-\tgit branch initial HEAD &&\n+\tgit branch initial\n+'\n+\n+test_expect_success 'setup - repository in init subdirectory' '\n \tmkdir init &&\n-\tcd init &&\n-\tgit init &&\n-\techo a >a &&\n-\tgit add a &&\n-\tgit commit -m \"submodule commit 1\" &&\n-\tgit tag -a -m \"rev-1\" rev-1 &&\n-\trev1=$(git rev-parse HEAD) &&\n-\tif test -z \"$rev1\"\n-\tthen\n-\t\techo \"[OOPS] submodule git rev-parse returned nothing\"\n-\t\tfalse\n-\tfi &&\n-\tcd .. &&\n+\t(\n+\t\tcd init &&\n+\t\tgit init &&\n+\t\techo a >a &&\n+\t\tgit add a &&\n+\t\tgit commit -m \"submodule commit 1\" &&\n+\t\tgit tag -a -m \"rev-1\" rev-1\n+\t)\n+\trev1=$(cd init && git rev-parse HEAD) &&\n+\tprintf \"rev1: %s\\n\" \"$rev1\" &&\n+\ttest -n \"$rev1\"\n+'\n+\n+test_expect_success 'setup - commit with gitlink' '\n \techo a >a &&\n \techo z >z &&\n \tgit add a init z &&\n-\tgit commit -m \"super commit 1\" &&\n-\tmv init .subrepo &&\n-\tGIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git\n+\tgit commit -m \"super commit 1\"\n+'\n+\n+test_expect_success 'setup - hide init subdirectory' '\n+\tmv init .subrepo\n+'\n+\n+test_expect_success 'setup - add an example entry to .gitmodules' '\n+\tGIT_CONFIG=.gitmodules \\\n+\tgit config submodule.example.url git://example.com/init.git\n '\n \n test_expect_success 'Prepare submodule add testing' '\n-- \n1.7.0.4\n"},{"id":"139114","messageId":"20100410053904.GB17649@progeny.tock","threadId":"23406","inReplyTo":"20100410053729.GA17595@progeny.tock","subject":"[PATCH 2/3] t7400: clarify 'submodule add' tests","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-10T05:39:04Z","receivedAt":"2010-04-10T05:39:04Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"A new reader may not realize what properties the $submodurl\nrepository needs to have.\n\nOne of the tests is checking that ‘submodule add -b foo’ creates\na ‘foo’ branch.  Put this test in context by checking that\nwithout -b, no ‘foo’ branch is created.\n\nWhile at it, make sure each added submodule is a reasonable\nrepository, with clean index, no stray files, and so on.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7400-submodule-basic.sh |  103 +++++++++++++++++++++++++++++++++++++------\n 1 files changed, 88 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 1f468e5..dbc8338 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -49,63 +49,136 @@ test_expect_success 'setup - add an example entry to .gitmodules' '\n \tgit config submodule.example.url git://example.com/init.git\n '\n \n-test_expect_success 'Prepare submodule add testing' '\n-\tsubmodurl=$(pwd)\n+test_expect_success 'setup - repository to add submodules to' '\n+\tgit init addtest\n+'\n+\n+# The 'submodule add' tests need some repository to add as a submodule.\n+# The trash directory is a good one as any.\n+submodurl=$TRASH_DIRECTORY\n+\n+listbranches() {\n+\tgit for-each-ref --format='%(refname)' 'refs/heads/*'\n+}\n+\n+inspect() {\n+\tdir=$1 &&\n+\tdotdot=\"${2:-..}\" &&\n+\n \t(\n-\t\tmkdir addtest &&\n-\t\tcd addtest &&\n-\t\tgit init\n+\t\tcd \"$dir\" &&\n+\t\tlistbranches >\"$dotdot/heads\" &&\n+\t\t{ git symbolic-ref HEAD || :; } >\"$dotdot/head\" &&\n+\t\tgit update-index --refresh &&\n+\t\tgit diff-files --exit-code &&\n+\t\tgit clean -n -d -x >\"$dotdot/untracked\"\n \t)\n-'\n+}\n \n+rm -f heads head untracked\n test_expect_success 'submodule add' '\n+\techo \"refs/heads/master\" >expect &&\n+\t>empty &&\n+\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add \"$submodurl\" submod &&\n \t\tgit submodule init\n-\t)\n+\t) &&\n+\n+\tinspect addtest/submod ../.. &&\n+\ttest_cmp expect heads &&\n+\ttest_cmp expect head &&\n+\ttest_cmp empty untracked\n '\n \n+rm -f heads head untracked\n test_expect_success 'submodule add --branch' '\n+\techo \"refs/heads/initial\" >expect-head &&\n+\tcat <<-\\EOF >expect-heads &&\n+\trefs/heads/initial\n+\trefs/heads/master\n+\tEOF\n+\t>empty &&\n+\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add -b initial \"$submodurl\" submod-branch &&\n-\t\tgit submodule init &&\n-\t\tcd submod-branch &&\n-\t\tgit branch | grep initial\n-\t)\n+\t\tgit submodule init\n+\t) &&\n+\n+\tinspect addtest/submod-branch ../.. &&\n+\ttest_cmp expect-heads heads &&\n+\ttest_cmp expect-head head &&\n+\ttest_cmp empty untracked\n '\n \n+rm -f heads head untracked\n test_expect_success 'submodule add with ./ in path' '\n+\techo \"refs/heads/master\" >expect &&\n+\t>empty &&\n+\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add \"$submodurl\" ././dotsubmod/./frotz/./ &&\n \t\tgit submodule init\n-\t)\n+\t) &&\n+\n+\tinspect addtest/dotsubmod/frotz ../../.. &&\n+\ttest_cmp expect heads &&\n+\ttest_cmp expect head &&\n+\ttest_cmp empty untracked\n '\n \n+rm -f heads head untracked\n test_expect_success 'submodule add with // in path' '\n+\techo \"refs/heads/master\" >expect &&\n+\t>empty &&\n+\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add \"$submodurl\" slashslashsubmod///frotz// &&\n \t\tgit submodule init\n-\t)\n+\t) &&\n+\n+\tinspect addtest/slashslashsubmod/frotz ../../.. &&\n+\ttest_cmp expect heads &&\n+\ttest_cmp expect head &&\n+\ttest_cmp empty untracked\n '\n \n+rm -f heads head untracked\n test_expect_success 'submodule add with /.. in path' '\n+\techo \"refs/heads/master\" >expect &&\n+\t>empty &&\n+\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add \"$submodurl\" dotdotsubmod/../realsubmod/frotz/.. &&\n \t\tgit submodule init\n-\t)\n+\t) &&\n+\n+\tinspect addtest/realsubmod ../.. &&\n+\ttest_cmp expect heads &&\n+\ttest_cmp expect head &&\n+\ttest_cmp empty untracked\n '\n \n+rm -f heads head untracked\n test_expect_success 'submodule add with ./, /.. and // in path' '\n+\techo \"refs/heads/master\" >expect &&\n+\t>empty &&\n+\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add \"$submodurl\" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&\n \t\tgit submodule init\n-\t)\n+\t) &&\n+\n+\tinspect addtest/realsubmod2 ../.. &&\n+\ttest_cmp expect heads &&\n+\ttest_cmp expect head &&\n+\ttest_cmp empty untracked\n '\n \n test_expect_success 'status should fail for unmapped paths' '\n-- \n1.7.0.4\n"},{"id":"139115","messageId":"20100410053940.GC17649@progeny.tock","threadId":"23406","inReplyTo":"20100410053729.GA17595@progeny.tock","subject":"[PATCH 3/3] t7400: clarify submodule update tests","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-10T05:39:41Z","receivedAt":"2010-04-10T05:39:41Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"In particular, add a missing && to the update --init test.\n\nThe goal is to make it clearer what happened when one of these\ntests fails.  The update --init test is currently (consistently)\nfailing on a few unusual machines.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7400-submodule-basic.sh |  186 +++++++++++++++++++++----------------------\n 1 files changed, 91 insertions(+), 95 deletions(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex dbc8338..55590ab 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -28,9 +28,6 @@ test_expect_success 'setup - repository in init subdirectory' '\n \t\tgit commit -m \"submodule commit 1\" &&\n \t\tgit tag -a -m \"rev-1\" rev-1\n \t)\n-\trev1=$(cd init && git rev-parse HEAD) &&\n-\tprintf \"rev1: %s\\n\" \"$rev1\" &&\n-\ttest -n \"$rev1\"\n '\n \n test_expect_success 'setup - commit with gitlink' '\n@@ -44,11 +41,6 @@ test_expect_success 'setup - hide init subdirectory' '\n \tmv init .subrepo\n '\n \n-test_expect_success 'setup - add an example entry to .gitmodules' '\n-\tGIT_CONFIG=.gitmodules \\\n-\tgit config submodule.example.url git://example.com/init.git\n-'\n-\n test_expect_success 'setup - repository to add submodules to' '\n \tgit init addtest\n '\n@@ -69,6 +61,7 @@ inspect() {\n \t\tcd \"$dir\" &&\n \t\tlistbranches >\"$dotdot/heads\" &&\n \t\t{ git symbolic-ref HEAD || :; } >\"$dotdot/head\" &&\n+\t\tgit rev-parse HEAD >\"$dotdot/head-sha1\" &&\n \t\tgit update-index --refresh &&\n \t\tgit diff-files --exit-code &&\n \t\tgit clean -n -d -x >\"$dotdot/untracked\"\n@@ -181,131 +174,129 @@ test_expect_success 'submodule add with ./, /.. and // in path' '\n \ttest_cmp empty untracked\n '\n \n+test_expect_success 'setup - add an example entry to .gitmodules' '\n+\tGIT_CONFIG=.gitmodules \\\n+\tgit config submodule.example.url git://example.com/init.git\n+'\n+\n test_expect_success 'status should fail for unmapped paths' '\n-\tif git submodule status\n-\tthen\n-\t\techo \"[OOPS] submodule status succeeded\"\n-\t\tfalse\n-\telif ! GIT_CONFIG=.gitmodules git config submodule.example.path init\n-\tthen\n-\t\techo \"[OOPS] git config failed to update .gitmodules\"\n-\t\tfalse\n-\tfi\n+\ttest_must_fail git submodule status\n+'\n+\n+test_expect_success 'setup - map path in .gitmodules' '\n+\tcat <<\\EOF >expect &&\n+[submodule \"example\"]\n+\turl = git://example.com/init.git\n+\tpath = init\n+EOF\n+\n+\tGIT_CONFIG=.gitmodules git config submodule.example.path init &&\n+\n+\ttest_cmp expect .gitmodules\n '\n \n test_expect_success 'status should only print one line' '\n-\tlines=$(git submodule status | wc -l) &&\n-\ttest $lines = 1\n+\tgit submodule status >lines &&\n+\ttest $(wc -l <lines) = 1\n+'\n+\n+test_expect_success 'setup - fetch commit name from submodule' '\n+\trev1=$(cd .subrepo && git rev-parse HEAD) &&\n+\tprintf \"rev1: %s\\n\" \"$rev1\" &&\n+\ttest -n \"$rev1\"\n '\n \n test_expect_success 'status should initially be \"missing\"' '\n-\tgit submodule status | grep \"^-$rev1\"\n+\tgit submodule status >lines &&\n+\tgrep \"^-$rev1\" lines\n '\n \n test_expect_success 'init should register submodule url in .git/config' '\n+\techo git://example.com/init.git >expect &&\n+\n \tgit submodule init &&\n-\turl=$(git config submodule.example.url) &&\n-\tif test \"$url\" != \"git://example.com/init.git\"\n-\tthen\n-\t\techo \"[OOPS] init succeeded but submodule url is wrong\"\n-\t\tfalse\n-\telif test_must_fail git config submodule.example.url ./.subrepo\n-\tthen\n-\t\techo \"[OOPS] init succeeded but update of url failed\"\n-\t\tfalse\n-\tfi\n+\tgit config submodule.example.url >url &&\n+\tgit config submodule.example.url ./.subrepo &&\n+\n+\ttest_cmp expect url\n '\n \n test_expect_success 'update should fail when path is used by a file' '\n+\techo hello >expect &&\n+\n \techo \"hello\" >init &&\n-\tif git submodule update\n-\tthen\n-\t\techo \"[OOPS] update should have failed\"\n-\t\tfalse\n-\telif test \"$(cat init)\" != \"hello\"\n-\tthen\n-\t\techo \"[OOPS] update failed but init file was molested\"\n-\t\tfalse\n-\telse\n-\t\trm init\n-\tfi\n+\ttest_must_fail git submodule update &&\n+\n+\ttest_cmp expect init\n '\n \n+rm -fr init\n test_expect_success 'update should fail when path is used by a nonempty directory' '\n+\techo hello >expect &&\n+\n \tmkdir init &&\n \techo \"hello\" >init/a &&\n-\tif git submodule update\n-\tthen\n-\t\techo \"[OOPS] update should have failed\"\n-\t\tfalse\n-\telif test \"$(cat init/a)\" != \"hello\"\n-\tthen\n-\t\techo \"[OOPS] update failed but init/a was molested\"\n-\t\tfalse\n-\telse\n-\t\trm init/a\n-\tfi\n+\n+\ttest_must_fail git submodule update &&\n+\n+\ttest_cmp expect init/a\n '\n \n+rm -fr init\n+rm -f head-sha1\n test_expect_success 'update should work when path is an empty dir' '\n-\trm -rf init &&\n+\techo \"$rev1\" >expect\n+\n \tmkdir init &&\n \tgit submodule update &&\n-\thead=$(cd init && git rev-parse HEAD) &&\n-\tif test -z \"$head\"\n-\tthen\n-\t\techo \"[OOPS] Failed to obtain submodule head\"\n-\t\tfalse\n-\telif test \"$head\" != \"$rev1\"\n-\tthen\n-\t\techo \"[OOPS] Submodule head is $head but should have been $rev1\"\n-\t\tfalse\n-\tfi\n+\n+\tinspect init &&\n+\ttest_cmp expect head-sha1\n '\n \n test_expect_success 'status should be \"up-to-date\" after update' '\n-\tgit submodule status | grep \"^ $rev1\"\n+\tgit submodule status >list &&\n+\tgrep \"^ $rev1\" list\n '\n \n test_expect_success 'status should be \"modified\" after submodule commit' '\n-\tcd init &&\n-\techo b >b &&\n-\tgit add b &&\n-\tgit commit -m \"submodule commit 2\" &&\n-\trev2=$(git rev-parse HEAD) &&\n-\tcd .. &&\n-\tif test -z \"$rev2\"\n-\tthen\n-\t\techo \"[OOPS] submodule git rev-parse returned nothing\"\n-\t\tfalse\n-\tfi &&\n-\tgit submodule status | grep \"^+$rev2\"\n+\t(\n+\t\tcd init &&\n+\t\techo b >b &&\n+\t\tgit add b &&\n+\t\tgit commit -m \"submodule commit 2\"\n+\t) &&\n+\n+\trev2=$(cd init && git rev-parse HEAD) &&\n+\ttest -n \"$rev2\" &&\n+\tgit submodule status >list &&\n+\n+\tgrep \"^+$rev2\" list\n '\n \n test_expect_success 'the --cached sha1 should be rev1' '\n-\tgit submodule --cached status | grep \"^+$rev1\"\n+\tgit submodule --cached status >list &&\n+\tgrep \"^+$rev1\" list\n '\n \n test_expect_success 'git diff should report the SHA1 of the new submodule commit' '\n-\tgit diff | grep \"^+Subproject commit $rev2\"\n+\tgit diff >diff &&\n+\tgrep \"^+Subproject commit $rev2\" diff\n '\n \n+rm -f head-sha1\n test_expect_success 'update should checkout rev1' '\n+\techo \"$rev1\" >expect &&\n+\n \tgit submodule update init &&\n-\thead=$(cd init && git rev-parse HEAD) &&\n-\tif test -z \"$head\"\n-\tthen\n-\t\techo \"[OOPS] submodule git rev-parse returned nothing\"\n-\t\tfalse\n-\telif test \"$head\" != \"$rev1\"\n-\tthen\n-\t\techo \"[OOPS] init did not checkout correct head\"\n-\t\tfalse\n-\tfi\n+\tinspect init &&\n+\n+\ttest_cmp expect head-sha1\n '\n \n test_expect_success 'status should be \"up-to-date\" after update' '\n-\tgit submodule status | grep \"^ $rev1\"\n+\tgit submodule status >list &&\n+\tgrep \"^ $rev1\" list\n '\n \n test_expect_success 'checkout superproject with subproject already present' '\n@@ -314,6 +305,8 @@ test_expect_success 'checkout superproject with subproject already present' '\n '\n \n test_expect_success 'apply submodule diff' '\n+\t>empty &&\n+\n \tgit branch second &&\n \t(\n \t\tcd init &&\n@@ -326,21 +319,24 @@ test_expect_success 'apply submodule diff' '\n \tgit format-patch -1 --stdout >P.diff &&\n \tgit checkout second &&\n \tgit apply --index P.diff &&\n-\tD=$(git diff --cached master) &&\n-\ttest -z \"$D\"\n+\n+\tgit diff --cached master >staged &&\n+\ttest_cmp empty staged\n '\n \n test_expect_success 'update --init' '\n-\n \tmv init init2 &&\n \tgit config -f .gitmodules submodule.example.url \"$(pwd)/init2\" &&\n-\tgit config --remove-section submodule.example\n+\tgit config --remove-section submodule.example &&\n+\ttest_must_fail git config submodule.example.url &&\n+\n \tgit submodule update init > update.out &&\n+\tcat update.out &&\n \tgrep \"not initialized\" update.out &&\n-\ttest ! -d init/.git &&\n+\t! test -d init/.git &&\n+\n \tgit submodule update --init init &&\n \ttest -d init/.git\n-\n '\n \n test_expect_success 'do not add files from a submodule' '\n-- \n1.7.0.4\n"}]}