mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unittest - Enhanced support for testing hooks (wip)
* It is now possible to test: * Hook Input/Output on STDIN/STDOUT channels * Exit code of hook script * Execution count (how many times the hook was executed) * Timestamp execution (when was the hook executed - milisec resolution)
This commit is contained in:
parent
9ea61e25e8
commit
d261a38d17
9 changed files with 569 additions and 141 deletions
10
test/test_hooks/on-add.dummy
Normal file
10
test/test_hooks/on-add.dummy
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "on-add executed"
|
||||
|
||||
while read TASK; do
|
||||
echo "New task $TASK"
|
||||
echo $TASK
|
||||
done
|
||||
|
||||
exit 0
|
9
test/test_hooks/on-exit.dummy
Normal file
9
test/test_hooks/on-exit.dummy
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "on-exit executed"
|
||||
|
||||
while read TASK; do
|
||||
echo "New/modified task $TASK"
|
||||
done
|
||||
|
||||
exit 0
|
5
test/test_hooks/on-launch.dummy
Normal file
5
test/test_hooks/on-launch.dummy
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "on-launch executed"
|
||||
|
||||
exit 0
|
10
test/test_hooks/on-modify.dummy
Normal file
10
test/test_hooks/on-modify.dummy
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "on-modify executed"
|
||||
|
||||
while read TASK MODTASK; do
|
||||
echo "Existing task $TASK modified to $MODTASK"
|
||||
echo $MODTASK
|
||||
done
|
||||
|
||||
exit 0
|
16
test/test_hooks/wrapper.sh
Normal file
16
test/test_hooks/wrapper.sh
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
SELF=$(basename $0)
|
||||
ORIGINALHOOK="$(dirname $0)/original_${SELF}"
|
||||
IN="${NEWFILE}.log.in"
|
||||
OUT="${NEWFILE}.log.out"
|
||||
|
||||
# Let it know that we were executed
|
||||
echo "% Called at $(date +%s%N)" >> ${OUT}
|
||||
|
||||
$ORIGINALHOOK < <(tee -a ${IN}) > >(tee -a ${OUT})
|
||||
|
||||
EXITCODE=$?
|
||||
echo "! Exit code: ${EXITCODE}" >> ${OUT}
|
||||
|
||||
exit $EXITCODE
|
Loading…
Add table
Add a link
Reference in a new issue