mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Add a timemachine tool script
- Wrapper around faketime - Provides an interface to run tests at specific points in time
This commit is contained in:
parent
42acf839d9
commit
68549dc22d
1 changed files with 46 additions and 0 deletions
46
test/timemachine
Normal file
46
test/timemachine
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
# parse options/arguments
|
||||
until [[ -z "${1}" ]] ; do
|
||||
case "${1}" in
|
||||
--minute)
|
||||
shift
|
||||
minutes="${minutes} ${1}"
|
||||
;;
|
||||
--hour)
|
||||
shift
|
||||
hours="${hours} ${1}"
|
||||
;;
|
||||
--day)
|
||||
shift
|
||||
days="${days} ${1}"
|
||||
;;
|
||||
--fail-at-end)
|
||||
fail_at_end=1
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option '${1}'"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
tests="${tests} ${1}"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
for day in ${days-$(date --rfc-3339=date)} ; do
|
||||
for minute in ${minutes-$(echo "0$(rand -M 60)" | sed "s|.\+\(..\)\$|\1|g")} ; do
|
||||
for hour in ${hours-$(seq -w 0 23)} ; do
|
||||
date="${day}T${hour}:${minute}"
|
||||
for single_test in ${tests} ; do
|
||||
echo "Running test ${single_test} at ${date}"
|
||||
faketime "@${date}" "${single_test}"
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
echo "Test ${single_test} broke at ${date}!"
|
||||
[[ ${fail_at_end-0} -ne 0 ]] || break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue