File: options.sh

package info (click to toggle)
cssc 1.0.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,612 kB
  • ctags: 1,424
  • sloc: cpp: 13,502; sh: 4,759; ansic: 2,971; perl: 342; makefile: 339; awk: 11
file content (85 lines) | stat: -rw-r--r-- 2,276 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
#! /bin/sh
# options.sh:  Testing for the various command-line options of "delta".

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

remove command.log log log.stdout log.stderr
mkdir test 2>/dev/null

g=foo
s=s.$g
p=p.$g
z=z.$g
files="$g $s $p $z ${g}_1 ${g}_2"

remove $files

append() {
   f="$1"
   shift
   echo  "$@" >> "$f" || miscarry "Could not append a line to $1" 
}


test -d test || mkdir test || miscarry "Could not create subdirectory 'test'" >&2

exec </dev/null

# Do some setup.
docommand o1 "${admin} -n $s" 0 IGNORE IGNORE

docommand o2 "${get} -e $s" 0 IGNORE IGNORE
append $g "hello, world"
docommand o3 "${delta} -r1.1 -yFirst $s" 0 \
 "1.2\n1 inserted\n0 deleted\n0 unchanged\n" IGNORE

docommand o4 "${get} -e $s" 0 IGNORE IGNORE
append $g "hello, world"


# The -s option should suppress output to stdout.
docommand o5 "${delta} -s -r1.2 -ySecond $s" 0 "" IGNORE

# Now we have deltas 1.1, 1.2 and 1.3.

# Now edit the same file twice (but different SIDs)
docommand o6 "${admin} -dj $s" 0 IGNORE IGNORE
docommand o7 "${get} -r1.1 -e -p $s > ${g}_1" 0 IGNORE IGNORE
append ${g}_1 "this is appended to file 1"

docommand o8 "${get} -r1.2 -e -p $s > ${g}_2" 0 IGNORE IGNORE
append ${g}_2 "this is appended to file 2"



mv ${g}_1 ${g} || miscarry "Could not rename ${g}_1 to ${g}"

# Failure to specify an SCCS file name is an error.
docommand o9 "${delta} -r1.2.1.1 -yBranch1" 1 IGNORE IGNORE

# Unknown command line option is an error (we pick an unlikely one)
docommand o10 "${delta}"' -! -yBranch1' 1 IGNORE IGNORE

# Ambiguity in SID selection is an error
docommand o11 "${delta} -r1 -yBranch1 $s" 1 IGNORE IGNORE
docommand o12 "${delta} -yBranch1 $s" 1 IGNORE IGNORE

# Invalid branch should be detected (note return value 2 not 1)
docommand o13 "${delta} -r1.2.1.1a -yBranch2 $s" 1 IGNORE IGNORE

docommand o14 "${delta} -r1.1.1.1 -yBranch1 $s" 0 IGNORE IGNORE

# the p-file should still exist
docommand o15 "test -r $p" 0 "" ""

mv ${g}_2 ${g} || miscarry "Could not rename ${g}_2 to ${g}"
docommand o16 "${delta} -r1.2.1.1 -p -yBranch2 $s" 0 \
"1.2.1.1\n1a2\n> this is appended to file 2\n1 inserted\n0 deleted\n1 unchanged\n" IGNORE

# the p-file should now be gone
docommand o17 "test -r $p" 1 "" ""

remove $files 
success