diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-30 09:09:02 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-30 09:09:02 -0500 |
| commit | 204bc6091b76c30e68a14cd2c3b948179b27c602 (patch) | |
| tree | 3fd7ae3bfc698a54c731ec6f512dc61f53066380 /tests/testutil-calendar-sync.el | |
| parent | ecf3d7952fa53f9f4fd57697526c7cce0c88f283 (diff) | |
| download | dotemacs-204bc6091b76c30e68a14cd2c3b948179b27c602.tar.gz dotemacs-204bc6091b76c30e68a14cd2c3b948179b27c602.zip | |
fix(test): anchor monthly tests on a day every month has
- The tests anchored on tomorrow, whose day varies by run date.
- A series on the 31st correctly skips months without one.
- That gave seven occurrences against an assertion of ten.
- The suite went red on the 30th and aborted the run.
A relative offset is not a date-independent anchor, which is what the file
header claimed it was. I added a helper that walks forward to the first day
at or below the 28th, and pointed the three cadence tests at it.
One assertion was also too weak to notice. It checked that each occurrence
fell on or before the anchor day, which a skipped month satisfies without
ever landing on the right day. It now checks equality.
Verified across 400 simulated run dates: no anchor past the 28th and no
count outside the expected band. The old anchor fails nine of those days.
Diffstat (limited to 'tests/testutil-calendar-sync.el')
| -rw-r--r-- | tests/testutil-calendar-sync.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/testutil-calendar-sync.el b/tests/testutil-calendar-sync.el index 2187c56c..60f878d0 100644 --- a/tests/testutil-calendar-sync.el +++ b/tests/testutil-calendar-sync.el @@ -172,6 +172,22 @@ Returns float number of days (positive if date2 > date1)." (t2 (calendar-sync--date-to-time (list (nth 0 date2) (nth 1 date2) (nth 2 date2))))) (/ (float-time (time-subtract t2 t1)) 86400.0))) +(defun test-calendar-sync-time-monthly-anchor (hour minute) + "Return a soon-future date on a day-of-month that every month has. +Walks forward from tomorrow to the first date whose day is 28 or less, then +returns it at HOUR:MINUTE. + +Use this instead of `test-calendar-sync-time-days-from-now' for any test that +asserts a monthly cadence. A relative offset is not a date-independent anchor: +its day-of-month varies with the run date, and a monthly series anchored on the +29th, 30th, or 31st correctly appears only in the months that have that day. A +test asserting roughly one occurrence per month then fails for several days each +month, which is what happened on 2026-07-30." + (let ((days 1)) + (while (> (nth 2 (test-calendar-sync-time-days-from-now days hour minute)) 28) + (setq days (1+ days))) + (test-calendar-sync-time-days-from-now days hour minute))) + (defun test-calendar-sync-wide-range () "Generate wide date range: 90 days past to 365 days future. Returns (start-time end-time) suitable for expansion functions." |
