File: 027_recursive

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 (134 lines) | stat: -rwxr-xr-x 3,754 bytes parent folder | download | duplicates (4)
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
#!/bin/bash

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

LOGFILE=$LOGDIR/027.recursive

mkdir -p 1/2/3/4/5/6
mkdir 1/2/3/4/5/d
list="1/2/3/4/5/6 1/2/3/4 1/2"
for f in $list
do
	echo $f > $f-changed
	echo $f > $f-same
done
# commit some of the files
$BINdflt ci -m 1 -q -o delay=yes
$WC2_UP_ST_COMPARE

for n in new changed
do
	for f in $list
	do
		echo $n `date` > $f-$n
	done
done
# Change directories' mtime
touch $list
# remove directory
rmdir 1/2/3/4/5/d


function check
{
# Action, Parameter, Nr. of expected lines, Message
	msg="$4"

# If we do a status, we'll have a logfile anyway.
# If it's a revert, it might be nice to see whe WC before.
	if [[ "$1" == "status" ]]
	then
		rm $LOGFILE.status 2> /dev/null || true
	else
		$BINdflt status -C -C > $LOGFILE.status
	fi

	$BINdflt $1 $2 > $LOGFILE
	lns=`wc -l < $LOGFILE`
	if [[ $lns -ne "$3" ]]
	then
		$ERROR "$msg failed - wrong number of output lines (exp $3, got $lns)."
	fi

	shift 4
	while [[ "$1" != "" ]]
	do
		if [[ `grep $1 < $LOGFILE | wc -l` -ne $2 ]]
		then
			$ERROR_NB "$msg"
			cat $LOGFILE
			$ERROR "expected $2*$1."
		fi
		shift 2
	done

	$SUCCESS "$msg"
}

function status
{
	check status "$@"
}

function revert
{
	check revert "$@"
}

status "" 13 "Recursive status from root" changed 3 new 3 same 0
status "1/2/3" 9 "Partial recursive status" changed 2 new 2 same 0
status "1/2/3 -N" 4 "Partial non-recursive status" changed 1 new 1 same 0
status "1/2/3 -N -N" 1 "Partial atomic status" changed 0 new 0 same 0
status "1/2/3/4/5/6?* -N -N" 2 "Status with wildcard" changed 1 new 1 same 0
status "1/2/3/4/5/6?* -N -N -v" 3 "Verbose status with wildcard" changed 1 new 1 same 1


# Revert prints the revision it reverts to, so we get an extra line.
revert "1/2/3/4/5/d" 2 "Revert of directory deletion" /d 1 changed 0 same 0 new 0
revert "1/2/3/4/5/6-changed" 2 "Single revert" changed 1 same 0 new 0
status "1/2/3/4/5/6-changed -v" 1 "Status after revert" changed 1 same 0 new 0 "-F ....." 1
status "1/2/3/4/5 -v" 6 "Status after revert" changed 1 same 1 new 1 /d 1 \
			"-F ......" 3 "-F ....C." 1 "-F .t...." 1

echo $RANDOM > 1/2/3/4/5/6-changed
revert "1/2/3/" 4 "Non-recursive revert" changed 1 same 0 new 0 ".m.?" 2 dir 2

status "1/2/3/4/5 -v" 6 "Status after revert" changed 1 same 1 new 1 /d 1 \
			"-F ......" 2 "-F ....C." 1 "-F .t..C." 1 "-F .t...." 1

# The two changed entries get reverted, and their directories the mtime 
# reset. The directory 3 has already been done, so 1, 2 and 6 get reported 
# as possibly changed.

# WHY is 6-new not found???

revert ". -R" 6 "Recursive revert" changed 2 same 0 new 0 mC 2 "^\.m\." 3
status "." 6 "Status after revert" new 3 changed 0 same 0
status ". -v" 17 "Verbose status after revert" new 3 changed 3 same 3 "-F ......" 11

# Don't try this at home!
rm -r *
revert ". -R -o delay=yes" 15 "Full revert" changed 3 same 3 /d 1 new 0 dir 8 5/6 3
# Now the status is empty - all is like it was.
status "." 0 "Rec st after full revert" changed 0 new 0 same 0 "-F ......" 0
status ". -v" 14 "Rec verb st after full revert" changed 3 new 0 same 3 "-F ......" 14 /d 1
$WC2_UP_ST_COMPARE

for f in $list
do
	echo something-else > $f-changed
	echo something-else > $f-same
done

# Directories whose entries got changed don't get a new mtime!
revert ". -R -o delay=yes" 7 "Full revert 2" changed 3 same 3 /d 0 new 0 ./1/2 6
# But that doesn't work for the root directory ... so we touch it, then we 
# know exactly what to test for.
touch .
# Now the status is (nearly) empty - all is like it was.
status "." 1 "Rec st after full revert 2" changed 0 new 0 same 0 "-F ...." 0 "-F .m.." 1
status ". -v" 14 "Rec verb st after full revert 2" changed 3 new 0 same 3 "-F ....." 13 /d 1 "-F .t...." 1
$WC2_UP_ST_COMPARE