File: 020_partial_ci

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (266 lines) | stat: -rwxr-xr-x 5,883 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/bash

set -e 
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS
cd $WC

dir1=dA
dir2=dB
dir3=dC
dir31=dC/dA
dir32=dC/dB
dir4=dD
dirN=dNew

file11=$dir1/1
file12=$dir1/2
file21=$dir2/1
file22=$dir2/2
file41=$dir4/1

log=$LOGDIR/020.logfile


if [[ "$VERBOSE" == 1 ]]
then
#	BINdflt="$BINdflt -d"
 true
fi

function ChangeData
{
	for dir in d? d?/d?
	do
		[ -e $dir ] || continue
		for file in 1 2
		do
			echo "A testline " > $dir/$file
			dd if=/dev/zero bs=$RANDOM count=1 >> $dir/$file 2>/dev/null
		done
	done
}


mkdir $dir1
$BINq ci -m "def dir"

# Test empty_commit option.
# We cannot use $REPURL, as that includes subdirectories within the 
# repository, which don't get touched - we see the revision only at the 
# repository root.
msg="EMPTY_COMMIT"
if $BINdflt ci -m "$msg" -o empty_commit=no | grep "Avoiding empty commit as requested." &&
	! ( svn log $REPURLBASE | grep "$msg" )
then
	$SUCCESS "Empty commit avoided"
else
  $ERROR "Always commits?"
fi

if $BINdflt ci -m "$msg" -o empty_commit=yes &&
	svn log -r HEAD $REPURLBASE | grep "$msg"
then
	$SUCCESS "Empty commit done"
else
  $ERROR "Doesn't commit when empty?"
fi


ChangeData

$BINdflt ci -m "new file" $file11 > $log
# file, directory
# The / is necessary to exclude the directory itself, but to include
# the other file, if it should show up.
if [[ `grep $dir1/ < $log | wc -l` -eq 1 ]]
then
  $SUCCESS "Ok, commit of a file beneath another new file works"
else
	cat $log
  $ERROR "wrong data committed (1); only $file11 expected!"
fi

$BINdflt ci -m "new file2" $dir1 -o delay=yes > $log
if [[ `grep $dir1 < $log | wc -l` -eq 2 ]]
then
  $SUCCESS "commit of a file beneath a committed file works"
else
	cat $log
  $ERROR "wrong data committed (2); only $dir1 and $file12 expected!"
fi


mkdir $dir2

ChangeData


$BINdflt ci -m "new file" $file21 > $log
if [[ `grep $dir2 < $log | wc -l` -eq 2 ]]
then
  $SUCCESS "commit of a changed file beneath another changed file works"
else
	cat $log
  $ERROR "wrong data committed (3); only $file21 expected!"
fi

if false
then
# This test currently doesn't work - that's the same bug as
# with an update-before-commit.
	$BINdflt st
	# now the directory should still show as changed:
	if [[ `$BINdflt st | grep $dir2 | wc -l` -eq 1 ]]
	then
		$SUCCESS "directory still shows as changed"
	else
		$BINdflt st
		$ERROR "directory isn't seen as changed"
	fi
fi

# This time the directory gets committed, too - so it will be stored
# with correct values and won't show as changed.
$BINdflt ci -m "new dir" $dir2 -o delay=yes > $log
if [[ `grep $dir2 $log | wc -l` -eq 2 ]]
then
  $SUCCESS "commit of a single directory works"
else
	cat $log
  $ERROR "wrong data committed (4); only 2 lines expected!"
fi


# Now test for an initial commit - where no previous dir file exists.
# Remove file list ...
rm `$PATH2SPOOL $WC dir`
mv $dir1 $dirN
$BINdflt ci -m "new dir" $dirN > $log
if [[ `grep -F " $dirN" < $log | wc -l` -eq 3 ]]
then
  $SUCCESS "initial commit works"
else
	cat $log
  $ERROR "wrong data committed (5); only 3 lines expected!"
fi


# A more complex commit, fails with unpatched fsvs 1.0.15...
rm `$PATH2SPOOL $WC dir`
mkdir $dir3 $dir4 $dir31 $dir32
$BINdflt ci -m "new dir, more complex case" $dir31 > $log
if [[ `grep -F " $dir31" < $log | wc -l` -eq 1 ]]
then
  $SUCCESS "complex initial commit works"
else
	cat $log
  $ERROR "wrong data committed (6); only 2 lines expected!"
fi


ChangeData

$BINdflt sync-repos -q

$BINdflt ci -m "changed files after sync-repos" ./$dir31 > $log
if [[ `grep -F ./ < $log | wc -l` -eq 3 ]]
then
  $SUCCESS "complex partial commit after sync-repos works"
else
	cat $log
  $ERROR "wrong data committed (7); expected 'committing to,dir,2files,revX'"
fi


$BINq ci -m "known state"
$WC2_UP_ST_COMPARE


# Now change data, and look whether filtering works.
function TT
{
	expected=$1
	do_changes=$3
	other_changes=$4

	if [[ "$do_changes" == "" ]] ; then ChangeData ; fi

	$BINdflt st $2 > $log
	if [[ `grep -F ./ < $log | wc -l` -ne $expected ]]
	then
		cat $log
		$ERROR "Filtered status for '$2' expected $expected entries."
	fi

	$BINdflt ci -m "options are $2, expect $expected" $2 > $log
	if [[ `grep -F ./ < $log | wc -l` -ne $expected ]]
	then
		cat $log
		$ERROR "Filtered commit for '$2' expected $expected entries."
	fi

	# We cannot easily compare with WC2 here, because there are many changed 
	# entries, and only a few get committed.
	# But we can check if there are still changes here.
	$BINdflt st $2 > $log
	if [[ `wc -l < $log` -ne 0 ]]
	then
		cat $log
		$ERROR "Still changes after 'commit $2'."
	fi

	if [[ "$other_changes" != "" ]]
	then
		# Expect some changes.
		$BINdflt st > $log
		if [[ `wc -l < $log` -ne $other_changes ]]
		then
			$ERROR "Expected $other_changes changes after 'commit $2'"
		fi
	fi

	$SUCCESS "Filtered commit for '$2' successful."
	$BINq	delay
}

# Simple: all data files changed, no new or deleted entries - so no 
# directory modifications.
TT 10 "."

# The directory is, depending on the time dependency, marked as changed, 
# too. To get a definitive answer we'll manually touch it.
echo aaaa > dB/Newwww
touch -d"2008-1-1 4:5:6" dB
# expect 1 file, afterwards 1 timestamp
TT 1 "-f new ." 1
rm dB/Newwww
# expect 1 file, afterwards 1 timestamp
TT 1 "-f deleted ." 1

# Other entries may not be recorded.
$INFO "Testing that other entries are not recorded"
echo > $file41
echo aaaa > dB/Newwww2
# We expect a single file to be committed; afterwards all other 9 data 
# files are changed, and "dB" (mtime).
TT 1 "-f new ." "" 11

# Now commit all changed entries; keeps "dB" as mtime.
TT 10 "-f text ." 1

# Now sync ... - no changes anymore.
$BINq ci -m sync1
$WC2_UP_ST_COMPARE


echo a > new1
echo a > $dir31/new2
rm $file41
# We expect ".", "dD" and "dC/dA" to be "mtime"
TT 3 "-f new,deleted ." no-change-data 3

# Sync again ...
$BINq ci -m sync2
$WC2_UP_ST_COMPARE