git-p4: test with limited p4 server results
[git/git.git] / t / t9818-git-p4-block.sh
CommitLineData
96b2d54a
LS
1#!/bin/sh
2
3test_description='git p4 fetching changes in multiple blocks'
4
5. ./lib-git-p4.sh
6
7test_expect_success 'start p4d' '
8 start_p4d
9'
10
6ba9e2c1
LD
11create_restricted_group() {
12 p4 group -i <<-EOF
13 Group: restricted
14 MaxResults: 7
15 MaxScanRows: 40
16 Users: author
17 EOF
18}
19
20test_expect_success 'Create group with limited maxrows' '
21 create_restricted_group
22'
23
755113b9 24test_expect_success 'Create a repo with many changes' '
96b2d54a 25 (
755113b9
LD
26 client_view "//depot/included/... //client/included/..." \
27 "//depot/excluded/... //client/excluded/..." &&
28 mkdir -p "$cli/included" "$cli/excluded" &&
29 cd "$cli/included" &&
96b2d54a
LS
30 >file.txt &&
31 p4 add file.txt &&
32 p4 submit -d "Add file.txt" &&
755113b9 33 for i in $(test_seq 0 5)
96b2d54a
LS
34 do
35 >outer$i.txt &&
36 p4 add outer$i.txt &&
37 p4 submit -d "Adding outer$i.txt" &&
755113b9 38 for j in $(test_seq 0 5)
96b2d54a
LS
39 do
40 p4 edit file.txt &&
41 echo $i$j >file.txt &&
42 p4 submit -d "Commit $i$j" || exit
43 done || exit
44 done
45 )
46'
47
6ba9e2c1
LD
48test_expect_success 'Default user cannot fetch changes' '
49 ! p4 changes -m 1 //depot/...
50'
51
52test_expect_failure 'Clone the repo' '
755113b9 53 git p4 clone --dest="$git" --changes-block-size=7 --verbose //depot/included@all
96b2d54a
LS
54'
55
6ba9e2c1 56test_expect_failure 'All files are present' '
96b2d54a
LS
57 echo file.txt >expected &&
58 test_write_lines outer0.txt outer1.txt outer2.txt outer3.txt outer4.txt >>expected &&
755113b9 59 test_write_lines outer5.txt >>expected &&
96b2d54a
LS
60 ls "$git" >current &&
61 test_cmp expected current
62'
63
6ba9e2c1 64test_expect_failure 'file.txt is correct' '
755113b9 65 echo 55 >expected &&
96b2d54a
LS
66 test_cmp expected "$git/file.txt"
67'
68
6ba9e2c1 69test_expect_failure 'Correct number of commits' '
96b2d54a 70 (cd "$git" && git log --oneline) >log &&
755113b9
LD
71 wc -l log &&
72 test_line_count = 43 log
96b2d54a
LS
73'
74
6ba9e2c1 75test_expect_failure 'Previous version of file.txt is correct' '
96b2d54a 76 (cd "$git" && git checkout HEAD^^) &&
755113b9 77 echo 53 >expected &&
96b2d54a
LS
78 test_cmp expected "$git/file.txt"
79'
80
755113b9
LD
81# Test git-p4 sync, with some files outside the client specification.
82
83p4_add_file() {
84 (cd "$cli" &&
85 >$1 &&
86 p4 add $1 &&
87 p4 submit -d "Added a file" $1
88 )
89}
90
91test_expect_success 'Add some more files' '
92 for i in $(test_seq 0 10)
93 do
94 p4_add_file "included/x$i" &&
95 p4_add_file "excluded/x$i"
96 done &&
97 for i in $(test_seq 0 10)
98 do
99 p4_add_file "excluded/y$i"
100 done
101'
102
103# This should pick up the 10 new files in "included", but not be confused
104# by the additional files in "excluded"
6ba9e2c1 105test_expect_failure 'Syncing files' '
755113b9
LD
106 (
107 cd "$git" &&
108 git p4 sync --changes-block-size=7 &&
109 git checkout p4/master &&
110 ls -l x* > log &&
111 test_line_count = 11 log
112 )
113'
114
96b2d54a
LS
115test_expect_success 'kill p4d' '
116 kill_p4d
117'
118
119test_done