aboutsummaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorTimon Reinold <tirei+aerc@agon.one>2024-07-19 20:20:20 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-04 17:48:45 +0200
commita794349a40f13da676928e5793e823bbb6912234 (patch)
treea3f5e308750913414a13dc6b718bd14a99390b58 /filters
parentb55db9bbda0aaffae3e59919e3d460ba935d8c22 (diff)
downloadaerc-a794349a40f13da676928e5793e823bbb6912234.tar.gz
filters: add calendar test vector
Add a test vector for the builtin "calendar" filter. Use the filter's current output as expected output. My aim is mostly just to run the calendar filter during "make tests", this vector doesn't necessarily cover the most interesting sections of its code. But at least running the filter once on what could be a common input (a meeting PUBLISH) and checking that its output matches what was expected should still be better than testing nothing. Previously, only compiled filters were tested. Testing the calendar filter (which is interpreted, not compiled) necessitated two changes: * Compilation output goes into the project root (filters/test.sh: "$here/../"), but the source code to interpret is in the filters/ subdirectory (filters/test.sh: "$here"/). The executable to invoke is thus in a different location. * .builds/alpine-edge.yml uses $FILTERS_TEST_PREFIX to wrap filters in valgrind, to check that filters written in e.g C don't leak memory. But for the calendar filter, that would check that the Awk interpreter doesn't leak memory, failing the test for at least gawk, mawk and busybox awk. Thus, a $FILTERS_TEST_BIN_PREFIX variable is introduced, which only applies to binary filters. Signed-off-by: Timon Reinold <tirei+aerc@agon.one> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'filters')
-rwxr-xr-xfilters/test.sh8
-rw-r--r--filters/vectors/calendar-invite.expected14
-rw-r--r--filters/vectors/calendar-invite.in15
3 files changed, 35 insertions, 2 deletions
diff --git a/filters/test.sh b/filters/test.sh
index ea04235a..dc5ac265 100755
--- a/filters/test.sh
+++ b/filters/test.sh
@@ -34,11 +34,15 @@ export AERC_STYLESET=$style
export AERC_OSC8_URLS=1
for vec in $here/vectors/*.in; do
- tool=$(basename $vec | sed 's/-.*//')
expected=${vec%%.in}.expected
+ tool=$(basename $vec | sed 's/-.*//')
+ tool_bin=$here/../$tool
+ prefix="$FILTERS_TEST_PREFIX $FILTERS_TEST_BIN_PREFIX"
+ # execute source directly (and omit $...BIN_PREFIX) for interpreted filters
+ [ -f $tool_bin ] || { tool_bin=$here/$tool; prefix="$FILTERS_TEST_PREFIX"; }
tmp=$(mktemp)
status=0
- $FILTERS_TEST_PREFIX $here/../$tool -f $vec > $tmp || status=$?
+ $prefix $tool_bin < $vec > $tmp || status=$?
if [ $status -eq 0 ] && diff -u "$expected" "$tmp"; then
echo "ok $tool < $vec > $tmp"
else
diff --git a/filters/vectors/calendar-invite.expected b/filters/vectors/calendar-invite.expected
new file mode 100644
index 00000000..4cd61485
--- /dev/null
+++ b/filters/vectors/calendar-invite.expected
@@ -0,0 +1,14 @@
+
+ This is a meeting PUBLISH
+
+ SUMMARY Test Event
+ START 2000/01/01 12:30:00
+ END 2999/12/31 32:30:00
+ LOCATION Some Location
+ ORGANIZER <invalid@example.org>
+ ATTENDEES
+
+ DETAILED LIST:
+
+A description.
+With multiple lines.
diff --git a/filters/vectors/calendar-invite.in b/filters/vectors/calendar-invite.in
new file mode 100644
index 00000000..ff456750
--- /dev/null
+++ b/filters/vectors/calendar-invite.in
@@ -0,0 +1,15 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//hacksw/handcal//NONSGML v1.0//EN
+CALSCALE:GREGORIAN
+METHOD:PUBLISH
+BEGIN:VEVENT
+DESCRIPTION:A description.\nWith multiple lines.
+DTEND:29991231T323000Z
+DTSTAMP:19990101T000000Z
+DTSTART:20000101T123000Z
+LOCATION:Some Location
+ORGANIZER:MAILTO:invalid@example.org
+SUMMARY:Test Event
+END:VEVENT
+END:VCALENDAR