3 test_description
='Clone repositories and store files in Mock LFS'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_file_is_not_in_mock_lfs
() {
11 echo "$CONTENT" >expect_content
&&
12 test_path_is_file
"$FILE" &&
13 test_cmp expect_content
"$FILE"
16 test_file_is_in_mock_lfs
() {
19 LOCAL_STORAGE
=".git/mock-storage/local/$CONTENT" &&
20 SERVER_STORAGE
=".git/mock-storage/remote/$CONTENT" &&
21 echo "pointer-$CONTENT" >expect_pointer
&&
22 echo "$CONTENT" >expect_content
&&
23 test_path_is_file
"$FILE" &&
24 test_path_is_file
"$LOCAL_STORAGE" &&
25 test_path_is_file
"$SERVER_STORAGE" &&
26 test_cmp expect_pointer
"$FILE" &&
27 test_cmp expect_content
"$LOCAL_STORAGE" &&
28 test_cmp expect_content
"$SERVER_STORAGE"
31 test_file_is_deleted_in_mock_lfs
() {
34 LOCAL_STORAGE
=".git/mock-storage/local/$CONTENT" &&
35 SERVER_STORAGE
=".git/mock-storage/remote/$CONTENT" &&
36 echo "pointer-$CONTENT" >expect_pointer
&&
37 echo "$CONTENT" >expect_content
&&
38 test_path_is_missing
"$FILE" &&
39 test_path_is_file
"$LOCAL_STORAGE" &&
40 test_path_is_file
"$SERVER_STORAGE" &&
41 test_cmp expect_content
"$LOCAL_STORAGE" &&
42 test_cmp expect_content
"$SERVER_STORAGE"
45 test_file_count_in_dir
() {
47 EXPECTED_COUNT
="$2" &&
48 find "$DIR" -type f
>actual
&&
49 test_line_count
= $EXPECTED_COUNT actual
52 test_expect_success
'start p4d' '
56 test_expect_success
'Create repo with binary files' '
57 client_view "//depot/... //client/..." &&
61 echo "content 1 txt 23 bytes" >file1.txt &&
63 echo "content 2-3 bin 25 bytes" >file2.dat &&
65 p4 submit -d "Add text and binary file" &&
67 mkdir "path with spaces" &&
68 echo "content 2-3 bin 25 bytes" >"path with spaces/file3.bin" &&
69 p4 add "path with spaces/file3.bin" &&
70 p4 submit -d "Add another binary file with same content and spaces in path" &&
72 echo "content 4 bin 26 bytes XX" >file4.bin &&
74 p4 submit -d "Add another binary file with different content"
78 test_expect_success
'Store files in Mock LFS based on size (>24 bytes)' '
79 client_view "//depot/... //client/..." &&
80 test_when_finished cleanup_git &&
84 git config git-p4.useClientSpec true &&
85 git config git-p4.largeFileSystem MockLFS &&
86 git config git-p4.largeFileThreshold 24 &&
87 git config git-p4.largeFilePush True &&
88 git p4 clone --destination="$git" //depot@all &&
90 test_file_is_not_in_mock_lfs file1.txt "content 1 txt 23 bytes" &&
91 test_file_is_in_mock_lfs file2.dat "content 2-3 bin 25 bytes" &&
92 test_file_is_in_mock_lfs "path with spaces/file3.bin" "content 2-3 bin 25 bytes" &&
93 test_file_is_in_mock_lfs file4.bin "content 4 bin 26 bytes XX" &&
95 test_file_count_in_dir ".git/mock-storage/local" 2 &&
96 test_file_count_in_dir ".git/mock-storage/remote" 2
100 test_expect_success
'Store files in Mock LFS based on extension (dat)' '
101 client_view "//depot/... //client/..." &&
102 test_when_finished cleanup_git &&
106 git config git-p4.useClientSpec true &&
107 git config git-p4.largeFileSystem MockLFS &&
108 git config git-p4.largeFileExtensions dat &&
109 git config git-p4.largeFilePush True &&
110 git p4 clone --destination="$git" //depot@all &&
112 test_file_is_not_in_mock_lfs file1.txt "content 1 txt 23 bytes" &&
113 test_file_is_in_mock_lfs file2.dat "content 2-3 bin 25 bytes" &&
114 test_file_is_not_in_mock_lfs "path with spaces/file3.bin" "content 2-3 bin 25 bytes" &&
115 test_file_is_not_in_mock_lfs file4.bin "content 4 bin 26 bytes XX" &&
117 test_file_count_in_dir ".git/mock-storage/local" 1 &&
118 test_file_count_in_dir ".git/mock-storage/remote" 1
122 test_expect_success
'Store files in Mock LFS based on extension (dat) and use git p4 sync and no client spec' '
123 test_when_finished cleanup_git &&
127 git config git-p4.useClientSpec true &&
128 git config git-p4.largeFileSystem MockLFS &&
129 git config git-p4.largeFileExtensions dat &&
130 git config git-p4.largeFilePush True &&
131 git p4 sync //depot &&
132 git checkout p4/master &&
134 test_file_is_not_in_mock_lfs file1.txt "content 1 txt 23 bytes" &&
135 test_file_is_in_mock_lfs file2.dat "content 2-3 bin 25 bytes" &&
136 test_file_is_not_in_mock_lfs "path with spaces/file3.bin" "content 2-3 bin 25 bytes" &&
137 test_file_is_not_in_mock_lfs file4.bin "content 4 bin 26 bytes XX" &&
139 test_file_count_in_dir ".git/mock-storage/local" 1 &&
140 test_file_count_in_dir ".git/mock-storage/remote" 1
144 test_expect_success
'Remove file from repo and store files in Mock LFS based on size (>24 bytes)' '
145 client_view "//depot/... //client/..." &&
148 p4 delete file4.bin &&
149 p4 submit -d "Remove file"
152 client_view "//depot/... //client/..." &&
153 test_when_finished cleanup_git &&
157 git config git-p4.useClientSpec true &&
158 git config git-p4.largeFileSystem MockLFS &&
159 git config git-p4.largeFileThreshold 24 &&
160 git config git-p4.largeFilePush True &&
161 git p4 clone --destination="$git" //depot@all &&
163 test_file_is_not_in_mock_lfs file1.txt "content 1 txt 23 bytes" &&
164 test_file_is_in_mock_lfs file2.dat "content 2-3 bin 25 bytes" &&
165 test_file_is_in_mock_lfs "path with spaces/file3.bin" "content 2-3 bin 25 bytes" &&
166 test_file_is_deleted_in_mock_lfs file4.bin "content 4 bin 26 bytes XX" &&
168 test_file_count_in_dir ".git/mock-storage/local" 2 &&
169 test_file_count_in_dir ".git/mock-storage/remote" 2
173 test_expect_success
'Run git p4 submit in repo configured with large file system' '
174 client_view "//depot/... //client/..." &&
175 test_when_finished cleanup_git &&
179 git config git-p4.useClientSpec true &&
180 git config git-p4.largeFileSystem MockLFS &&
181 git config git-p4.largeFileThreshold 24 &&
182 git config git-p4.largeFilePush True &&
183 git p4 clone --destination="$git" //depot@all &&
185 test_must_fail git p4 submit