{"thread":{"id":"8337","subject":"[PATCH] Add basic test-script for git-submodule","startedAt":"2007-05-27T20:34:59Z","lastAt":"2007-06-02T01:27:42Z","messageCount":9,"participants":["Lars Hjemli","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43450","messageId":"11802980992216-git-send-email-hjemli@gmail.com","threadId":"8337","inReplyTo":null,"subject":"[PATCH] Add basic test-script for git-submodule","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-27T20:34:59Z","receivedAt":"2007-05-27T20:34:59Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This test verifies the basic operations in git-submodule, i.e. that it is\nable to clone and update a submodule repository, that its status output is\nsane, and that it errors out when the submodule path is occupied during\ninit.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nFinally the test-script emerges. Btw, thanks for fixing my broken submodule\npatch :)\n\n t/t7400-submodule-basic.sh |   82 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 82 insertions(+), 0 deletions(-)\n create mode 100755 t/t7400-submodule-basic.sh\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nnew file mode 100755\nindex 0000000..2212b29\n--- /dev/null\n+++ b/t/t7400-submodule-basic.sh\n@@ -0,0 +1,82 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Lars Hjemli\n+#\n+\n+test_description='Basic submodule support in porcelain\n+\n+This test tries to run the init, update and status commands of git-submodule\n+with a known good setup (and two known bad)\n+'\n+\n+. ./test-lib.sh\n+\n+\n+# create a submodule repository\n+mkdir lib && cd lib\n+git-init >/dev/null\n+echo a >a && git-add a && git-commit -q -m \"submodule commit 1\"\n+git-tag -a -m \"rev-1\" rev-1\n+rev1=$(git-rev-parse HEAD)\n+cd ..\n+\n+# add submodule and other files to super repo\n+echo a >a && echo z >z\n+git-add a lib z && git-commit -q -m \"super commit 1\"\n+\n+# move submodule to another location, register repo url in .gitmodules\n+mv lib .subrepo\n+GIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo\n+\n+test_expect_success 'status is \"missing\"' \\\n+\t'git-submodule status | grep \"^-$rev1\"'\n+\n+# make sure 'init' will not overwrite a regular file\n+touch lib\n+test_expect_failure 'init fails when path is used by a file' \\\n+\t'git-submodule init'\n+\n+# make sure 'init' will not overwrite a nonempty directory\n+rm lib\n+mkdir -p lib/foo\n+test_expect_failure 'init fails when path is used by a nonempty directory' \\\n+\t'git-submodule init'\n+\n+# turn lib into an empty directory, just like git-checkout would do\n+rmdir lib/foo\n+test_expect_success 'init works when path is an empty dir' \\\n+\t'git-submodule init && test -d lib/.git && git-diff --exit-code'\n+\n+head=$(cd lib && git-rev-parse HEAD)\n+test_expect_success 'submodule HEAD should match rev1' \\\n+\t'test \"$head\" = \"$rev1\"'\n+\n+test_expect_success 'status is \"up-to-date\" after init' \\\n+\t'git-submodule status | grep \"^ $rev1\"'\n+\n+# change the submodule HEAD\n+cd lib\n+echo b >b && git-add b && git-commit -q -m \"submodule commit 2\"\n+rev2=$(git-rev-parse HEAD)\n+cd ..\n+\n+test_expect_success 'status is \"modified\" after submodule commit' \\\n+\t'git-submodule status | grep \"^\\+$rev2\"'\n+\n+test_expect_success 'the --cached sha1 should be rev1' \\\n+\t'git-submodule --cached status | grep \"^\\+$rev1\"'\n+\n+test_expect_failure 'git-diff --exit-code reports local modifications' \\\n+\t'git-diff --exit-code'\n+\n+test_expect_success 'update should checkout the correct commit' \\\n+\t'git-submodule update && git-diff --exit-code'\n+\n+head=$(cd lib && git-rev-parse HEAD)\n+test_expect_success 'submodule HEAD should match rev1' \\\n+\t'test \"$head\" = \"$rev1\"'\n+\n+test_expect_success 'status is \"up-to-date\" after update' \\\n+\t'git-submodule status | grep \"^ $rev1\"'\n+\n+test_done\n-- \n1.5.2.74.g6b2d\n"},{"id":"44459","messageId":"7v7iqs6r6p.fsf@assigned-by-dhcp.cox.net","threadId":"8337","inReplyTo":"11802980992216-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-29T07:10:22Z","receivedAt":"2007-05-29T07:10:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> +# create a submodule repository\n> +mkdir lib && cd lib\n> +git-init >/dev/null\n> +echo a >a && git-add a && git-commit -q -m \"submodule commit 1\"\n> +git-tag -a -m \"rev-1\" rev-1\n> +rev1=$(git-rev-parse HEAD)\n> +cd ..\n> +\n> +# add submodule and other files to super repo\n> +echo a >a && echo z >z\n> +git-add a lib z && git-commit -q -m \"super commit 1\"\n> +\n> +# move submodule to another location, register repo url in .gitmodules\n> +mv lib .subrepo\n> +GIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo\n\nWe typically try to catch malfunction even while setting up the test case.\n\n> +test_expect_success 'status is \"missing\"' \\\n> +\t'git-submodule status | grep \"^-$rev1\"'\n> +\n> +# make sure 'init' will not overwrite a regular file\n> +touch lib\n> +test_expect_failure 'init fails when path is used by a file' \\\n> +\t'git-submodule init'\n\nI am guilty for introducing \"expect-failure\", but it is usually\na mistake to use it unless you are testing something very trivial.\n\nFor example, for this case, you would want to make sure the\ncommand \"git-submodule init\" exits with non-zero status, but\nalso you would want to make sure that it does not disturb the\nexisting file \"lib\".  You might also want to see if the command\ngives the right error message (or status code) as well, although\ntypically the wording of error message is subject to change, so\nwe tend to try not to be too strict about it.\n\nIn any case, I would probably write this part of the code like\nthis:\n\n        test_expect_success 'init fails when path is used by a file' '\n\n                echo hello >lib &&\n                if git-submodule init\n                then\n                        echo \"Oops, should have failed\"\n                        false\n                elif test -f lib && test \"$(cat lib)\" = hello\n                then\t\t\n                        : happy\n                else\n                        echo \"Oops, failed but lib file was molested\"\n                        false\n                fi\n        '\n\nLater when somebody tries to improve git-submodule and botches,\nhe can run the test with \"-i -v\" and observe which \"Oops\" comes\nout to see why the test failed -- it would give him a clue on\nhow he broke it.\n"},{"id":"43622","messageId":"8c5c35580705292348q74281f7eu15b3b61f45b2c6f5@mail.gmail.com","threadId":"8337","inReplyTo":"7v7iqs6r6p.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-30T06:48:38Z","receivedAt":"2007-05-30T06:48:38Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 5/29/07, Junio C Hamano <junkio@cox.net> wrote:\n> Lars Hjemli <hjemli@gmail.com> writes:\n>\n> > +# create a submodule repository\n> > +mkdir lib && cd lib\n> > +git-init >/dev/null\n> > +echo a >a && git-add a && git-commit -q -m \"submodule commit 1\"\n> > +git-tag -a -m \"rev-1\" rev-1\n> > +rev1=$(git-rev-parse HEAD)\n> > +cd ..\n> > +\n> > +# add submodule and other files to super repo\n> > +echo a >a && echo z >z\n> > +git-add a lib z && git-commit -q -m \"super commit 1\"\n> > +\n> > +# move submodule to another location, register repo url in .gitmodules\n> > +mv lib .subrepo\n> > +GIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo\n>\n> We typically try to catch malfunction even while setting up the test case.\n\nOk\n\n>\n> > +test_expect_success 'status is \"missing\"' \\\n> > +     'git-submodule status | grep \"^-$rev1\"'\n> > +\n> > +# make sure 'init' will not overwrite a regular file\n> > +touch lib\n> > +test_expect_failure 'init fails when path is used by a file' \\\n> > +     'git-submodule init'\n>\n> I am guilty for introducing \"expect-failure\", but it is usually\n> a mistake to use it unless you are testing something very trivial.\n>\n> For example, for this case, you would want to make sure the\n> command \"git-submodule init\" exits with non-zero status, but\n> also you would want to make sure that it does not disturb the\n> existing file \"lib\".\n\nWould you prefer a patch on top of this version of the test-script or\non top of the later patch which uses .git/config to store submodule\nurl?\n\n--\nlarsh\n"},{"id":"43716","messageId":"7vzm3kz5w9.fsf@assigned-by-dhcp.cox.net","threadId":"8337","inReplyTo":"8c5c35580705292348q74281f7eu15b3b61f45b2c6f5@mail.gmail.com","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-06-01T03:54:14Z","receivedAt":"2007-06-01T03:54:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n> Would you prefer a patch on top of this version of the test-script or\n> on top of the later patch which uses .git/config to store submodule\n> url?\n\nAs you said you will be redoing submodule + .git/config stuff in\nyour other message, I would expect a replacement (i.e. not on\ntop of this) patch for tests to check the existing submodule\nfeatures.  If you want to finish the submodule + .git/config one\nfirst and then test script on top to test both existing featues\nand submodule + .git/config features, that is fine as well.\nYour choice.\n\nOne important point is to treat the test-script take #1 as\n\"already rejected\", and not basing further patches on it.\n"},{"id":"43720","messageId":"op.ts8d71b89pspc6@localhost","threadId":"8337","inReplyTo":"7vzm3kz5w9.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-06-01T07:10:39Z","receivedAt":"2007-06-01T07:10:39Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This test tries to verify basic sanity of git-submodule, i.e. that it is\nable to clone and update a submodule repository, that its status output is\nsane, and that it barfs when the submodule path is occupied during init.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nOn 6/1/07, Junio C Hamano <junkio@cox.net> wrote:\n> As you said you will be redoing submodule + .git/config stuff in\n> your other message, I would expect a replacement (i.e. not on\n> top of this) patch for tests to check the existing submodule\n> features.  If you want to finish the submodule + .git/config one\n> first and then test script on top to test both existing featues\n> and submodule + .git/config features, that is fine as well.\n> Your choice.\n\nMy continuous quest for self-discipline left me no choice but to attempt\nthe creation of a proper testscript for the existing features ;-)\n\n  t/t7400-submodule-basic.sh |  143 ++++++++++++++++++++++++++++++++++++++++++++\n  1 files changed, 143 insertions(+), 0 deletions(-)\n  create mode 100755 t/t7400-submodule-basic.sh\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nnew file mode 100755\nindex 0000000..a8beee2\n--- /dev/null\n+++ b/t/t7400-submodule-basic.sh\n@@ -0,0 +1,143 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Lars Hjemli\n+#\n+\n+test_description='Basic porcelain support for submodules\n+\n+This test tries to verify basic sanity of the init, update and status\n+subcommands of git-submodule.\n+'\n+\n+. ./test-lib.sh\n+\n+#\n+# Test setup:\n+#  -create a repository in directory lib\n+#  -add a couple of files\n+#  -add directory lib to 'superproject', this creates a DIRLINK entry\n+#  -add a couple of regular files to enable testing of submodule filtering\n+#  -mv lib subrepo\n+#  -add an entry to .gitmodules for path 'lib'\n+#\n+test_expect_success 'Prepare submodule testing' '\n+\tmkdir lib &&\n+\tcd lib &&\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+\techo a >a &&\n+\techo z >z &&\n+\tgit-add a lib z &&\n+\tgit-commit -m \"super commit 1\" &&\n+\tmv lib .subrepo &&\n+\tGIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo\n+'\n+\n+test_expect_success 'status should only print one line' '\n+\tlines=$(git-submodule status | wc -l)\n+\ttest \"$lines\" = \"1\"\n+'\n+\n+test_expect_success 'status should initially be \"missing\"' '\n+\tgit-submodule status | grep \"^-$rev1\"\n+'\n+\n+test_expect_success 'init should fail when path is used by a file' '\n+\techo \"hello\" >lib &&\n+\tif git-submodule init\n+\tthen\n+\t\techo \"[OOPS] init should have failed\"\n+\t\tfalse\n+\telif test -f lib && test \"$(cat lib)\" != \"hello\"\n+\tthen\n+\t\techo \"[OOPS] init failed but lib file was molested\"\n+\t\tfalse\n+\telse\n+\t\trm lib\n+\tfi\n+'\n+\n+test_expect_success 'init should fail when path is used by a nonempty directory' '\n+\tmkdir lib &&\n+\techo \"hello\" >lib/a &&\n+\tif git-submodule init\n+\tthen\n+\t\techo \"[OOPS] init should have failed\"\n+\t\tfalse\n+\telif test \"$(cat lib/a)\" != \"hello\"\n+\tthen\n+\t\techo \"[OOPS] init failed but lib/a was molested\"\n+\t\tfalse\n+\telse\n+\t\trm lib/a\n+\tfi\n+'\n+\n+test_expect_success 'init should work when path is an empty dir' '\n+\trm -rf lib &&\n+\tmkdir lib &&\n+\tgit-submodule init &&\n+\thead=$(cd lib && 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+\n+test_expect_success 'status should be \"up-to-date\" after init' '\n+\tgit-submodule status | grep \"^ $rev1\"\n+'\n+\n+test_expect_success 'status should be \"modified\" after submodule commit' '\n+\tcd lib &&\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+'\n+\n+test_expect_success 'the --cached sha1 should be rev1' '\n+\tgit-submodule --cached status | grep \"^\\+$rev1\"\n+'\n+\n+test_expect_success 'update should checkout rev1' '\n+\tgit-submodule update &&\n+\thead=$(cd lib && 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+'\n+\n+test_expect_success 'status should be \"up-to-date\" after update' '\n+\tgit-submodule status | grep \"^ $rev1\"\n+'\n+\n+test_done\n-- \n1.5.2.839.ga3b1-dirty\n"},{"id":"43725","messageId":"465FD11C.6B1D5172@eudaptics.com","threadId":"8337","inReplyTo":"op.ts8d71b89pspc6@localhost","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-06-01T07:56:12Z","receivedAt":"2007-06-01T07:56:12Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Lars Hjemli wrote:\n> +test_expect_success 'status should only print one line' '\n> +       lines=$(git-submodule status | wc -l)\n\n&& is missing.\n\n> +       test \"$lines\" = \"1\"\n\nPlease don't put output of wc in quotes because some versions of wc emit\npadding:\n\n\ttest $lines = 1\n\n(without the quotes around 1 - like in other test scripts).\n\n-- Hannes\n"},{"id":"43726","messageId":"op.ts8g4dsa9pspc6@localhost","threadId":"8337","inReplyTo":"465FD11C.6B1D5172@eudaptics.com","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-06-01T08:13:15Z","receivedAt":"2007-06-01T08:13:15Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This test tries to verify basic sanity of git-submodule, i.e. that it is\nable to clone and update a submodule repository, that its status output is\nsane, and that it barfs when the submodule path is occupied during init.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nOn Fri, 01 Jun 2007 09:56:12 +0200, Johannes Sixt <J.Sixt@eudaptics.com> wrote:\n> Lars Hjemli wrote:\n>> +test_expect_success 'status should only print one line' '\n>> +       lines=$(git-submodule status | wc -l)\n>\n> && is missing.\n>\n>> +       test \"$lines\" = \"1\"\n>\n> Please don't put output of wc in quotes because some versions of wc emit\n> padding:\n>\n> \ttest $lines = 1\n>\n> (without the quotes around 1 - like in other test scripts).\n>\n\nThanks, and sorry...\n\n\n  t/t7400-submodule-basic.sh |  143 ++++++++++++++++++++++++++++++++++++++++++++\n  1 files changed, 143 insertions(+), 0 deletions(-)\n  create mode 100755 t/t7400-submodule-basic.sh\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nnew file mode 100755\nindex 0000000..a985a6e\n--- /dev/null\n+++ b/t/t7400-submodule-basic.sh\n@@ -0,0 +1,143 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Lars Hjemli\n+#\n+\n+test_description='Basic porcelain support for submodules\n+\n+This test tries to verify basic sanity of the init, update and status\n+subcommands of git-submodule.\n+'\n+\n+. ./test-lib.sh\n+\n+#\n+# Test setup:\n+#  -create a repository in directory lib\n+#  -add a couple of files\n+#  -add directory lib to 'superproject', this creates a DIRLINK entry\n+#  -add a couple of regular files to enable testing of submodule filtering\n+#  -mv lib subrepo\n+#  -add an entry to .gitmodules for path 'lib'\n+#\n+test_expect_success 'Prepare submodule testing' '\n+\tmkdir lib &&\n+\tcd lib &&\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+\techo a >a &&\n+\techo z >z &&\n+\tgit-add a lib z &&\n+\tgit-commit -m \"super commit 1\" &&\n+\tmv lib .subrepo &&\n+\tGIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo\n+'\n+\n+test_expect_success 'status should only print one line' '\n+\tlines=$(git-submodule status | wc -l) &&\n+\ttest $lines = 1\n+'\n+\n+test_expect_success 'status should initially be \"missing\"' '\n+\tgit-submodule status | grep \"^-$rev1\"\n+'\n+\n+test_expect_success 'init should fail when path is used by a file' '\n+\techo \"hello\" >lib &&\n+\tif git-submodule init\n+\tthen\n+\t\techo \"[OOPS] init should have failed\"\n+\t\tfalse\n+\telif test -f lib && test \"$(cat lib)\" != \"hello\"\n+\tthen\n+\t\techo \"[OOPS] init failed but lib file was molested\"\n+\t\tfalse\n+\telse\n+\t\trm lib\n+\tfi\n+'\n+\n+test_expect_success 'init should fail when path is used by a nonempty directory' '\n+\tmkdir lib &&\n+\techo \"hello\" >lib/a &&\n+\tif git-submodule init\n+\tthen\n+\t\techo \"[OOPS] init should have failed\"\n+\t\tfalse\n+\telif test \"$(cat lib/a)\" != \"hello\"\n+\tthen\n+\t\techo \"[OOPS] init failed but lib/a was molested\"\n+\t\tfalse\n+\telse\n+\t\trm lib/a\n+\tfi\n+'\n+\n+test_expect_success 'init should work when path is an empty dir' '\n+\trm -rf lib &&\n+\tmkdir lib &&\n+\tgit-submodule init &&\n+\thead=$(cd lib && 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+\n+test_expect_success 'status should be \"up-to-date\" after init' '\n+\tgit-submodule status | grep \"^ $rev1\"\n+'\n+\n+test_expect_success 'status should be \"modified\" after submodule commit' '\n+\tcd lib &&\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+'\n+\n+test_expect_success 'the --cached sha1 should be rev1' '\n+\tgit-submodule --cached status | grep \"^\\+$rev1\"\n+'\n+\n+test_expect_success 'update should checkout rev1' '\n+\tgit-submodule update &&\n+\thead=$(cd lib && 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+'\n+\n+test_expect_success 'status should be \"up-to-date\" after update' '\n+\tgit-submodule status | grep \"^ $rev1\"\n+'\n+\n+test_done\n-- \n1.5.2.839.ga3b1-dirty\n"},{"id":"43753","messageId":"7vmyzjzc76.fsf@assigned-by-dhcp.cox.net","threadId":"8337","inReplyTo":"op.ts8g4dsa9pspc6@localhost","subject":"Re: [PATCH] Add basic test-script for git-submodule","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-06-01T19:50:21Z","receivedAt":"2007-06-01T19:50:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n> This test tries to verify basic sanity of git-submodule, i.e. that it is\n> able to clone and update a submodule repository, that its status output is\n> sane, and that it barfs when the submodule path is occupied during init.\n>\n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n\nMicronit...\n\n> +test_expect_success 'the --cached sha1 should be rev1' '\n> +\tgit-submodule --cached status | grep \"^\\+$rev1\"\n> +'\n\nWhat's the purpose of that solitary backslash?\n"},{"id":"43778","messageId":"1180747662110-git-send-email-hjemli@gmail.com","threadId":"8337","inReplyTo":"7vmyzjzc76.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Add basic test-script for git-submodule","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-06-02T01:27:42Z","receivedAt":"2007-06-02T01:27:42Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This test tries to verify basic sanity of git-submodule, i.e. that it is\nable to clone and update a submodule repository, that its status output is\nsane, and that it barfs when the submodule path is occupied during init.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nOn 6/1/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Lars Hjemli\" <hjemli@gmail.com> writes:\n> > +test_expect_success 'the --cached sha1 should be rev1' '\n> > +     git-submodule --cached status | grep \"^\\+$rev1\"\n> > +'\n> \n> What's the purpose of that solitary backslash?\n\nThat's just a sign of me being sloppy, expecting the behaviour of 'grep -E' without\nbothering to study the man-page. Sorry.\n\n\n t/t7400-submodule-basic.sh |  143 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 143 insertions(+), 0 deletions(-)\n create mode 100755 t/t7400-submodule-basic.sh\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nnew file mode 100755\nindex 0000000..6274729\n--- /dev/null\n+++ b/t/t7400-submodule-basic.sh\n@@ -0,0 +1,143 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Lars Hjemli\n+#\n+\n+test_description='Basic porcelain support for submodules\n+\n+This test tries to verify basic sanity of the init, update and status\n+subcommands of git-submodule.\n+'\n+\n+. ./test-lib.sh\n+\n+#\n+# Test setup:\n+#  -create a repository in directory lib\n+#  -add a couple of files\n+#  -add directory lib to 'superproject', this creates a DIRLINK entry\n+#  -add a couple of regular files to enable testing of submodule filtering\n+#  -mv lib subrepo\n+#  -add an entry to .gitmodules for path 'lib'\n+#\n+test_expect_success 'Prepare submodule testing' '\n+\tmkdir lib &&\n+\tcd lib &&\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+\techo a >a &&\n+\techo z >z &&\n+\tgit-add a lib z &&\n+\tgit-commit -m \"super commit 1\" &&\n+\tmv lib .subrepo &&\n+\tGIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo\n+'\n+\n+test_expect_success 'status should only print one line' '\n+\tlines=$(git-submodule status | wc -l) &&\n+\ttest $lines = 1\n+'\n+\n+test_expect_success 'status should initially be \"missing\"' '\n+\tgit-submodule status | grep \"^-$rev1\"\n+'\n+\n+test_expect_success 'init should fail when path is used by a file' '\n+\techo \"hello\" >lib &&\n+\tif git-submodule init\n+\tthen\n+\t\techo \"[OOPS] init should have failed\"\n+\t\tfalse\n+\telif test -f lib && test \"$(cat lib)\" != \"hello\"\n+\tthen\n+\t\techo \"[OOPS] init failed but lib file was molested\"\n+\t\tfalse\n+\telse\n+\t\trm lib\n+\tfi\n+'\n+\n+test_expect_success 'init should fail when path is used by a nonempty directory' '\n+\tmkdir lib &&\n+\techo \"hello\" >lib/a &&\n+\tif git-submodule init\n+\tthen\n+\t\techo \"[OOPS] init should have failed\"\n+\t\tfalse\n+\telif test \"$(cat lib/a)\" != \"hello\"\n+\tthen\n+\t\techo \"[OOPS] init failed but lib/a was molested\"\n+\t\tfalse\n+\telse\n+\t\trm lib/a\n+\tfi\n+'\n+\n+test_expect_success 'init should work when path is an empty dir' '\n+\trm -rf lib &&\n+\tmkdir lib &&\n+\tgit-submodule init &&\n+\thead=$(cd lib && 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+\n+test_expect_success 'status should be \"up-to-date\" after init' '\n+\tgit-submodule status | grep \"^ $rev1\"\n+'\n+\n+test_expect_success 'status should be \"modified\" after submodule commit' '\n+\tcd lib &&\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+'\n+\n+test_expect_success 'the --cached sha1 should be rev1' '\n+\tgit-submodule --cached status | grep \"^+$rev1\"\n+'\n+\n+test_expect_success 'update should checkout rev1' '\n+\tgit-submodule update &&\n+\thead=$(cd lib && 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+'\n+\n+test_expect_success 'status should be \"up-to-date\" after update' '\n+\tgit-submodule status | grep \"^ $rev1\"\n+'\n+\n+test_done\n-- \n1.5.2.839.ga3b1-dirty\n"}]}