login
Header Space

 
 

[PATCH] new test from the submodule chapter of the user manual

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: <git@...>, Johannes Schindelin <Johannes.Schindelin@...>, J. Bruce Fields <bfields@...>
Date: Saturday, September 22, 2007 - 4:05 pm

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

On Fri, Sep 21, 2007 at 11:04:05AM -0700, Junio C Hamano <gitster@pobox.com> wrote:

okay, here is the third try. now checking for the result using diff-tree and
ls-files. hopefully i did what you expected :)

 t/t3060-subprojects-tutorial.sh |   95 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100755 t/t3060-subprojects-tutorial.sh

diff --git a/t/t3060-subprojects-tutorial.sh b/t/t3060-subprojects-tutorial.sh
new file mode 100755
index 0000000..d46dded
--- /dev/null
+++ b/t/t3060-subprojects-tutorial.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Miklos Vajna
+#
+
+test_description='A simple subprojects tutorial in the form of a test case'
+
+. ./test-lib.sh
+
+test_expect_success "create the submodules" '
+	for i in a b c d
+	do
+		mkdir $i &&
+		cd $i &&
+		git init &&
+		echo "module $i" > $i.txt &&
+		git add $i.txt &&
+		git commit -m "Initial commit, submodule $i" &&
+		cd ..
+	done
+'
+
+mkdir super
+cd super
+cat >expected << EOF
+:000000 100644 00000... A	.gitmodules
+:000000 160000 00000... A	a
+:000000 160000 00000... A	b
+:000000 160000 00000... A	c
+:000000 160000 00000... A	d
+EOF
+
+test_expect_success "create the superproject" '
+	git init &&
+	echo super > super.txt &&
+	git add super.txt &&
+	git commit -m "initial" &&
+	for i in a b c d
+	do
+		git submodule add '`pwd`'/../$i
+	done &&
+	git commit -m "Add submodules a, b, c and d." &&
+	git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
+	cmp expected current
+'
+
+test_expect_success "checking if the correct commit is stored in the superproject" '
+	for i in a b c d
+	do
+		git ls-files -s $i|cut -d " " -f 2 > $i.actual &&
+		(cd $i && git-rev-parse HEAD) > $i.expected &&
+		cmp $i.actual $i.expected
+	done &&
+	cd ..
+'
+
+test_expect_success "clone the superproject" '
+	git clone super cloned &&
+	cd cloned
+'
+
+test_expect_success "submodule init" '
+	git submodule init
+'
+
+test_expect_success "submodule update" '
+	git submodule update
+'
+
+test_expect_success "checking the result of the commit in the cloned project" '
+	for i in a b c d
+	do
+		git ls-files -s $i|cut -d " " -f 2 > $i.actual &&
+		(cd $i && git-rev-parse HEAD) > $i.expected &&
+		cmp $i.actual $i.expected
+	done
+'
+
+test_expect_success "update the submodule from within the superproject" '
+	cd a &&
+	echo "adding a line again" >> a.txt &&
+	git commit -a -m "Updated the submodule from within the superproject." &&
+	git push &&
+	cd .. &&
+	git add a &&
+	git commit -m "Updated submodule a." &&
+	git push
+'
+
+test_expect_success "checking the result of the commit in the updated cloned project" '
+	git ls-files -s a|cut -d " " -f 2 > a.actual &&
+	(cd a && git-rev-parse HEAD) > a.expected &&
+	cmp a.actual a.expected
+'
+test_done
-- 
1.5.3.2.80.g077d6f-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[rfc] git submodules howto, Miklos Vajna, (Tue Sep 18, 6:55 am)
Re: [rfc] git submodules howto, Uwe , (Mon Sep 24, 3:11 am)
Re: [rfc] git submodules howto, Miklos Vajna, (Mon Sep 24, 4:30 am)
Re: [rfc] git submodules howto, J. Bruce Fields, (Tue Sep 18, 9:29 am)
Re: [rfc] git submodules howto, Miklos Vajna, (Tue Sep 18, 11:47 am)
Re: [rfc] git submodules howto, J. Bruce Fields, (Tue Sep 18, 11:55 am)
Re: [rfc] git submodules howto, Miklos Vajna, (Tue Sep 18, 12:11 pm)
Re: [rfc] git submodules howto, Michael Smith, (Tue Sep 18, 2:12 pm)
[PATCH] User Manual: add a chapter for submodules, Miklos Vajna, (Wed Sep 19, 1:42 pm)
Re: [PATCH] User Manual: add a chapter for submodules, Sven Verdoolaege, (Wed Sep 19, 5:00 pm)
Re: [PATCH] User Manual: add a chapter for submodules, Junio C Hamano, (Wed Sep 19, 3:44 pm)
[PATCH] User Manual: add a chapter for submodules, Miklos Vajna, (Wed Sep 19, 8:34 pm)
Re: [PATCH] User Manual: add a chapter for submodules, Junio C Hamano, (Thu Sep 20, 12:15 am)
Re: [PATCH] User Manual: add a chapter for submodules, Miklos Vajna, (Thu Sep 20, 6:02 pm)
Re: [PATCH] User Manual: add a chapter for submodules, Johannes Schindelin, (Thu Sep 20, 6:34 am)
[PATCH] new test from the submodule chapter of the user manual, Miklos Vajna, (Sat Sep 22, 4:05 pm)
Re: [PATCH] new test from the submodule chapter of the user ..., Johannes Schindelin, (Thu Sep 20, 2:47 pm)
[PATCH] User Manual: add a chapter for submodules, Miklos Vajna, (Wed Sep 19, 8:01 pm)
Re: [PATCH] User Manual: add a chapter for submodules, J. Bruce Fields, (Wed Sep 19, 4:30 pm)
Re: [rfc] git submodules howto, Michael Smith, (Tue Sep 18, 8:10 am)
Re: [rfc] git submodules howto, Johannes Schindelin, (Tue Sep 18, 8:03 am)
speck-geostationary