| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | . test/lib.shscip-shell source . . `test/lib.sh`. |
| 3 | |
| 4 | begin "Expects a name" |
| 5 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 6 | (8) |
| 7 | EOF |
| 8 | end 1 |
| 9 | |
| 10 | begin "Expects a section" |
| 11 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 12 | test |
| 13 | EOF |
| 14 | end 1 |
| 15 | |
| 16 | begin "Expects a section within the parentheses" |
| 17 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 18 | test() |
| 19 | EOF |
| 20 | end 1 |
| 21 | |
| 22 | begin "Expects name to alphanumeric" |
| 23 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 24 | !!!!(8) |
| 25 | EOF |
| 26 | end 1 |
| 27 | |
| 28 | begin "Expects section to start with a number" |
| 29 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 30 | test(hello) |
| 31 | EOF |
| 32 | end 1 |
| 33 | |
| 34 | begin "Expects section to be legit" |
| 35 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 36 | test(100) |
| 37 | EOF |
| 38 | end 1 |
| 39 | |
| 40 | begin "Expects section to be legit with subsection" |
| 41 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 42 | test(100hello) |
| 43 | EOF |
| 44 | end 1 |
| 45 | |
| 46 | begin "Expects section not to contain a space" |
| 47 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 48 | test(8 hello) |
| 49 | EOF |
| 50 | end 1 |
| 51 | |
| 52 | begin "Accepts a valid preamble" |
| 53 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 54 | test(8) |
| 55 | EOF |
| 56 | end 0 |
| 57 | |
| 58 | begin "Accepts a valid preamble with subsection" |
| 59 | scdoc <<EOF >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 60 | test(8hello) |
| 61 | EOF |
| 62 | end 0 |
| 63 | |
| 64 | # Make sure SOURCE_DATE_EPOCH is not set for the next tests |
| 65 | unset SOURCE_DATE_EPOCH |
| 66 | date_escaped="$(datescip-shell system . . date. -u +'%F' | sedscip-shell system . . sed. 's/-/\\\\-/g')" |
| 67 | |
| 68 | begin "Writes the appropriate header" |
| 69 | scdoc <<EOF | grepscip-shell system . . grep. '^\.TH "test" "8" "'"${date_escaped}"'"' >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 70 | test(8) |
| 71 | EOF |
| 72 | end 0 |
| 73 | |
| 74 | begin "Preserves dashes and add escaping" |
| 75 | scdoc <<EOF | grepscip-shell system . . grep. '^\.TH "test\\-manual" "8" "'"${date_escaped}"'"' >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 76 | test-manual(8) |
| 77 | EOF |
| 78 | end 0 |
| 79 | |
| 80 | begin "Handles extra footer field" |
| 81 | scdoc <<EOF | grepscip-shell system . . grep. '^\.TH "test\\-manual" "8" "'"${date_escaped}"'" "Footer"' >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 82 | test-manual(8) "Footer" |
| 83 | EOF |
| 84 | end 0 |
| 85 | |
| 86 | begin "Handles both extra fields" |
| 87 | scdoc <<EOF | grepscip-shell system . . grep. '^\.TH "test\\-manual" "8" "'"${date_escaped}"'" "Footer" "Header"' >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 88 | test-manual(8) "Footer" "Header" |
| 89 | EOF |
| 90 | end 0 |
| 91 | |
| 92 | begin "Emits empty footer correctly" |
| 93 | scdoc <<EOF | grepscip-shell system . . grep. '^\.TH "test\\-manual" "8" "'"${date_escaped}"'" "" "Header"' >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 94 | test-manual(8) "" "Header" |
| 95 | EOF |
| 96 | end 0 |
| 97 | |
| 98 | export SOURCE_DATE_EPOCH=1512861537 |
| 99 | |
| 100 | begin "Supports \$SOURCE_DATE_EPOCH" |
| 101 | scdoc <<EOF | grepscip-shell system . . grep. '^\.TH "reproducible\\-manual" "8" "2017\\-12\\-09"' >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 102 | reproducible-manual(8) |
| 103 | EOF |
| 104 | end 0 |