File: subst.sh

package info (click to toggle)
cssc 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,540 kB
  • ctags: 10,602
  • sloc: cpp: 39,776; sh: 16,907; ansic: 13,767; python: 3,923; makefile: 1,698; perl: 342; awk: 15
file content (95 lines) | stat: -rwxr-xr-x 2,677 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
#! /bin/sh

# Some substitution tests...


# Import common functions & definitions.
. ../common/test-common


# Get a test file...
f=keywords.txt
s=s.$f
output=get.output


remove $s $f
../../testutils/uu_decode --decode < keywords.uue || miscarry could not extract test file.

# Expand all the keywords from the s.file and save the format in 
# a temporary file.   We then examine this file later.
echo_nonl "Preparing..."
remove ${output}
if ${vg_get} -p $s > ${output} 2>/dev/null
then
    echo passed
else
    fail "$0: preparation step: could not run get -p."
fi

# Ckeck that the format of stderr is correct.
docommand "stderr format" "${vg_get} -p $s" 0 "IGNORE" "1.1\n83 lines\n"

expands_to () {
    # $1 -- format
    # $2 -- expansion
docommand "%${1}%" "egrep \"^_${1}_ \" <${output}" 0 "$2" ""
}

# Examine each of the things formatted into the file and
# check them against our expectations.

expands_to A "_A_ @(#) keywords.txt 1.1@(#)\n" 
expands_to B "_B_ 0\n"                         
expands_to C "_C_ 16\n_C_ 17\n"                
expands_to E "_E_ 97/10/25\n"                  
expands_to F "_F_ s.keywords.txt\n"            
expands_to G "_G_ 10/25/97\n"                  
expands_to I "_I_ 1.1\n" 
expands_to L "_L_ 1\n"                         
expands_to M "_M_ keywords.txt\n"	         
expands_to P "_P_ `../../testutils/realpwd`/s.keywords.txt\n"     
expands_to Q "_Q_ \n"                          
expands_to R "_R_ 1\n"                         
expands_to S "_S_ 0\n"                         
expands_to U "_U_ 13:19:31\n"                  
expands_to W "_W_ @(#)keywords.txt\t1.1\n"     
expands_to Y "_Y_ \n"                          
expands_to Z "_Z_ @(#)\n"                      

# TODO: better tests for Q, D, H, T, Y


# Test the -k flag, which disables keyword substitution.
if percents=`${vg_get} -p -k $s 2>/dev/null | tr -dc % | wc -c`
then
    if [ $percents -eq 68 ]
    then
	echo D1...passed
    else
	fail There should be 68 % signs in the gotten output with -k option.
    fi
else
    fail get without substitution should not fail here.
fi


remove $s $output

# Tests to make sure that the keyword substitution gets the right IDs
# and so forth when working with the -c date cutoff.
s=s.keys.txt
remove $s
../../testutils/uu_decode --decode < keys.uue || miscarry could not extract test file.
docommand K1 "${vg_get} -p -c971025230458 $s" 0 "1.2 1.2\n" "1.2\n1 lines\n"
docommand K2 "${vg_get} -p -c971025230457 $s" 0 "1.1 1.1\n" \
	"IGNORE"

# TODO: We currently say Excluded: blah... if a version is 
# excluded because of the cutoff date.  We should not do that.


# tests are finished.
remove $s
remove command.log
success