t7507-commit-verbose: improve test coverage by testing number of diffs
Make the fake "editor" store output of grep in a file so that we can see how many diffs were contained in the message and use them in individual tests where ever it is required. A subsequent commit will introduce scenarios where it is important to be able to exactly determine how many diffs were present. The fake "editor" is always made to succeed regardless of whether grep found diff headers or not so that we don't have to use 'test_must_fail' for which 'test_line_count = 0' is an easy substitute and also helps in maintaining the consistency. Also use write_script() to create the fake "editor". Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		 Pranit Bauva
					Pranit Bauva
				
			
				
					committed by
					
						 Junio C Hamano
						Junio C Hamano
					
				
			
			
				
	
			
			
			 Junio C Hamano
						Junio C Hamano
					
				
			
						parent
						
							e0070e8bd5
						
					
				
				
					commit
					de45dbb818
				
			| @ -3,11 +3,10 @@ | |||||||
| test_description='verbose commit template' | test_description='verbose commit template' | ||||||
| . ./test-lib.sh | . ./test-lib.sh | ||||||
|  |  | ||||||
| cat >check-for-diff <<EOF | write_script "check-for-diff" <<\EOF && | ||||||
| #!$SHELL_PATH | grep '^diff --git' "$1" >out | ||||||
| exec grep '^diff --git' "\$1" | exit 0 | ||||||
| EOF | EOF | ||||||
| chmod +x check-for-diff |  | ||||||
| test_set_editor "$PWD/check-for-diff" | test_set_editor "$PWD/check-for-diff" | ||||||
|  |  | ||||||
| cat >message <<'EOF' | cat >message <<'EOF' | ||||||
| @ -23,7 +22,8 @@ test_expect_success 'setup' ' | |||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'initial commit shows verbose diff' ' | test_expect_success 'initial commit shows verbose diff' ' | ||||||
| 	git commit --amend -v | 	git commit --amend -v && | ||||||
|  | 	test_line_count = 1 out | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'second commit' ' | test_expect_success 'second commit' ' | ||||||
| @ -39,13 +39,15 @@ check_message() { | |||||||
|  |  | ||||||
| test_expect_success 'verbose diff is stripped out' ' | test_expect_success 'verbose diff is stripped out' ' | ||||||
| 	git commit --amend -v && | 	git commit --amend -v && | ||||||
| 	check_message message | 	check_message message && | ||||||
|  | 	test_line_count = 1 out | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'verbose diff is stripped out (mnemonicprefix)' ' | test_expect_success 'verbose diff is stripped out (mnemonicprefix)' ' | ||||||
| 	git config diff.mnemonicprefix true && | 	git config diff.mnemonicprefix true && | ||||||
| 	git commit --amend -v && | 	git commit --amend -v && | ||||||
| 	check_message message | 	check_message message && | ||||||
|  | 	test_line_count = 1 out | ||||||
| ' | ' | ||||||
|  |  | ||||||
| cat >diff <<'EOF' | cat >diff <<'EOF' | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user