t7400: split setup into multiple tests
The setup in t7400-submodule-basic does a number of different things to support different tests. Splitting it up makes the test a little easier to read and should provide an opportunity to move each piece of setup closer to the tests that require it. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							b9aa901856
						
					
				
				
					commit
					fe454b1315
				
			@ -11,40 +11,42 @@ subcommands of git submodule.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
. ./test-lib.sh
 | 
					. ./test-lib.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					test_expect_success 'setup - initial commit' '
 | 
				
			||||||
# Test setup:
 | 
						>t &&
 | 
				
			||||||
#  -create a repository in directory init
 | 
					 | 
				
			||||||
#  -add a couple of files
 | 
					 | 
				
			||||||
#  -add directory init to 'superproject', this creates a DIRLINK entry
 | 
					 | 
				
			||||||
#  -add a couple of regular files to enable testing of submodule filtering
 | 
					 | 
				
			||||||
#  -mv init subrepo
 | 
					 | 
				
			||||||
#  -add an entry to .gitmodules for submodule 'example'
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
test_expect_success 'Prepare submodule testing' '
 | 
					 | 
				
			||||||
	: > t &&
 | 
					 | 
				
			||||||
	git add t &&
 | 
						git add t &&
 | 
				
			||||||
	git commit -m "initial commit" &&
 | 
						git commit -m "initial commit" &&
 | 
				
			||||||
	git branch initial HEAD &&
 | 
						git branch initial
 | 
				
			||||||
 | 
					'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test_expect_success 'setup - repository in init subdirectory' '
 | 
				
			||||||
	mkdir init &&
 | 
						mkdir init &&
 | 
				
			||||||
 | 
						(
 | 
				
			||||||
		cd init &&
 | 
							cd init &&
 | 
				
			||||||
		git init &&
 | 
							git init &&
 | 
				
			||||||
		echo a >a &&
 | 
							echo a >a &&
 | 
				
			||||||
		git add a &&
 | 
							git add a &&
 | 
				
			||||||
		git commit -m "submodule commit 1" &&
 | 
							git commit -m "submodule commit 1" &&
 | 
				
			||||||
	git tag -a -m "rev-1" rev-1 &&
 | 
							git tag -a -m "rev-1" rev-1
 | 
				
			||||||
	rev1=$(git rev-parse HEAD) &&
 | 
						)
 | 
				
			||||||
	if test -z "$rev1"
 | 
						rev1=$(cd init && git rev-parse HEAD) &&
 | 
				
			||||||
	then
 | 
						printf "rev1: %s\n" "$rev1" &&
 | 
				
			||||||
		echo "[OOPS] submodule git rev-parse returned nothing"
 | 
						test -n "$rev1"
 | 
				
			||||||
		false
 | 
					'
 | 
				
			||||||
	fi &&
 | 
					
 | 
				
			||||||
	cd .. &&
 | 
					test_expect_success 'setup - commit with gitlink' '
 | 
				
			||||||
	echo a >a &&
 | 
						echo a >a &&
 | 
				
			||||||
	echo z >z &&
 | 
						echo z >z &&
 | 
				
			||||||
	git add a init z &&
 | 
						git add a init z &&
 | 
				
			||||||
	git commit -m "super commit 1" &&
 | 
						git commit -m "super commit 1"
 | 
				
			||||||
	mv init .subrepo &&
 | 
					'
 | 
				
			||||||
	GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
 | 
					
 | 
				
			||||||
 | 
					test_expect_success 'setup - hide init subdirectory' '
 | 
				
			||||||
 | 
						mv init .subrepo
 | 
				
			||||||
 | 
					'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test_expect_success 'setup - add an example entry to .gitmodules' '
 | 
				
			||||||
 | 
						GIT_CONFIG=.gitmodules \
 | 
				
			||||||
 | 
						git config submodule.example.url git://example.com/init.git
 | 
				
			||||||
'
 | 
					'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_expect_success 'Prepare submodule add testing' '
 | 
					test_expect_success 'Prepare submodule add testing' '
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user