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

!MAILaRCHIVE_VOTE_RePLACE
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: Friday, September 21, 2007 - 9:09 am

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

second version, now checking for all output, the commit hashes shows what is
committed is what we wanted to commit.

 t/t3060-subprojects-tutorial.sh |  151 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 151 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..fc09451
--- /dev/null
+++ b/t/t3060-subprojects-tutorial.sh
@@ -0,0 +1,151 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Miklos Vajna
+#
+
+test_description='A simple subprojects tutorial in the form of a test case'
+
+. ./test-lib.sh
+
+test_tick
+
+cat > create.expect << EOF
+Initialized empty Git repository in .git/
+Created initial commit 85349d2: Initial commit, submodule a
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ create mode 100644 a.txt
+Initialized empty Git repository in .git/
+Created initial commit 47398d6: Initial commit, submodule b
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ create mode 100644 b.txt
+Initialized empty Git repository in .git/
+Created initial commit 3d88526: Initial commit, submodule c
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ create mode 100644 c.txt
+Initialized empty Git repository in .git/
+Created initial commit 73af3de: Initial commit, submodule d
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ create mode 100644 d.txt
+EOF
+
+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 > create.output
+test_expect_success "create the submodules" 'cmp create.expect create.output'
+
+mkdir super
+cd super
+cat > create-super.expect << EOF
+Initialized empty Git repository in .git/
+Initialized empty Git repository in `pwd`/a/.git/
+0 blocks
+Initialized empty Git repository in `pwd`/b/.git/
+0 blocks
+Initialized empty Git repository in `pwd`/c/.git/
+0 blocks
+Initialized empty Git repository in `pwd`/d/.git/
+0 blocks
+EOF
+
+(git init &&
+for i in a b c d
+do
+	git submodule add `pwd`/../$i
+done ) &> create-super.output
+test_expect_success "create the superproject" 'cmp create-super.expect create-super.output'
+
+cat > commit-superproject.expect << EOF
+Created initial commit c496be9: Add submodules a, b, c and d.
+ 5 files changed, 16 insertions(+), 0 deletions(-)
+ create mode 100644 .gitmodules
+ create mode 160000 a
+ create mode 160000 b
+ create mode 160000 c
+ create mode 160000 d
+EOF
+git commit -m "Add submodules a, b, c and d." > commit-superproject.output
+
+test_expect_success "commit in the superproject" 'cmp commit-superproject.expect commit-superproject.output'
+
+cd ..
+
+cat > clone.expect << EOF
+Initialized empty Git repository in `pwd`/cloned/.git/
+0 blocks
+EOF
+
+git clone super cloned &> clone.output
+
+test_expect_success "clone the superproject" 'cmp clone.expect clone.output'
+
+cd cloned
+
+cat > submodule-init.expect << EOF
+Submodule 'a' (${PWD%%/cloned}/a/.git) registered for path 'a'
+Submodule 'b' (${PWD%%/cloned}/b/.git) registered for path 'b'
+Submodule 'c' (${PWD%%/cloned}/c/.git) registered for path 'c'
+Submodule 'd' (${PWD%%/cloned}/d/.git) registered for path 'd'
+EOF
+
+git submodule init > submodule-init.output
+
+test_expect_success "submodule init" 'cmp submodule-init.expect submodule-init.output'
+
+cat > submodule-update.expect << EOF
+Initialized empty Git repository in `pwd`/a/.git/
+0 blocks
+Submodule path 'a': checked out '85349d24595f581f5548b321a55c8a5fbe87259f'
+Initialized empty Git repository in `pwd`/b/.git/
+0 blocks
+Submodule path 'b': checked out '47398d6286153d23bfd5780ae3bf1996eb18cf90'
+Initialized empty Git repository in `pwd`/c/.git/
+0 blocks
+Submodule path 'c': checked out '3d88526ff6973dd27a07f57a3bb2bf5fa0bada42'
+Initialized empty Git repository in `pwd`/d/.git/
+0 blocks
+Submodule path 'd': checked out '73af3de6718291404ef541f4bb152f87d35a1481'
+EOF
+
+git submodule update &> submodule-update.output
+
+test_expect_success "submodule update" 'cmp submodule-update.expect submodule-update.output'
+
+cat > submodule-push.expect << EOF
+Created commit ab78b5a: Updated the submodule from within the superproject.
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+Everything up-to-date
+Created commit 8bbfffe: Updated submodule a.
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+updating 'refs/heads/master'
+  from c496be9e726d5c6ee0f96668b1b5822cf6cad027
+  to   8bbfffe1651b896e371bf7a3506452d545cf81b3
+ Also local refs/remotes/origin/master
+Generating pack...
+Done counting 2 objects.
+Deltifying 2 objects...
+  50% (1/2) done
 100% (2/2) done

+Writing 2 objects...
+  50% (1/2) done
 100% (2/2) done

+Total 2 (delta 0), reused 0 (delta 0)
+refs/heads/master: c496be9e726d5c6ee0f96668b1b5822cf6cad027 -> 8bbfffe1651b896e371bf7a3506452d545cf81b3
+EOF
+
+( 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) &> submodule-push.output
+
+test_expect_success "update the submodule from within the superproject" 'cmp submodule-push.expect submodule-push.output'
+
+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, (Fri Sep 21, 9:09 am)
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)