git-p4: clean-up code style in tests
Preliminary clean-up of testing libraries for git-p4. * spaces added to both sides of () in function definitions in lib-git-p4 * tab indentation added to git-p4 tests when <<- redirection is used Signed-off-by: Jan Durovec <jan.durovec@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jan Durovec committed
Apr 19, 2016 at 19:49 UTC
a98772c63fa666e9239b0cdbd790daf7af503b75
2 files changed
+42
-42
t/lib-git-p4.sh
+12
-12
@@ -33,7 +33,7 @@ fi
33
# Older versions of perforce were available compiled natively for
34
# cygwin. Those do not accept native windows paths, so make sure
35
# not to convert for them.
36
-native_path() {
36
+native_path () {
37
path="$1" &&
38
if test_have_prereq CYGWIN && ! p4 -V | grep -q CYGWIN
39
then
@@ -49,7 +49,7 @@ native_path() {
49
# Attention: This function is not safe again against time offset updates
50
# at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'
51
# function could fix that but it is not in Python until 3.3.
52
-time_in_seconds() {
52
+time_in_seconds () {
53
python -c 'import time; print int(time.time())'
54
}
55
@@ -75,7 +75,7 @@ git="$TRASH_DIRECTORY/git"
75
pidfile="$TRASH_DIRECTORY/p4d.pid"
76
77
# Sometimes "prove" seems to hang on exit because p4d is still running
78
-cleanup() {
78
+cleanup () {
79
if test -f "$pidfile"
80
then
81
kill -9 $(cat "$pidfile") 2>/dev/null && exit 255
@@ -89,7 +89,7 @@ trap cleanup EXIT
89
TMPDIR="$TRASH_DIRECTORY"
90
export TMPDIR
91
92
-start_p4d() {
92
+start_p4d () {
93
mkdir -p "$db" "$cli" "$git" &&
94
rm -f "$pidfile" &&
95
(
@@ -151,7 +151,7 @@ start_p4d() {
151
return 0
152
}
153
154
-p4_add_user() {
154
+p4_add_user () {
155
name=$1 &&
156
p4 user -f -i <<-EOF
157
User: $name
@@ -160,7 +160,7 @@ p4_add_user() {
160
EOF
161
}
162
163
-retry_until_success() {
163
+retry_until_success () {
164
timeout=$(($(time_in_seconds) + $RETRY_TIMEOUT))
165
until "$@" 2>/dev/null || test $(time_in_seconds) -gt $timeout
166
do
@@ -168,7 +168,7 @@ retry_until_success() {
168
done
169
}
170
171
-retry_until_fail() {
171
+retry_until_fail () {
172
timeout=$(($(time_in_seconds) + $RETRY_TIMEOUT))
173
until ! "$@" 2>/dev/null || test $(time_in_seconds) -gt $timeout
174
do
@@ -176,7 +176,7 @@ retry_until_fail() {
176
done
177
}
178
179
-kill_p4d() {
179
+kill_p4d () {
180
pid=$(cat "$pidfile")
181
retry_until_fail kill $pid
182
retry_until_fail kill -9 $pid
@@ -186,13 +186,13 @@ kill_p4d() {
186
retry_until_fail kill -9 $watchdog_pid
187
}
188
189
-cleanup_git() {
189
+cleanup_git () {
190
retry_until_success rm -r "$git"
191
test_must_fail test -d "$git" &&
192
retry_until_success mkdir "$git"
193
}
194
195
-marshal_dump() {
195
+marshal_dump () {
196
what=$1 &&
197
line=${2:-1} &&
198
cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
@@ -208,7 +208,7 @@ marshal_dump() {
208
#
209
# Construct a client with this list of View lines
210
#
211
-client_view() {
211
+client_view () {
212
(
213
cat <<-EOF &&
214
Client: $P4CLIENT
@@ -222,7 +222,7 @@ client_view() {
222
) | p4 client -i
223
}
224
225
-is_cli_file_writeable() {
225
+is_cli_file_writeable () {
226
# cygwin version of p4 does not set read-only attr,
227
# will be marked 444 but -w is true
228
file="$1" &&
t/t9826-git-p4-keep-empty-commits.sh
+30
-30
@@ -47,23 +47,23 @@ test_expect_success 'Clone repo root path with all history' '
47
git init . &&
48
git p4 clone --use-client-spec --destination="$git" //depot@all &&
49
cat >expect <<-\EOF &&
50
-Remove file 4
51
-[git-p4: depot-paths = "//depot/": change = 6]
50
+ Remove file 4
51
+ [git-p4: depot-paths = "//depot/": change = 6]
52
53
-Remove file 3
54
-[git-p4: depot-paths = "//depot/": change = 5]
53
+ Remove file 3
54
+ [git-p4: depot-paths = "//depot/": change = 5]
55
56
-Add file 4
57
-[git-p4: depot-paths = "//depot/": change = 4]
56
+ Add file 4
57
+ [git-p4: depot-paths = "//depot/": change = 4]
58
59
-Add file 3
60
-[git-p4: depot-paths = "//depot/": change = 3]
59
+ Add file 3
60
+ [git-p4: depot-paths = "//depot/": change = 3]
61
62
-Add file 2
63
-[git-p4: depot-paths = "//depot/": change = 2]
62
+ Add file 2
63
+ [git-p4: depot-paths = "//depot/": change = 2]
64
65
-Add file 1
66
-[git-p4: depot-paths = "//depot/": change = 1]
65
+ Add file 1
66
+ [git-p4: depot-paths = "//depot/": change = 1]
67
68
EOF
69
git log --format=%B >actual &&
@@ -80,23 +80,23 @@ test_expect_success 'Clone repo subdir with all history but keep empty commits'
80
git config git-p4.keepEmptyCommits true &&
81
git p4 clone --use-client-spec --destination="$git" //depot@all &&
82
cat >expect <<-\EOF &&
83
-Remove file 4
84
-[git-p4: depot-paths = "//depot/": change = 6]
83
+ Remove file 4
84
+ [git-p4: depot-paths = "//depot/": change = 6]
85
86
-Remove file 3
87
-[git-p4: depot-paths = "//depot/": change = 5]
86
+ Remove file 3
87
+ [git-p4: depot-paths = "//depot/": change = 5]
88
89
-Add file 4
90
-[git-p4: depot-paths = "//depot/": change = 4]
89
+ Add file 4
90
+ [git-p4: depot-paths = "//depot/": change = 4]
91
92
-Add file 3
93
-[git-p4: depot-paths = "//depot/": change = 3]
92
+ Add file 3
93
+ [git-p4: depot-paths = "//depot/": change = 3]
94
95
-Add file 2
96
-[git-p4: depot-paths = "//depot/": change = 2]
95
+ Add file 2
96
+ [git-p4: depot-paths = "//depot/": change = 2]
97
98
-Add file 1
99
-[git-p4: depot-paths = "//depot/": change = 1]
98
+ Add file 1
99
+ [git-p4: depot-paths = "//depot/": change = 1]
100
101
EOF
102
git log --format=%B >actual &&
@@ -112,14 +112,14 @@ test_expect_success 'Clone repo subdir with all history' '
112
git init . &&
113
git p4 clone --use-client-spec --destination="$git" --verbose //depot@all &&
114
cat >expect <<-\EOF &&
115
-Remove file 3
116
-[git-p4: depot-paths = "//depot/": change = 5]
115
+ Remove file 3
116
+ [git-p4: depot-paths = "//depot/": change = 5]
117
118
-Add file 3
119
-[git-p4: depot-paths = "//depot/": change = 3]
118
+ Add file 3
119
+ [git-p4: depot-paths = "//depot/": change = 3]
120
121
-Add file 1
122
-[git-p4: depot-paths = "//depot/": change = 1]
121
+ Add file 1
122
+ [git-p4: depot-paths = "//depot/": change = 1]
123
124
EOF
125
git log --format=%B >actual &&