job-specifier: Adapt 'bump-time' to 'next-...-from' procedures

This is a follow-up to commit 913e3c65e4.

Since 'next-...-from' procedures now uses an '#:optional' argument
instead of a dotted optional arguments list, 'bump-time' doesn't need to
unwrap VALUE-LIST anymore.

* src/mcron/job-specifier.scm (bump-time): Pass VALUE-LIST directly to
'%find-best-next'.
* tests/job-specifier.scm ("next-hour-from"): New test.
* NEWS: Update.

Reported-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Mathieu Lirzin 2018-03-26 16:56:40 +02:00
commit f71b0b8310
No known key found for this signature in database
GPG key ID: 0ADEE10094604D37
3 changed files with 19 additions and 15 deletions

6
NEWS
View file

@ -10,6 +10,12 @@ GNU Mcron NEWS -*- outline -*-
The programs now sets the GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH
environment variables with the location of the installed Guile modules.
'next-year-from', 'next-year', 'next-month-from', 'next-month',
'next-day-from', 'next-day', 'next-hour-from', 'next-hour',
'next-minute-from', 'next-minute', 'next-second-from', and 'next-second' no
longer crashes when passing an optional arguments.
[bug introduced in mcron-1.1]
** Improvements
Some basic tests for the installed programs can be run after 'make install'

View file

@ -85,21 +85,15 @@ go into the list. For example, (range 1 6 2) returns '(1 3 5)."
;;
;; ... except that the function is actually generalized to deal with
;; seconds, minutes, etc., in an obvious way :-)
;;
;; Note that value-list always comes from an optional argument to a
;; procedure, so is wrapped up as the first element of a list (i.e. it is a
;; list inside a list).
(match value-list
(()
(set-component! time (1+ (component time))))
((val . rest)
(match (%find-best-next (component time) val)
((smallest . closest+)
(cond ((inf? closest+)
(set-higher-component! time (1+ (higher-component time)))
(set-component! time smallest))
(else
(set-component! time closest+)))))))
(if (null? value-list)
(set-component! time (1+ (component time)))
(match (%find-best-next (component time) value-list)
((smallest . closest+)
(cond ((inf? closest+)
(set-higher-component! time (1+ (higher-component time)))
(set-component! time smallest))
(else
(set-component! time closest+))))))
(first (mktime time)))
;; Set of configuration methods which use the above general function to bump

View file

@ -49,4 +49,8 @@
(match (pk 'match (%find-best-next 1 '(0 2)))
((a . b) (and (exact? a) (exact? b)))))
(test-equal "next-hour-from"
7200
(next-hour-from 10 '(0 3 7)))
(test-end)