summaryrefslogtreecommitdiffstats
path: root/debian/tests/yangre
blob: 7ef17f95668386080cbf9a6f4cd6eb41d46ae714 (plain)
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
#!/bin/sh

set -e

cleanup() {
    if [ -n "${patternsfile}" ]; then
        rm -f "${patternsfile}"
    fi
}
trap cleanup EXIT

# All these tests were taken from the yangre(1) manpage
echo "Testing plain regular expression"
yangre -p 'te.*xt' text_text

echo "Testing multiple patterns"
yangre -p '.*pat1' -p 'pat2.*' pat2testpat1

echo "Testing multiple patterns including an inverted one"
yangre -p '.*pat1' -p 'pat2.*' -p 'notpat' -i pat2testpat1

echo "Testing multiple patterns, including an inverted one, via a file"
patternsfile=$(mktemp)
cat > "${patternsfile}" <<EOF
.*pat1
pat2.*
 notpat

pat2testpat1
EOF
yangre -f "${patternsfile}"