File: 040_path_display

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 (117 lines) | stat: -rwxr-xr-x 2,264 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
#!/bin/bash

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

logfile=$LOGDIR/040.paths.log

seq 1 10 > tree/b/2/file-x

# Locally remove WC1, so that only WC matches
export WC1=barbaz


# Now test the filename display
function T
{
	path=$1
	pat=$2
	chg=${3:-.mC.}

	$BINdflt st $path -opath=$pathparm > $logfile
	if [[ `wc -l < $logfile` -ne 1 ]]
	then
		cat $logfile
		$ERROR "too many lines"
	fi

	if grep "^$chg \+[a-z0-9]\+ \+$pat" < $logfile > /dev/null
	then
		true
	else
		echo "path=$pathparm of $path ~~ $pat"
		echo '  '`cat $logfile`
		$ERROR "doesn't match $pat"
	fi
}

cd tree/b


pathparm=parameter
$INFO "testing '-opath=$pathparm'"
T "" "2/file-x"
T "." "./2/file-x"
T ".." "../b/2/file-x"
T "../a/.." "../a/../b/2/file-x"
T "2" "2/file-x"
T "2/file-x" "2/file-x"
T "../a/../b/2/file-x" "../a/../b/2/file-x"

for pathparm in environment full-environment
do
	$INFO "testing '-opath=$pathparm'"
	T "" "\$WC/tree/b/2/file-x"
	T "." "\$WC/tree/b/2/file-x"
	T ".." "\$WC/tree/b/2/file-x"
	T "../a/.." "\$WC/tree/b/2/file-x"
	# variable has only part of name
	export WCBLUBB=$WC/tre
	T "" "\$WC/tree/b/2/file-x"
	export WCBLUBB=$WC/tree/b/2
	T "../a/.." "\$WCBLUBB/file-x"
	WCBLUBB=
done

pathparm=wcroot
$INFO "testing '-opath=$pathparm'"
T ""         "./tree/b/2/file-x"
T "."        "./tree/b/2/file-x"
T "../b"     "./tree/b/2/file-x"
T "../a/.."  "./tree/b/2/file-x"
T "2"        "./tree/b/2/file-x"

pathparm=absolute
$INFO "testing '-opath=$pathparm'"
T ""         "$WC/tree/b/2/file-x"
T "."        "$WC/tree/b/2/file-x"
T "../b"     "$WC/tree/b/2/file-x"
T "../a/.."  "$WC/tree/b/2/file-x"


$INFO "checking for new entries"
mkdir -p h/j
pathparm=environment
T h/j "\$WC/tree/b/h/j" N...
WCBLUBB=$WC/tree/b/h T h/j "\$WC/tree/b/h/j" N...
pathparm=full-environment
T h/j "\$WC/tree/b/h/j" N...
WCBLUBB=$WC/tree/b/h T h/j "\$WCBLUBB/j" N...

$SUCCESS "Status output ok."


$INFO "Testing diff"
function D
{
	how=$1
	pat=$2
	$BINdflt diff 2 -opath=$how > $logfile
	if [[ `grep -c "$pat" < $logfile` -ne 3 ]]
	then
		$ERROR "Diff output wrong"
	fi
}

for x in environment full-environment
do
	D $x "\$WC/tree/b/2/file-x"
	WCBLUBB=$WC/tree/b D $x "\$WCBLUBB/2/file-x"
	WC=asf D $x "$WC/tree/b/2/file-x"
done


$SUCCESS "Diff output ok."