git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCHv2 06/11] git p4 test: run as user "author"
Date: Wed, 22 Jan 2014 17:47:24 -0500	[thread overview]
Message-ID: <1390430849-11436-6-git-send-email-pw@padd.com> (raw)
In-Reply-To: <20140122224421.GB4047@padd.com>

The tests use author@example.com as the canonical submitter, but
he does not have an entry in the p4 users database.  This causes
the generated change description to complain that the git and p4
users disagree.  The complaint message is still valid, just isn't
useful in tests.  It was introduced in 848de9c (git-p4: warn if
git authorship won't be retained, 2011-05-13).

Fix t9813 to use @example.com instead of @localhost due to change
in p4_add_user().  Move the function into the git p4 test library
so author can be added at initialization time.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 t/lib-git-p4.sh                  | 15 ++++++++++++++-
 t/t9813-git-p4-preserve-users.sh | 38 ++++++++++++++------------------------
 2 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
index ccd918e..4ff2bb1 100644
--- a/t/lib-git-p4.sh
+++ b/t/lib-git-p4.sh
@@ -47,9 +47,10 @@ P4DPORT=$((10669 + ($testid - $git_p4_test_start)))
 
 P4PORT=localhost:$P4DPORT
 P4CLIENT=client
+P4USER=author
 P4EDITOR=:
 unset P4CHARSET
-export P4PORT P4CLIENT P4EDITOR P4CHARSET
+export P4PORT P4CLIENT P4USER P4EDITOR P4CHARSET
 
 db="$TRASH_DIRECTORY/db"
 cli="$TRASH_DIRECTORY/cli"
@@ -96,12 +97,24 @@ start_p4d() {
 		return 1
 	fi
 
+	# build a p4 user so author@example.com has an entry
+	p4_add_user author
+
 	# build a client
 	client_view "//depot/... //client/..." &&
 
 	return 0
 }
 
+p4_add_user() {
+	name=$1 &&
+	p4 user -f -i <<-EOF
+	User: $name
+	Email: $name@example.com
+	FullName: Dr. $name
+	EOF
+}
+
 kill_p4d() {
 	pid=$(cat "$pidfile")
 	# it had better exist for the first kill
diff --git a/t/t9813-git-p4-preserve-users.sh b/t/t9813-git-p4-preserve-users.sh
index f2e85e5..166b840 100755
--- a/t/t9813-git-p4-preserve-users.sh
+++ b/t/t9813-git-p4-preserve-users.sh
@@ -19,16 +19,6 @@ test_expect_success 'create files' '
 	)
 '
 
-p4_add_user() {
-	name=$1 fullname=$2 &&
-	p4 user -f -i <<-EOF &&
-	User: $name
-	Email: $name@localhost
-	FullName: $fullname
-	EOF
-	p4 passwd -P secret $name
-}
-
 p4_grant_admin() {
 	name=$1 &&
 	{
@@ -51,8 +41,8 @@ make_change_by_user() {
 
 # Test username support, submitting as user 'alice'
 test_expect_success 'preserve users' '
-	p4_add_user alice Alice &&
-	p4_add_user bob Bob &&
+	p4_add_user alice &&
+	p4_add_user bob &&
 	p4_grant_admin alice &&
 	git p4 clone --dest="$git" //depot &&
 	test_when_finished cleanup_git &&
@@ -60,8 +50,8 @@ test_expect_success 'preserve users' '
 		cd "$git" &&
 		echo "username: a change by alice" >>file1 &&
 		echo "username: a change by bob" >>file2 &&
-		git commit --author "Alice <alice@localhost>" -m "a change by alice" file1 &&
-		git commit --author "Bob <bob@localhost>" -m "a change by bob" file2 &&
+		git commit --author "Alice <alice@example.com>" -m "a change by alice" file1 &&
+		git commit --author "Bob <bob@example.com>" -m "a change by bob" file2 &&
 		git config git-p4.skipSubmitEditCheck true &&
 		P4EDITOR=touch P4USER=alice P4PASSWD=secret git p4 commit --preserve-user &&
 		p4_check_commit_author file1 alice &&
@@ -78,7 +68,7 @@ test_expect_success 'refuse to preserve users without perms' '
 		cd "$git" &&
 		git config git-p4.skipSubmitEditCheck true &&
 		echo "username-noperms: a change by alice" >>file1 &&
-		git commit --author "Alice <alice@localhost>" -m "perms: a change by alice" file1 &&
+		git commit --author "Alice <alice@example.com>" -m "perms: a change by alice" file1 &&
 		P4EDITOR=touch P4USER=bob P4PASSWD=secret &&
 		export P4EDITOR P4USER P4PASSWD &&
 		test_must_fail git p4 commit --preserve-user &&
@@ -94,9 +84,9 @@ test_expect_success 'preserve user where author is unknown to p4' '
 		cd "$git" &&
 		git config git-p4.skipSubmitEditCheck true &&
 		echo "username-bob: a change by bob" >>file1 &&
-		git commit --author "Bob <bob@localhost>" -m "preserve: a change by bob" file1 &&
+		git commit --author "Bob <bob@example.com>" -m "preserve: a change by bob" file1 &&
 		echo "username-unknown: a change by charlie" >>file1 &&
-		git commit --author "Charlie <charlie@localhost>" -m "preserve: a change by charlie" file1 &&
+		git commit --author "Charlie <charlie@example.com>" -m "preserve: a change by charlie" file1 &&
 		P4EDITOR=touch P4USER=alice P4PASSWD=secret &&
 		export P4EDITOR P4USER P4PASSWD &&
 		test_must_fail git p4 commit --preserve-user &&
@@ -121,24 +111,24 @@ test_expect_success 'not preserving user with mixed authorship' '
 	(
 		cd "$git" &&
 		git config git-p4.skipSubmitEditCheck true &&
-		p4_add_user derek Derek &&
+		p4_add_user derek &&
 
-		make_change_by_user usernamefile3 Derek derek@localhost &&
+		make_change_by_user usernamefile3 Derek derek@example.com &&
 		P4EDITOR=cat P4USER=alice P4PASSWD=secret &&
 		export P4EDITOR P4USER P4PASSWD &&
 		git p4 commit |\
-		grep "git author derek@localhost does not match" &&
+		grep "git author derek@example.com does not match" &&
 
-		make_change_by_user usernamefile3 Charlie charlie@localhost &&
+		make_change_by_user usernamefile3 Charlie charlie@example.com &&
 		git p4 commit |\
-		grep "git author charlie@localhost does not match" &&
+		grep "git author charlie@example.com does not match" &&
 
-		make_change_by_user usernamefile3 alice alice@localhost &&
+		make_change_by_user usernamefile3 alice alice@example.com &&
 		git p4 commit |\
 		test_must_fail grep "git author.*does not match" &&
 
 		git config git-p4.skipUserNameCheck true &&
-		make_change_by_user usernamefile3 Charlie charlie@localhost &&
+		make_change_by_user usernamefile3 Charlie charlie@example.com &&
 		git p4 commit |\
 		test_must_fail grep "git author.*does not match" &&
 
-- 
1.8.5.2.364.g6ac45cd

  parent reply	other threads:[~2014-01-22 22:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 23:16 [PATCH 00/11] git p4 tests and a few bug fixes Pete Wyckoff
2014-01-21 23:16 ` [PATCH 01/11] git p4 test: wildcards are supported Pete Wyckoff
2014-01-21 23:16 ` [PATCH 02/11] git p4 test: ensure p4 symlink parsing works Pete Wyckoff
2014-01-21 23:16 ` [PATCH 03/11] git p4: work around p4 bug that causes empty symlinks Pete Wyckoff
2014-01-22  1:26   ` Eric Sunshine
2014-01-21 23:16 ` [PATCH 04/11] git p4 test: explicitly check p4 wildcard delete Pete Wyckoff
2014-01-21 23:16 ` [PATCH 05/11] git p4 test: is_cli_file_writeable succeeds Pete Wyckoff
2014-01-21 23:16 ` [PATCH 06/11] git p4 test: run as user "author" Pete Wyckoff
2014-01-22  1:26   ` Eric Sunshine
2014-01-21 23:16 ` [PATCH 07/11] git p4 test: do not pollute /tmp Pete Wyckoff
2014-01-21 23:16 ` [PATCH 08/11] git p4: handle files with wildcards when doing RCS scrubbing Pete Wyckoff
2014-01-21 23:16 ` [PATCH 09/11] git p4: fix an error message when "p4 where" fails Pete Wyckoff
2014-01-21 23:16 ` [PATCH 10/11] git p4 test: examine behavior with locked (+l) files Pete Wyckoff
2014-01-21 23:16 ` [PATCH 11/11] git p4 doc: use two-line style for options with multiple spellings Pete Wyckoff
2014-01-22  0:03 ` [PATCH 00/11] git p4 tests and a few bug fixes Junio C Hamano
2014-01-22 22:44   ` Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 01/11] git p4 test: wildcards are supported Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 02/11] git p4 test: ensure p4 symlink parsing works Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 03/11] git p4: work around p4 bug that causes empty symlinks Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 04/11] git p4 test: explicitly check p4 wildcard delete Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 05/11] git p4 test: is_cli_file_writeable succeeds Pete Wyckoff
2014-01-22 22:47     ` Pete Wyckoff [this message]
2014-01-22 22:47     ` [PATCHv2 07/11] git p4 test: do not pollute /tmp Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 08/11] git p4: handle files with wildcards when doing RCS scrubbing Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 09/11] git p4: fix an error message when "p4 where" fails Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 10/11] git p4 test: examine behavior with locked (+l) files Pete Wyckoff
2014-01-22 22:47     ` [PATCHv2 11/11] git p4 doc: use two-line style for options with multiple spellings Pete Wyckoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390430849-11436-6-git-send-email-pw@padd.com \
    --to=pw@padd.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).