From d00d2ed1c5bd41a26c61236e79e82764baad464b Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 19 Feb 2011 08:17:54 -0500 Subject: git-p4: test script Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9800-git-p4.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 t/t9800-git-p4.sh (limited to 't/t9800-git-p4.sh') diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh new file mode 100755 index 0000000000..2d354f86d0 --- /dev/null +++ b/t/t9800-git-p4.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +test_description='git-p4 tests' + +. ./test-lib.sh + +( p4 -h && p4d -h ) >/dev/null 2>&1 || { + skip_all='skipping git-p4 tests; no p4 or p4d' + test_done +} + +GITP4=$GIT_BUILD_DIR/contrib/fast-import/git-p4 +P4DPORT=10669 + +db="$TRASH_DIRECTORY/db" +cli="$TRASH_DIRECTORY/cli" +git="$TRASH_DIRECTORY/git" + +test_debug 'echo p4d -q -d -r "$db" -p $P4DPORT' +test_expect_success setup ' + mkdir -p "$db" && + p4d -q -d -r "$db" -p $P4DPORT && + mkdir -p "$cli" && + mkdir -p "$git" && + export P4PORT=localhost:$P4DPORT +' + +test_expect_success 'add p4 files' ' + cd "$cli" && + p4 client -i <<-EOF && + Client: client + Description: client + Root: $cli + View: //depot/... //client/... + EOF + export P4CLIENT=client && + echo file1 >file1 && + p4 add file1 && + p4 submit -d "file1" && + cd "$TRASH_DIRECTORY" +' + +test_expect_success 'basic git-p4 clone' ' + "$GITP4" clone --dest="$git" //depot && + rm -rf "$git" && mkdir "$git" +' + +test_expect_success 'shutdown' ' + pid=`pgrep -f p4d` && + test -n "$pid" && + test_debug "ps wl `echo $pid`" && + kill $pid +' + +test_done -- cgit v1.2.3 From 68b28593899d528d4b59e7eb07cc37b85012376a Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 19 Feb 2011 08:17:55 -0500 Subject: git-p4: fix key error for p4 problem Some p4 failures result in an error, but the info['code'] is not set. These include a bad p4 executable, or a core dump from p4, and other odd internal errors where p4 fails to generate proper marshaled output. Make sure the info key exists before using it to avoid a python traceback. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9800-git-p4.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't/t9800-git-p4.sh') diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh index 2d354f86d0..c1ea4d445c 100755 --- a/t/t9800-git-p4.sh +++ b/t/t9800-git-p4.sh @@ -45,6 +45,19 @@ test_expect_success 'basic git-p4 clone' ' rm -rf "$git" && mkdir "$git" ' +test_expect_success 'exit when p4 fails to produce marshaled output' ' + badp4dir="$TRASH_DIRECTORY/badp4dir" && + mkdir -p "$badp4dir" && + cat >"$badp4dir"/p4 <<-EOF && + #!$SHELL_PATH + exit 1 + EOF + chmod 755 "$badp4dir"/p4 && + PATH="$badp4dir:$PATH" "$GITP4" clone --dest="$git" //depot >errs 2>&1 ; retval=$? && + test $retval -eq 1 && + test_must_fail grep -q Traceback errs +' + test_expect_success 'shutdown' ' pid=`pgrep -f p4d` && test -n "$pid" && -- cgit v1.2.3 From 084f6306d4b7b27a5d12236e808604220b8b3e3f Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 19 Feb 2011 08:18:00 -0500 Subject: git-p4: decode p4 wildcard characters There are four wildcard characters in p4. Files with these characters can be added to p4 repos using the "-f" option. They are stored in %xx notation, and when checked out, p4 converts them back to normal. This patch does the same thing when importing into git, converting the four special characters. Without this change, the files appear with literal %xx in their names. Be careful not to produce "*" in filenames on windows. That will fail. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9800-git-p4.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't/t9800-git-p4.sh') diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh index c1ea4d445c..026277a47a 100755 --- a/t/t9800-git-p4.sh +++ b/t/t9800-git-p4.sh @@ -58,6 +58,28 @@ test_expect_success 'exit when p4 fails to produce marshaled output' ' test_must_fail grep -q Traceback errs ' +test_expect_success 'add p4 files with wildcards in the names' ' + cd "$cli" && + echo file-wild-hash >file-wild#hash && + echo file-wild-star >file-wild\*star && + echo file-wild-at >file-wild@at && + echo file-wild-percent >file-wild%percent && + p4 add -f file-wild* && + p4 submit -d "file wildcards" && + cd "$TRASH_DIRECTORY" +' + +test_expect_success 'wildcard files git-p4 clone' ' + "$GITP4" clone --dest="$git" //depot && + cd "$git" && + test -f file-wild#hash && + test -f file-wild\*star && + test -f file-wild@at && + test -f file-wild%percent && + cd "$TRASH_DIRECTORY" && + rm -rf "$git" && mkdir "$git" +' + test_expect_success 'shutdown' ' pid=`pgrep -f p4d` && test -n "$pid" && -- cgit v1.2.3 From 382000769477ed0666e99d01c21df64df9ba0911 Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 19 Feb 2011 08:18:01 -0500 Subject: git-p4: support clone --bare Just like git clone --bare, build a .git directory but no checked out files. Signed-off-by: Pete Wyckoff Acked-By: Tor Arvid Lund Signed-off-by: Junio C Hamano --- t/t9800-git-p4.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/t9800-git-p4.sh') diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh index 026277a47a..1969e6b9d3 100755 --- a/t/t9800-git-p4.sh +++ b/t/t9800-git-p4.sh @@ -80,6 +80,16 @@ test_expect_success 'wildcard files git-p4 clone' ' rm -rf "$git" && mkdir "$git" ' +test_expect_success 'clone bare' ' + "$GITP4" clone --dest="$git" --bare //depot && + cd "$git" && + test ! -d .git && + bare=`git config --get core.bare` && + test "$bare" = true && + cd "$TRASH_DIRECTORY" && + rm -rf "$git" && mkdir "$git" +' + test_expect_success 'shutdown' ' pid=`pgrep -f p4d` && test -n "$pid" && -- cgit v1.2.3 From f0c9fe050474e0f2a947366a82a62efd6afbf2ce Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 12 Mar 2011 11:24:49 -0500 Subject: git-p4: test clone @all Cloning a p4 depot by default generates a single commit. The use of the "@all" revision specifier instead tells git-p4 to import all commits. Check to make sure both these invocations work as expected. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9800-git-p4.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/t9800-git-p4.sh') diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh index 1969e6b9d3..abe7c64ba9 100755 --- a/t/t9800-git-p4.sh +++ b/t/t9800-git-p4.sh @@ -37,11 +37,27 @@ test_expect_success 'add p4 files' ' echo file1 >file1 && p4 add file1 && p4 submit -d "file1" && + echo file2 >file2 && + p4 add file2 && + p4 submit -d "file2" && cd "$TRASH_DIRECTORY" ' test_expect_success 'basic git-p4 clone' ' "$GITP4" clone --dest="$git" //depot && + cd "$git" && + git log --oneline >lines && + test_line_count = 1 lines && + cd .. && + rm -rf "$git" && mkdir "$git" +' + +test_expect_success 'git-p4 clone @all' ' + "$GITP4" clone --dest="$git" //depot@all && + cd "$git" && + git log --oneline >lines && + test_line_count = 2 lines && + cd .. && rm -rf "$git" && mkdir "$git" ' -- cgit v1.2.3 From 27c6000b28c89cad7af23df90d52bf33e205f61f Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Wed, 16 Mar 2011 16:53:53 -0400 Subject: git-p4: test sync new branch Add two new unit tests. One to test the feature that that was added in e32e00d, and another to test the regression that was fixed in the parent to this commit. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- t/t9800-git-p4.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 't/t9800-git-p4.sh') diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh index abe7c64ba9..a523473954 100755 --- a/t/t9800-git-p4.sh +++ b/t/t9800-git-p4.sh @@ -61,6 +61,29 @@ test_expect_success 'git-p4 clone @all' ' rm -rf "$git" && mkdir "$git" ' +test_expect_success 'git-p4 sync uninitialized repo' ' + test_create_repo "$git" && + cd "$git" && + test_must_fail "$GITP4" sync && + rm -rf "$git" && mkdir "$git" +' + +# +# Create a git repo by hand. Add a commit so that HEAD is valid. +# Test imports a new p4 repository into a new git branch. +# +test_expect_success 'git-p4 sync new branch' ' + test_create_repo "$git" && + cd "$git" && + test_commit head && + "$GITP4" sync --branch=refs/remotes/p4/depot //depot@all && + git log --oneline p4/depot >lines && + cat lines && + test_line_count = 2 lines && + cd .. && + rm -rf "$git" && mkdir "$git" +' + test_expect_success 'exit when p4 fails to produce marshaled output' ' badp4dir="$TRASH_DIRECTORY/badp4dir" && mkdir -p "$badp4dir" && -- cgit v1.2.3