-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-examples.sh
More file actions
executable file
·129 lines (99 loc) · 4.64 KB
/
Copy pathgenerate-examples.sh
File metadata and controls
executable file
·129 lines (99 loc) · 4.64 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bash
set -euo pipefail
SCRIPT="./tries.py"
OUTDIR="EXAMPLES"
TESTDIR="${OUTDIR}/tests"
mkdir -p "$TESTDIR"
echo
echo "=========================================="
echo " tries — FEATURE TEST SUITE"
echo "=========================================="
echo
run_test() {
name="$1"
shift
args=( "$@" ) # preserve exact quoting
dotfile="${TESTDIR}/${name}.dot"
pngfile="${TESTDIR}/${name}.png"
echo " - ${name}"
echo " Command: $SCRIPT ${args[*]}"
"$SCRIPT" "${args[@]}" > "$dotfile"
dot -Tpng "$dotfile" -o "$pngfile"
}
echo
echo "- Running tests..."
echo
###############################################################################
# Character-mode tests
###############################################################################
run_test "hosts_default" --sample-hosts
run_test "hosts_TB" --sample-hosts -d TB
run_test "hosts_head" --sample-hosts -H
run_test "hosts_mark_nothing" --sample-hosts -M ''
run_test "hosts_mark_srv" --sample-hosts -M srv
run_test "hosts_mark_fw_and_sw" --sample-hosts -M fw sw
run_test "hosts_filter_fw" --sample-hosts -f fw
run_test "hosts_filter_fw_invert" --sample-hosts -f fw --invert-filter
run_test "hosts_ignore_case" --sample-hosts --ignore-case
run_test "hosts_keep_prefix" --sample-hosts --keep-prefix
run_test "hosts_keep_prefix_ignore_case" --sample-hosts --keep-prefix --ignore-case
run_test "hosts_keep_fqdn" --sample-hosts --keep-fqdn
run_test "hosts_no_labels" --sample-hosts --no-labels
#head sorting using nato
run_test "nato_head" --sample-nato -H
# head + no-labels (important behaviour case)
run_test "hosts_head_no_labels" --sample-hosts -H --no-labels
###############################################################################
# Token-mode tests
###############################################################################
run_test "ips_token" --sample-ips -D .
run_test "paths_token" --sample-paths -D /
run_test "urls_token" --sample-urls -D /
run_test "emails_token" --sample-emails -D @ --rtl
# head-mode ignored in token-mode
run_test "ips_token_head_ignored" --sample-ips -D . -H
# deeper marking in token-mode
run_test "paths_token_mark_share" --sample-paths -D / -M share
# mixed-case token-mode + ignore-case
run_test "paths_mixed_case_ignore" --sample-paths -D / --ignore-case
###############################################################################
# Token-mode corner cases
###############################################################################
# Empty input in token-mode (should not crash)
echo "" | run_test "empty_token_input" -D .
# Combined multiple datasets + delimiter + filter
run_test "combined_filter_token" --sample-hosts --sample-ips -D . -f 192
###############################################################################
# Combined samples (character-mode + token-mode)
###############################################################################
run_test "combined_hosts_ips" --sample-hosts --sample-ips -D .
run_test "combined_hosts_paths" --sample-hosts --sample-paths -D /
###############################################################################
# Theme sanity tests
###############################################################################
run_test "theme_default" --sample-hosts -T default
run_test "theme_midnight" --sample-hosts -T midnight
run_test "theme_hotdog" --sample-hosts -T hotdog
run_test "theme_tacky" --sample-hosts -T tacky-test
run_test "theme_none" --sample-hosts -T none
###############################################################################
# Override tests (only ONE of each type is needed)
###############################################################################
# Colour override test (one test is enough)
run_test "override_all_colours" \
--sample-hosts \
-cn red -cm green -ch blue -ce orange -cp purple
# Text (font colour) override test
run_test "override_all_text" \
--sample-hosts \
-tn red -tm green -th blue
# Font family test (single test)
run_test "font_menlo" \
--sample-hosts -F menlo
###############################################################################
echo
echo "- Test suite complete."
echo
echo "Tests: ${TESTDIR}/"
echo "=========================================="
echo