~sircmpwn/scdoc

ref: f092f83bcfe5e6ec648c4991ad2f6cf5ea23bb0e scdoc/test/preamble -rwxr-xr-x 1.5 KiB View raw
f092f83bRaymond E. Pasco Fix `date --date` dependent test 2 months ago
                                                                                
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
#!/bin/sh
. test/lib.sh

begin "Expects a name"
scdoc <<EOF >/dev/null
(8)
EOF
end 1

begin "Expects a section"
scdoc <<EOF >/dev/null
test
EOF
end 1

begin "Expects name to alphanumeric"
scdoc <<EOF >/dev/null
!!!!(8)
EOF
end 1

begin "Expects section to be a number"
scdoc <<EOF >/dev/null
test(hello)
EOF
end 1

begin "Expects section to legit"
scdoc <<EOF >/dev/null
test(100)
EOF
end 1

begin "Accepts a valid preamble"
scdoc <<EOF >/dev/null
test(8)
EOF
end 0

# Make sure SOURCE_DATE_EPOCH is not set for the next tests
unset SOURCE_DATE_EPOCH

begin "Writes the appropriate header"
scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date -u +'%F')"'"' >/dev/null
test(8)
EOF
end 0

begin "Preserves dashes"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'"' >/dev/null
test-manual(8)
EOF
end 0

begin "Handles extra footer field"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'" "Footer"' >/dev/null
test-manual(8) "Footer"
EOF
end 0

begin "Handles both extra fields"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'" "Footer" "Header"' >/dev/null
test-manual(8) "Footer" "Header"
EOF
end 0

begin "Emits empty footer correctly"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'" "" "Header"' >/dev/null
test-manual(8) "" "Header"
EOF
end 0

export SOURCE_DATE_EPOCH=1512861537

begin "Supports \$SOURCE_DATE_EPOCH"
scdoc <<EOF | grep '^\.TH "reproducible-manual" "8" "2017-12-09"' >/dev/null
reproducible-manual(8)
EOF
end 0