[PATCH 2/4] git-p4: make tests work on p4d eval server

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

 



The "evaluation" license for p4d allows only two users.  One of
the users will be auto-created as super when generating the first
commit or adding the first new user.  So we cannot have both an
Alice and Bob as well as super.  Instead, adapt the tests to work
with just a single Alice user.

Signed-off-by: Pete Wyckoff <pw@xxxxxxxx>
---
 t/t9800-git-p4.sh |   44 ++++++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
index aec3ba1..04d8413 100755
--- a/t/t9800-git-p4.sh
+++ b/t/t9800-git-p4.sh
@@ -149,6 +149,13 @@ p4_grant_admin() {
 	p4 protect -i
 }
 
+p4_ungrant_admin() {
+    name=$1
+    p4 protect -o |\
+	grep -v $name |\
+	p4 protect -i
+}
+
 p4_check_commit_author() {
     file=$1
     user=$2
@@ -167,22 +174,30 @@ make_change_by_user() {
 	git commit --author "$name <$email>" -m "a change by $name"
 }
 
-# Test username support, submitting as user 'alice'
+marshal_dump() {
+	what=$1
+	python -c 'import marshal, sys; d = marshal.load(sys.stdin); print d["'$what'"]'
+}
+
+# Test username support, submitting as user 'alice'.  Second user will be
+# whoever is running these tests.  Cannot avoid having p4d auto-create that
+# user, and the eval version only supports two users.
 test_expect_success 'preserve users' '
+	bobuser=$(p4 -G users | marshal_dump User) &&
+	bobemail=$(p4 -G users | marshal_dump Email) &&
 	p4_add_user alice Alice &&
-	p4_add_user bob Bob &&
 	p4_grant_admin alice &&
 	"$GITP4" clone --dest="$git" //depot &&
 	test_when_finished cleanup_git &&
 	cd "$git" &&
 	echo "username: a change by alice" >> file1 &&
-	echo "username: a change by bob" >> file2 &&
+	echo "username: a change by $bobuser" >> 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 "$bobuser <$bobemail>" -m "a change by $bobuser" file2 &&
 	git config git-p4.skipSubmitEditCheck true &&
 	P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
 	p4_check_commit_author file1 alice &&
-	p4_check_commit_author file2 bob
+	p4_check_commit_author file2 $bobuser
 '
 
 # Test username support, submitting as bob, who lacks admin rights. Should
@@ -191,9 +206,10 @@ test_expect_success 'refuse to preserve users without perms' '
 	"$GITP4" clone --dest="$git" //depot &&
 	test_when_finished cleanup_git &&
 	cd "$git" &&
-	echo "username-noperms: a change by alice" >> file1 &&
-	git commit --author "Alice <alice@localhost>" -m "perms: a change by alice" file1 &&
-	! P4EDITOR=touch P4USER=bob P4PASSWD=secret "$GITP4" commit --preserve-user &&
+	p4_ungrant_admin alice &&
+	echo "username-noperms: a change by $bobuser" >> file1 &&
+	git commit --author "$bobuser <$bobemail>" -m "perms: a change by $bobuser" file1 &&
+	! P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
 	! git diff --exit-code HEAD..p4/master > /dev/null
 '
 
@@ -202,9 +218,10 @@ test_expect_success 'preserve user where author is unknown to p4' '
 	"$GITP4" clone --dest="$git" //depot &&
 	test_when_finished cleanup_git &&
 	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 config git-p4.skipSubmitEditCheck true &&
+	p4_grant_admin alice &&
+	echo "username-bob: a change by $bobuser" >> file1 &&
+	git commit --author "$bobuser <$bobemail>" -m "preserve: a change by $bobuser" file1 &&
 	echo "username-unknown: a change by charlie" >> file1 &&
 	git commit --author "Charlie <charlie@localhost>" -m "preserve: a change by charlie" file1 &&
 	! P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
@@ -226,11 +243,10 @@ test_expect_success 'not preserving user with mixed authorship' '
 	test_when_finished cleanup_git &&
 	cd "$git" &&
 	git config git-p4.skipSubmitEditCheck true &&
-	p4_add_user derek Derek &&
 
-	make_change_by_user usernamefile3 Derek derek@localhost &&
+	make_change_by_user usernamefile3 $bobuser $bobemail &&
 	P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual &&
-	grep "git author derek@localhost does not match" actual &&
+	grep "git author $bobemail does not match" actual &&
 
 	make_change_by_user usernamefile3 Charlie charlie@localhost &&
 	P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual &&
-- 
1.7.5.4

--
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]