Re: [PATCH v4 27/73] gettextize: git-commit formatting messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ãvar ArnfjÃrà Bjarmason wrote:

> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -696,12 +696,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		char *ai_tmp, *ci_tmp;
>  		if (in_merge)
>  			fprintf(fp,
> -				"#\n"
> +				_("#\n"
[...]

(Everything up to and including patch 26 still looks good.)

Here's a weatherballoon patch to mark the tests affected by patch 27
as "expect failure", in case we want to go that route.  Combined with
"commit: error out for missing commit message template", it passes all
tests.

-- 8< --
Subject: i18n: update expected test results for git-commit formatting messages

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 t/lib-commit-template.sh           |   19 ++++++++
 t/t3404-rebase-interactive.sh      |    3 +-
 t/t4013-diff-various.sh            |   82 +++++++++++++++++++++++-------------
 t/t7500-commit.sh                  |   19 ++++----
 t/t7501-commit.sh                  |    9 ++--
 t/t7505-prepare-commit-msg-hook.sh |    7 ++-
 t/t7507-commit-verbose.sh          |    5 +-
 t/t7509-commit.sh                  |    3 +-
 8 files changed, 97 insertions(+), 50 deletions(-)
 create mode 100644 t/lib-commit-template.sh

diff --git a/t/lib-commit-template.sh b/t/lib-commit-template.sh
new file mode 100644
index 0000000..80ec50c
--- /dev/null
+++ b/t/lib-commit-template.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Messages such as
+#
+#      # It looks like you may be committing a MERGE.\n"
+#
+# are now translatable, even though the "# " part probably ought not
+# to be.  Expect some tests to fail when GETTEXT_POISON is enabled.
+
+if test_have_prereq C_LOCALE_OUTPUT
+then
+	test_log_messages_expect_success () {
+		test_expect_success "$@"
+	}
+else
+	test_log_messages_expect_success () {
+		test_expect_failure "$@"
+	}
+fi
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 7d8147b..84630e3 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -28,6 +28,7 @@ Initial setup:
 . ./test-lib.sh
 
 . "$TEST_DIRECTORY"/lib-rebase.sh
+. "$TEST_DIRECTORY"/lib-commit-template.sh
 
 test_cmp_rev () {
 	git rev-parse --verify "$1" >expect.rev &&
@@ -390,7 +391,7 @@ D
 ONCE
 EOF
 
-test_expect_success 'squash and fixup generate correct log messages' '
+test_log_messages_expect_success 'squash and fixup generate correct log messages' '
 	git checkout -b squash-fixup E &&
 	base=$(git rev-parse HEAD~4) &&
 	FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index b8f81d0..872c37c 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -6,6 +6,7 @@
 test_description='Various diff formatting options'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-commit-template.sh
 
 LF='
 '
@@ -95,35 +96,42 @@ test_expect_success setup '
 EOF
 
 V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
-while read cmd
-do
-	case "$cmd" in
-	'' | '#'*) continue ;;
-	esac
-	test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
-	pfx=`printf "%04d" $test_count`
-	expect="$TEST_DIRECTORY/t4013/diff.$test"
-	actual="$pfx-diff.$test"
 
-	test_expect_success "git $cmd" '
-		{
-			echo "\$ git $cmd"
-			git $cmd |
-			sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
-			    -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
-			echo "\$"
-		} >"$actual" &&
-		if test -f "$expect"
-		then
-			test_cmp "$expect" "$actual" &&
-			rm -f "$actual"
-		else
-			# this is to help developing new tests.
-			cp "$actual" "$expect"
-			false
-		fi
-	'
-done <<\EOF
+try_cmds () {
+	test_expect_expectation=${1:-test_expect_success}
+
+	while read cmd
+	do
+		case "$cmd" in
+		'' | '#'*) continue ;;
+		esac
+		test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
+		pfx=`printf "%04d" $test_count`
+		expect="$TEST_DIRECTORY/t4013/diff.$test"
+		actual="$pfx-diff.$test"
+
+		$test_expect_expectation "git $cmd" '
+			{
+				echo "\$ git $cmd"
+				git $cmd |
+				sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
+				    -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
+				echo "\$"
+			} >"$actual" &&
+			if test -f "$expect"
+			then
+				test_cmp "$expect" "$actual" &&
+				rm -f "$actual"
+			else
+				# this is to help developing new tests.
+				cp "$actual" "$expect"
+				false
+			fi
+		'
+	done
+}
+
+try_cmds <<\EOF
 diff-tree initial
 diff-tree -r initial
 diff-tree -r --abbrev initial
@@ -174,25 +182,33 @@ diff-tree --pretty --patch-with-stat side
 
 diff-tree master
 diff-tree -p master
+EOF
+try_cmds test_log_messages_expect_success <<\EOF
 diff-tree -p -m master
 diff-tree -c master
 diff-tree -c --abbrev master
-diff-tree --cc master
 # stat only should show the diffstat with the first parent
 diff-tree -c --stat master
 diff-tree --cc --stat master
 diff-tree -c --stat --summary master
 diff-tree --cc --stat --summary master
+EOF
+try_cmds <<\EOF
 # stat summary should show the diffstat and summary with the first parent
 diff-tree -c --stat --summary side
 diff-tree --cc --stat --summary side
+EOF
+try_cmds test_log_messages_expect_success <<\EOF
 # improved by Timo's patch
 diff-tree --cc --patch-with-stat master
 # improved by Timo's patch
 diff-tree --cc --patch-with-stat --summary master
+EOF
+try_cmds <<\EOF
 # this is correct
 diff-tree --cc --patch-with-stat --summary side
-
+EOF
+try_cmds test_log_messages_expect_success <<\EOF
 log master
 log -p master
 log --root master
@@ -237,14 +253,20 @@ log --patch-with-stat master -- dir/
 whatchanged --patch-with-stat master -- dir/
 log --patch-with-stat --summary master -- dir/
 whatchanged --patch-with-stat --summary master -- dir/
+EOF
+try_cmds <<\EOF
 
 show initial
 show --root initial
 show side
+EOF
+try_cmds test_log_messages_expect_success <<\EOF
 show master
 show -c master
 show -m master
 show --first-parent master
+EOF
+try_cmds <<\EOF
 show --stat side
 show --stat --summary side
 show --patch-with-stat side
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 5976f59..614d31b 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -8,6 +8,7 @@ test_description='git commit
 Tests for selected commit options.'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY/lib-commit-template.sh"
 
 commit_msg_is () {
 	expect=commit_msg_is.expect
@@ -48,7 +49,7 @@ test_expect_success 'nonexistent template file in config should return error' '
 # From now on we'll use a template file that exists.
 TEMPLATE="$PWD"/template
 
-test_expect_success 'unedited template should not commit' '
+test_log_messages_expect_success 'unedited template should not commit' '
 	echo "template line" > "$TEMPLATE" &&
 	test_must_fail git commit --template "$TEMPLATE"
 '
@@ -72,7 +73,7 @@ test_expect_success 'adding comments to a template should not commit' '
 	)
 '
 
-test_expect_success 'adding real content to a template should commit' '
+test_log_messages_expect_success 'adding real content to a template should commit' '
 	(
 		test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
 		git commit --template "$TEMPLATE"
@@ -80,7 +81,7 @@ test_expect_success 'adding real content to a template should commit' '
 	commit_msg_is "template linecommit message"
 '
 
-test_expect_success '-t option should be short for --template' '
+test_log_messages_expect_success '-t option should be short for --template' '
 	echo "short template" > "$TEMPLATE" &&
 	echo "new content" >> foo &&
 	git add foo &&
@@ -91,7 +92,7 @@ test_expect_success '-t option should be short for --template' '
 	commit_msg_is "short templatecommit message"
 '
 
-test_expect_success 'config-specified template should commit' '
+test_log_messages_expect_success 'config-specified template should commit' '
 	echo "new template" > "$TEMPLATE" &&
 	git config commit.template "$TEMPLATE" &&
 	echo "more content" >> foo &&
@@ -206,7 +207,7 @@ test_expect_success 'commit -F overrides -t' '
 	commit_msg_is "-F log"
 '
 
-test_expect_success 'Commit without message is allowed with --allow-empty-message' '
+test_log_messages_expect_success 'Commit without message is allowed with --allow-empty-message' '
 	echo "more content" >>foo &&
 	git add foo &&
 	>empty &&
@@ -214,7 +215,7 @@ test_expect_success 'Commit without message is allowed with --allow-empty-messag
 	commit_msg_is ""
 '
 
-test_expect_success 'Commit without message is no-no without --allow-empty-message' '
+test_log_messages_expect_success 'Commit without message is no-no without --allow-empty-message' '
 	echo "more content" >>foo &&
 	git add foo &&
 	>empty &&
@@ -270,7 +271,7 @@ test_expect_success 'commit --squash works with -C' '
 	commit_msg_is "squash! target message subject lineintermediate commit"
 '
 
-test_expect_success 'commit --squash works with -c' '
+test_log_messages_expect_success 'commit --squash works with -c' '
 	commit_for_rebase_autosquash_setup &&
 	test_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&
 	git commit --squash HEAD~1 -c HEAD &&
@@ -283,14 +284,14 @@ test_expect_success 'commit --squash works with -C for same commit' '
 	commit_msg_is "squash! intermediate commit"
 '
 
-test_expect_success 'commit --squash works with -c for same commit' '
+test_log_messages_expect_success 'commit --squash works with -c for same commit' '
 	commit_for_rebase_autosquash_setup &&
 	test_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&
 	git commit --squash HEAD -c HEAD &&
 	commit_msg_is "squash! edited commit"
 '
 
-test_expect_success 'commit --squash works with editor' '
+test_log_messages_expect_success 'commit --squash works with editor' '
 	commit_for_rebase_autosquash_setup &&
 	test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
 	git commit --squash HEAD~1 &&
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 8980738..af6a829 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -8,6 +8,7 @@
 
 test_description='git commit'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-commit-template.sh
 
 test_tick
 
@@ -163,7 +164,7 @@ d381ac431806e53f3dd7ac2f1ae0534f36d738b9
 402702b49136e7587daa9280e91e4bb7cb2179f7
 EOF
 
-test_expect_success \
+test_log_messages_expect_success \
     'validate git rev-list output.' \
     'test_cmp expected current'
 
@@ -200,7 +201,7 @@ test_expect_success 'partial commit that involves removal (3)' '
 '
 
 author="The Real Author <someguy@xxxxxxxxxxxxx>"
-test_expect_success 'amend commit to fix author' '
+test_log_messages_expect_success 'amend commit to fix author' '
 
 	oldtick=$GIT_AUTHOR_DATE &&
 	test_tick &&
@@ -215,7 +216,7 @@ test_expect_success 'amend commit to fix author' '
 
 '
 
-test_expect_success 'amend commit to fix date' '
+test_log_messages_expect_success 'amend commit to fix date' '
 
 	test_tick &&
 	newtick=$GIT_AUTHOR_DATE &&
@@ -329,7 +330,7 @@ test_expect_success 'multiple -m' '
 '
 
 author="The Real Author <someguy@xxxxxxxxxxxxx>"
-test_expect_success 'amend commit to fix author' '
+test_log_messages_expect_success 'amend commit to fix author' '
 
 	oldtick=$GIT_AUTHOR_DATE &&
 	test_tick &&
diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
index ff18962..2d7ec32 100755
--- a/t/t7505-prepare-commit-msg-hook.sh
+++ b/t/t7505-prepare-commit-msg-hook.sh
@@ -3,6 +3,7 @@
 test_description='prepare-commit-msg hook'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-commit-template.sh
 
 test_expect_success 'with no hook' '
 
@@ -103,7 +104,7 @@ test_expect_success 'with hook (-C)' '
 
 '
 
-test_expect_success 'with hook (editor)' '
+test_log_messages_expect_success 'with hook (editor)' '
 
 	echo "more more" >> file &&
 	git add file &&
@@ -112,7 +113,7 @@ test_expect_success 'with hook (editor)' '
 
 '
 
-test_expect_success 'with hook (--amend)' '
+test_log_messages_expect_success 'with hook (--amend)' '
 
 	head=`git rev-parse HEAD` &&
 	echo "more" >> file &&
@@ -122,7 +123,7 @@ test_expect_success 'with hook (--amend)' '
 
 '
 
-test_expect_success 'with hook (-c)' '
+test_log_messages_expect_success 'with hook (-c)' '
 
 	head=`git rev-parse HEAD` &&
 	echo "more" >> file &&
diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh
index da5bd3b..62c42b3 100755
--- a/t/t7507-commit-verbose.sh
+++ b/t/t7507-commit-verbose.sh
@@ -2,6 +2,7 @@
 
 test_description='verbose commit template'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-commit-template.sh
 
 cat >check-for-diff <<EOF
 #!$SHELL_PATH
@@ -37,12 +38,12 @@ check_message() {
 	test_cmp "$1" actual
 }
 
-test_expect_success 'verbose diff is stripped out' '
+test_log_messages_expect_success 'verbose diff is stripped out' '
 	git commit --amend -v &&
 	check_message message
 '
 
-test_expect_success 'verbose diff is stripped out (mnemonicprefix)' '
+test_log_messages_expect_success 'verbose diff is stripped out (mnemonicprefix)' '
 	git config diff.mnemonicprefix true &&
 	git commit --amend -v &&
 	check_message message
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index 77b6920..2820b89 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
@@ -6,6 +6,7 @@
 test_description='git commit --reset-author'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-commit-template.sh
 
 author_header () {
 	git cat-file commit "$1" |
@@ -57,7 +58,7 @@ test_expect_success '-c option copies authorship and message' '
 	test_cmp expect actual
 '
 
-test_expect_success '-c option copies only the message with --reset-author' '
+test_log_messages_expect_success '-c option copies only the message with --reset-author' '
 	echo "Test 4" >>foo &&
 	test_tick &&
 	EDITOR=: VISUAL=: git commit -a -c Initial --reset-author &&
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]