2011-02-19 14:17:54 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-04-09 02:18:02 +02:00
|
|
|
test_description='git p4 tests'
|
2011-02-19 14:17:54 +01:00
|
|
|
|
2011-08-23 04:20:33 +02:00
|
|
|
. ./lib-git-p4.sh
|
2011-02-19 14:17:54 +01:00
|
|
|
|
2011-08-23 04:20:33 +02:00
|
|
|
test_expect_success 'start p4d' '
|
|
|
|
start_p4d
|
2011-02-19 14:17:54 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'add p4 files' '
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
echo file1 >file1 &&
|
|
|
|
p4 add file1 &&
|
|
|
|
p4 submit -d "file1" &&
|
|
|
|
echo file2 >file2 &&
|
|
|
|
p4 add file2 &&
|
|
|
|
p4 submit -d "file2"
|
|
|
|
)
|
2011-02-19 14:17:54 +01:00
|
|
|
'
|
|
|
|
|
2012-04-09 02:18:02 +02:00
|
|
|
test_expect_success 'basic git p4 clone' '
|
|
|
|
git p4 clone --dest="$git" //depot &&
|
2011-07-31 15:44:50 +02:00
|
|
|
test_when_finished cleanup_git &&
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git log --oneline >lines &&
|
|
|
|
test_line_count = 1 lines
|
|
|
|
)
|
2011-03-12 17:24:49 +01:00
|
|
|
'
|
|
|
|
|
2012-04-09 02:18:02 +02:00
|
|
|
test_expect_success 'git p4 clone @all' '
|
|
|
|
git p4 clone --dest="$git" //depot@all &&
|
2011-07-31 15:44:50 +02:00
|
|
|
test_when_finished cleanup_git &&
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git log --oneline >lines &&
|
|
|
|
test_line_count = 2 lines
|
|
|
|
)
|
2011-02-19 14:17:54 +01:00
|
|
|
'
|
|
|
|
|
2012-04-09 02:18:02 +02:00
|
|
|
test_expect_success 'git p4 sync uninitialized repo' '
|
2011-03-16 21:53:53 +01:00
|
|
|
test_create_repo "$git" &&
|
2011-07-31 15:44:50 +02:00
|
|
|
test_when_finished cleanup_git &&
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
2012-06-27 14:00:59 +02:00
|
|
|
test_must_fail git p4 sync 2>errs &&
|
|
|
|
test_i18ngrep "Perhaps you never did" errs
|
2011-08-23 04:20:33 +02:00
|
|
|
)
|
2011-03-16 21:53:53 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2012-04-09 02:18:02 +02:00
|
|
|
test_expect_success 'git p4 sync new branch' '
|
2011-03-16 21:53:53 +01:00
|
|
|
test_create_repo "$git" &&
|
2011-07-31 15:44:50 +02:00
|
|
|
test_when_finished cleanup_git &&
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
test_commit head &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 sync --branch=refs/remotes/p4/depot //depot@all &&
|
2011-08-23 04:20:33 +02:00
|
|
|
git log --oneline p4/depot >lines &&
|
|
|
|
test_line_count = 2 lines
|
|
|
|
)
|
2011-03-16 21:53:53 +01:00
|
|
|
'
|
|
|
|
|
2011-12-25 03:07:33 +01:00
|
|
|
test_expect_success 'clone two dirs' '
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
mkdir sub1 sub2 &&
|
|
|
|
echo sub1/f1 >sub1/f1 &&
|
|
|
|
echo sub2/f2 >sub2/f2 &&
|
|
|
|
p4 add sub1/f1 &&
|
|
|
|
p4 submit -d "sub1/f1" &&
|
|
|
|
p4 add sub2/f2 &&
|
|
|
|
p4 submit -d "sub2/f2"
|
|
|
|
) &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot/sub1 //depot/sub2 &&
|
2011-12-25 03:07:33 +01:00
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git ls-files >lines &&
|
|
|
|
test_line_count = 2 lines &&
|
|
|
|
git log --oneline p4/master >lines &&
|
|
|
|
test_line_count = 1 lines
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'clone two dirs, @all' '
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
echo sub1/f3 >sub1/f3 &&
|
|
|
|
p4 add sub1/f3 &&
|
|
|
|
p4 submit -d "sub1/f3"
|
|
|
|
) &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
|
2011-12-25 03:07:33 +01:00
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git ls-files >lines &&
|
|
|
|
test_line_count = 3 lines &&
|
|
|
|
git log --oneline p4/master >lines &&
|
|
|
|
test_line_count = 3 lines
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'clone two dirs, @all, conflicting files' '
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
echo sub2/f3 >sub2/f3 &&
|
|
|
|
p4 add sub2/f3 &&
|
|
|
|
p4 submit -d "sub2/f3"
|
|
|
|
) &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
|
2011-12-25 03:07:33 +01:00
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git ls-files >lines &&
|
|
|
|
test_line_count = 3 lines &&
|
|
|
|
git log --oneline p4/master >lines &&
|
|
|
|
test_line_count = 4 lines &&
|
|
|
|
echo sub2/f3 >expected &&
|
|
|
|
test_cmp expected f3
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-02-19 14:17:55 +01:00
|
|
|
test_expect_success 'exit when p4 fails to produce marshaled output' '
|
2012-06-27 14:00:56 +02:00
|
|
|
mkdir badp4dir &&
|
|
|
|
test_when_finished "rm badp4dir/p4 && rmdir badp4dir" &&
|
|
|
|
cat >badp4dir/p4 <<-EOF &&
|
2011-02-19 14:17:55 +01:00
|
|
|
#!$SHELL_PATH
|
|
|
|
exit 1
|
|
|
|
EOF
|
2012-06-27 14:00:56 +02:00
|
|
|
chmod 755 badp4dir/p4 &&
|
2012-06-27 14:01:03 +02:00
|
|
|
(
|
|
|
|
PATH="$TRASH_DIRECTORY/badp4dir:$PATH" &&
|
|
|
|
export PATH &&
|
|
|
|
test_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1
|
|
|
|
) &&
|
|
|
|
cat errs &&
|
|
|
|
! test_i18ngrep Traceback errs
|
2011-02-19 14:17:55 +01:00
|
|
|
'
|
|
|
|
|
2011-02-19 14:18:01 +01:00
|
|
|
test_expect_success 'clone bare' '
|
2012-06-27 14:01:01 +02:00
|
|
|
rm -rf "$git" &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" --bare //depot &&
|
2011-07-31 15:44:50 +02:00
|
|
|
test_when_finished cleanup_git &&
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
test ! -d .git &&
|
|
|
|
bare=`git config --get core.bare` &&
|
|
|
|
test "$bare" = true
|
|
|
|
)
|
2011-02-19 14:18:01 +01:00
|
|
|
'
|
|
|
|
|
2011-07-31 15:45:55 +02:00
|
|
|
marshal_dump() {
|
|
|
|
what=$1
|
2011-08-23 04:20:33 +02:00
|
|
|
"$PYTHON_PATH" -c 'import marshal, sys; d = marshal.load(sys.stdin); print d["'$what'"]'
|
2011-07-31 15:45:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Sleep a bit so that the top-most p4 change did not happen "now". Then
|
|
|
|
# import the repo and make sure that the initial import has the same time
|
|
|
|
# as the top-most change.
|
|
|
|
test_expect_success 'initial import time from top change time' '
|
|
|
|
p4change=$(p4 -G changes -m 1 //depot/... | marshal_dump change) &&
|
|
|
|
p4time=$(p4 -G changes -m 1 //depot/... | marshal_dump time) &&
|
|
|
|
sleep 3 &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot &&
|
2011-07-31 15:45:55 +02:00
|
|
|
test_when_finished cleanup_git &&
|
2011-08-23 04:20:33 +02:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
gittime=$(git show -s --raw --pretty=format:%at HEAD) &&
|
|
|
|
echo $p4time $gittime &&
|
|
|
|
test $p4time = $gittime
|
|
|
|
)
|
2011-07-31 15:45:55 +02:00
|
|
|
'
|
2011-05-13 21:46:00 +02:00
|
|
|
|
2011-08-23 04:20:33 +02:00
|
|
|
test_expect_success 'kill p4d' '
|
|
|
|
kill_p4d
|
2011-02-19 14:17:54 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|