git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Hjemli <hjemli@gmail.com>
To: Junio C Hamano <junkio@cox.net>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: [PATCH] Add basic test-script for git-submodule
Date: Sun, 27 May 2007 22:34:59 +0200	[thread overview]
Message-ID: <11802980992216-git-send-email-hjemli@gmail.com> (raw)

This test verifies the basic operations in git-submodule, i.e. that it is
able to clone and update a submodule repository, that its status output is
sane, and that it errors out when the submodule path is occupied during
init.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---

Finally the test-script emerges. Btw, thanks for fixing my broken submodule
patch :)

 t/t7400-submodule-basic.sh |   82 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)
 create mode 100755 t/t7400-submodule-basic.sh

diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
new file mode 100755
index 0000000..2212b29
--- /dev/null
+++ b/t/t7400-submodule-basic.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Lars Hjemli
+#
+
+test_description='Basic submodule support in porcelain
+
+This test tries to run the init, update and status commands of git-submodule
+with a known good setup (and two known bad)
+'
+
+. ./test-lib.sh
+
+
+# create a submodule repository
+mkdir lib && cd lib
+git-init >/dev/null
+echo a >a && git-add a && git-commit -q -m "submodule commit 1"
+git-tag -a -m "rev-1" rev-1
+rev1=$(git-rev-parse HEAD)
+cd ..
+
+# add submodule and other files to super repo
+echo a >a && echo z >z
+git-add a lib z && git-commit -q -m "super commit 1"
+
+# move submodule to another location, register repo url in .gitmodules
+mv lib .subrepo
+GIT_CONFIG=.gitmodules git-config module.lib.url ./.subrepo
+
+test_expect_success 'status is "missing"' \
+	'git-submodule status | grep "^-$rev1"'
+
+# make sure 'init' will not overwrite a regular file
+touch lib
+test_expect_failure 'init fails when path is used by a file' \
+	'git-submodule init'
+
+# make sure 'init' will not overwrite a nonempty directory
+rm lib
+mkdir -p lib/foo
+test_expect_failure 'init fails when path is used by a nonempty directory' \
+	'git-submodule init'
+
+# turn lib into an empty directory, just like git-checkout would do
+rmdir lib/foo
+test_expect_success 'init works when path is an empty dir' \
+	'git-submodule init && test -d lib/.git && git-diff --exit-code'
+
+head=$(cd lib && git-rev-parse HEAD)
+test_expect_success 'submodule HEAD should match rev1' \
+	'test "$head" = "$rev1"'
+
+test_expect_success 'status is "up-to-date" after init' \
+	'git-submodule status | grep "^ $rev1"'
+
+# change the submodule HEAD
+cd lib
+echo b >b && git-add b && git-commit -q -m "submodule commit 2"
+rev2=$(git-rev-parse HEAD)
+cd ..
+
+test_expect_success 'status is "modified" after submodule commit' \
+	'git-submodule status | grep "^\+$rev2"'
+
+test_expect_success 'the --cached sha1 should be rev1' \
+	'git-submodule --cached status | grep "^\+$rev1"'
+
+test_expect_failure 'git-diff --exit-code reports local modifications' \
+	'git-diff --exit-code'
+
+test_expect_success 'update should checkout the correct commit' \
+	'git-submodule update && git-diff --exit-code'
+
+head=$(cd lib && git-rev-parse HEAD)
+test_expect_success 'submodule HEAD should match rev1' \
+	'test "$head" = "$rev1"'
+
+test_expect_success 'status is "up-to-date" after update' \
+	'git-submodule status | grep "^ $rev1"'
+
+test_done
-- 
1.5.2.74.g6b2d

             reply	other threads:[~2007-05-27 20:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 20:34 Lars Hjemli [this message]
2007-05-29  7:10 ` [PATCH] Add basic test-script for git-submodule Junio C Hamano
2007-05-30  6:48   ` Lars Hjemli
2007-06-01  3:54     ` Junio C Hamano
2007-06-01  7:10       ` Lars Hjemli
2007-06-01  7:56         ` Johannes Sixt
2007-06-01  8:13           ` Lars Hjemli
2007-06-01 19:50             ` Junio C Hamano
2007-06-02  1:27               ` Lars Hjemli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11802980992216-git-send-email-hjemli@gmail.com \
    --to=hjemli@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).