threads / patch / 24887

patch, 2 partsTwo tests for rr/fmt-merge-msg

Subject: [PATCH 0/2] Two tests for rr/fmt-merge-msg

## tl;dr

7 messages between Aug 27, 2010 and Aug 28, 2010. Diffs are folded; open one to read it.

replies: 6people: 2as markdown or json

Ramkumar Ramachandra· Aug 27, 2010, 14:14 UTC · lore
These tests exercise the feature in rr/fmt-merge-msg.
Ramkumar Ramachandra (2):
  t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog
    length
  t6200-fmt-merge-msg: Exercise '--log' to configure shortlog length
 t/t6200-fmt-merge-msg.sh |  111 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 111 insertions(+), 0 deletions(-)
-- 
1.7.2.2.409.gdbb11.dirty
Ramkumar Ramachandra· Aug 27, 2010, 14:14 UTC · re: Ramkumar Ramachandra · lore

[PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length

Add a test to exercise the 'merge.log' configuration option of 'git fmt-merge-msg'. It controls the number of shortlog entries to display in merge commit messages.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t6200-fmt-merge-msg.sh |   55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
Show changes to t/t6200-fmt-merge-msg.sh +55 −0
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 71f6cad..750568e 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -129,6 +129,61 @@ test_expect_success '[merge] summary/log configuration' '
 	test_cmp expected actual2
 '
 
+test_expect_success 'configurable shortlog length: merge.log' '
+	cat >expected_a <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left: (5 commits)
+	  Left #5
+	  Left #4
+	  Left #3
+	  ...
+	EOF
+
+	git config merge.log 3 &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
+
+	test_might_fail git config --unset-all merge.log &&
+	git config merge.summary 3 &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
+
+	echo "Merge branch ${apos}left${apos}" >expected_b &&
+
+	git config merge.log 0 &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
+
+	test_cmp expected_a actual1 &&
+	test_cmp expected_a actual2 &&
+	test_cmp expected_b actual3 &&
+	test_cmp expected_b actual4
+'
+
 test_expect_success 'fmt-merge-msg -m' '
 	echo "Sync with left" >expected &&
 	cat >expected.log <<-EOF &&
-- 
1.7.2.2.409.gdbb11.dirty
Jonathan Nieder· Aug 28, 2010, 02:00 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length

Hi,
Ramkumar Ramachandra wrote:
> Add a test to exercise the 'merge.log' configuration option
Thanks!
> +test_expect_success 'configurable shortlog length: merge.log' '

I suspect this test would be easier to understand if split up (yes, I know I'm guilty of the same in other tests from this file).

Maybe something like this?
	test_expect_success 'setup: clear [merge] configuration' '
		test_might_fail git config --unset-all merge.log &&
		test_might_fail git config --unset-all merge.summary
	'
	test_expect_success 'set up FETCH_HEAD' '
		git checkout master &&
		git fetch . left
	'
	test_expect_success 'merge.log=3 limits shortlog length' '
		test_might_fail git config --unset merge.log &&
		test_might_fail git config --unset merge.summary &&
		cat >expected <<-\EOF &&
		  Left #3
		  ...
		EOF
		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
		tail -n 2 msg >actual &&
		test_cmp expected actual
	'
	test_expect_success 'shortlog length defaults to 20' '
		[...]
	'
	test_expect_success 'merge.log=5 does not limit shortlog length' '
		[...]
	'
	test_expect_success 'merge.log=6 does not limit shortlog length' '
		[...]
	'
	test_expect_success 'merge.log=0 disables shortlog' '
		[...]
	'
	test_expect_success 'merge.log=-1 does something sane' '
		[...]
	'

I can clean up the earlier tests afterwards. :) Jonathan

Jonathan Nieder· Aug 28, 2010, 02:05 UTC · re: Jonathan Nieder · lore

Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length

Jonathan Nieder wrote:
Show 15 quoted lines
> Maybe something like this?
> 
> 	test_expect_success 'setup: clear [merge] configuration' '
> 		test_might_fail git config --unset-all merge.log &&
> 		test_might_fail git config --unset-all merge.summary
> 	'
> 
> 	test_expect_success 'set up FETCH_HEAD' '
> 		git checkout master &&
> 		git fetch . left
> 	'
> 
> 	test_expect_success 'merge.log=3 limits shortlog length' '
> 		test_might_fail git config --unset merge.log &&
> 		test_might_fail git config --unset merge.summary &&

Erm, these two lines wouldn't be necessary given the earlier setup, of course.

Show 10 quoted lines
> 
> 		cat >expected <<-\EOF &&
> 		  Left #3
> 		  ...
> 		EOF
> 		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
> 
> 		tail -n 2 msg >actual &&
> 		test_cmp expected actual
> 	'
Sorry for the noise.
*goes off to sleep*
Ramkumar Ramachandra· Aug 28, 2010, 10:35 UTC · re: Jonathan Nieder · lore

Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length

Hi Jonathan,
Jonathan Nieder writes:
> I suspect this test would be easier to understand if split up (yes, I
> know I'm guilty of the same in other tests from this file).

I sort of tried to follow what was done in the rest of the file. If this style is desired instead, I'll post an alternative series instead.

Show 9 quoted lines
> 	test_expect_success 'setup: clear [merge] configuration' '
> 		test_might_fail git config --unset-all merge.log &&
> 		test_might_fail git config --unset-all merge.summary
> 	'
> 
> 	test_expect_success 'set up FETCH_HEAD' '
> 		git checkout master &&
> 		git fetch . left
> 	'
Okay.
> 	test_expect_success 'merge.log=3 limits shortlog length' '
> 		test_might_fail git config --unset merge.log &&
> 		test_might_fail git config --unset merge.summary &&
Redundant, as you pointed out in another email.
Show 9 quoted lines
> 		cat >expected <<-\EOF &&
> 		  Left #3
> 		  ...
> 		EOF
> 		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
> 
> 		tail -n 2 msg >actual &&
> 		test_cmp expected actual
> 	'

Ok. I don't like the `tail` thing. Why are you doing it instead of comparing full outputs like the tests in the rest of the file?

> 	test_expect_success 'shortlog length defaults to 20' '
> 		[...]
> 	'

Actually, we can't test this unless we actually create a branch with 20 commits and merge it. I've dropped this- you might like to add it during the cleanup.

> 	test_expect_success 'merge.log=5 does not limit shortlog length' '
> 		[...]
> 	'
Okay.
> 	test_expect_success 'merge.log=6 does not limit shortlog length' '
> 		[...]
> 	'
I thought this was a bit of an overkill, so I removed it.
> 	test_expect_success 'merge.log=0 disables shortlog' '
> 		[...]
> 	'
Okay.
> 	test_expect_success 'merge.log=-1 does something sane' '
> 		[...]
> 	'
Thanks! I found a bug and fixed it (patch will come in a moment).
> I can clean up the earlier tests afterwards. :)
Okay, sounds good.
-- Ram
Jonathan Nieder· Aug 28, 2010, 17:09 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH 1/2] t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length

Ramkumar Ramachandra wrote:
> Jonathan Nieder writes:
Show 12 quoted lines
>> 		cat >expected <<-\EOF &&
>> 		  Left #3
>> 		  ...
>> 		EOF
>> 		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
>> 
>> 		tail -n 2 msg >actual &&
>> 		test_cmp expected actual
>> 	'
>
> Ok. I don't like the `tail` thing. Why are you doing it instead of
> comparing full outputs like the tests in the rest of the file?
No good reason. :)

Thanks, Jonathan

Ramkumar Ramachandra· Aug 27, 2010, 14:14 UTC · re: Ramkumar Ramachandra · lore

[PATCH 2/2] t6200-fmt-merge-msg: Exercise '--log' to configure shortlog length

Add a test to exercise the '--log' command-line option of 'git fmt-merge-msg'. It controls the number of shortlog entries to display in merge commit messages.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t6200-fmt-merge-msg.sh |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
Show changes to t/t6200-fmt-merge-msg.sh +56 −0
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 750568e..b308c3b 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -184,6 +184,62 @@ test_expect_success 'configurable shortlog length: merge.log' '
 	test_cmp expected_b actual4
 '
 
+test_expect_success 'configurable shortlog length: --log' '
+	cat >expected1 <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left: (5 commits)
+	  Left #5
+	  Left #4
+	  Left #3
+	  ...
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual1 &&
+
+	cat >expected_b <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg --log <.git/FETCH_HEAD >actual2 &&
+
+	echo "Merge branch ${apos}left${apos}" >expected_c &&
+
+	test_might_fail git config --unset-all merge.log &&
+	test_might_fail git config --unset-all merge.summary &&
+
+	git checkout master &&
+	test_tick &&
+	git fetch . left &&
+
+	git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual3 &&
+
+	test_cmp expected_a actual1 &&
+	test_cmp expected_b actual2 &&
+	test_cmp expected_c actual3
+'
+
 test_expect_success 'fmt-merge-msg -m' '
 	echo "Sync with left" >expected &&
 	cat >expected.log <<-EOF &&
-- 
1.7.2.2.409.gdbb11.dirty

← back to recent threads