Skip to contentSkip to conversation

Two tests for rr/fmt-merge-msg

PATCH In review Ramkumar Ramachandra 2 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover Two tests for rr/fmt-merge-msg

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(-)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#1 lore raw

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.

---
 t/t6200-fmt-merge-msg.sh |   55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
t/t6200-fmt-merge-msg.sh +55 -0
index 71f6cad..750568e 100755
@@ -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 &&
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#2 lore raw

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

Hi,

Quoted 1 line · Ramkumar Ramachandra

Add a test to exercise the 'merge.log' configuration option

Thanks!

Quoted 1 line

+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

#3 lore raw

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

Quoted 15 lines · Jonathan Nieder

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.

Quoted 10 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*

#4 lore raw

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

In reply to Jonathan Nieder

Hi Jonathan,

Quoted 2 lines · Jonathan Nieder

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.

Quoted 9 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.

Quoted 3 lines
	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.

Quoted 9 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?

Quoted 3 lines
	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.

Quoted 3 lines
	test_expect_success 'merge.log=5 does not limit shortlog length' '
		[...]
	'

Okay.

Quoted 3 lines
	test_expect_success 'merge.log=6 does not limit shortlog length' '
		[...]
	'

I thought this was a bit of an overkill, so I removed it.

Quoted 3 lines
	test_expect_success 'merge.log=0 disables shortlog' '
		[...]
	'

Okay.

Quoted 3 lines
	test_expect_success 'merge.log=-1 does something sane' '
		[...]
	'

Thanks! I found a bug and fixed it (patch will come in a moment).

Quoted 1 line

I can clean up the earlier tests afterwards. :)

Okay, sounds good.

-- Ram

#5 lore raw

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

Quoted 8 lines · Ramkumar Ramachandra
Quoted 6 lines · Jonathan Nieder
		cat >expected <<-\EOF &&
		  Left #3
		  ...
		EOF
		git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >msg &&
Quoted 6 lines
Quoted 3 lines
		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

#6 lore raw

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

In reply to Ramkumar Ramachandra

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.

---
 t/t6200-fmt-merge-msg.sh |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
t/t6200-fmt-merge-msg.sh +56 -0
index 750568e..b308c3b 100755
@@ -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 &&
Signature · 1 line
1.7.2.2.409.gdbb11.dirty