fix: improve rollover date comparison logic in Test 0

- Fix date comparison to check alarm date against current date, not initial alarm date
- Remove false warning when alarm date unchanged but scheduled for future (correct behavior)
- Only warn if alarm date is in the past (actual failure case)
- Improve logic flow: date change confirms rollover, but rollover logs are primary indicator
- When dates match but alarm is scheduled for today/future, defer to rollover log check

This fixes the confusing warning message that appeared when:
- Initial alarm scheduled for tomorrow (2025-12-31)
- Notification fires and rollover reschedules for same tomorrow date
- Rollover logs confirm rollover occurred, but date comparison incorrectly warned

The test now correctly recognizes that an alarm scheduled for the future
is valid, and relies on rollover logs as the primary verification method.
This commit is contained in:
Matthew Raymer
2025-12-30 07:53:23 +00:00
parent 39eed856f5
commit 7b1f1200bc

View File

@@ -824,18 +824,36 @@ main() {
info "Post-rollover alarm time: ${post_rollover_alarm_time} (normalized)" info "Post-rollover alarm time: ${post_rollover_alarm_time} (normalized)"
# Verify alarm time changed (rollover occurred) # Verify alarm time changed (rollover occurred)
# Compare dates only (YYYY-MM-DD) to detect day change # Compare alarm date to current date - if alarm is scheduled for tomorrow or later, rollover worked
if [ -n "${initial_alarm_time}" ] && [ -n "${post_rollover_alarm_time}" ]; then if [ -n "${post_rollover_alarm_time}" ]; then
local initial_date=$(echo "${initial_alarm_time}" | cut -d' ' -f1) local current_date=$(date +%Y-%m-%d)
local post_date=$(echo "${post_rollover_alarm_time}" | cut -d' ' -f1) local post_date=$(echo "${post_rollover_alarm_time}" | cut -d' ' -f1)
if [ "${initial_date}" != "${post_date}" ]; then # Compare dates: if alarm date is >= current date, it's scheduled for today or future (correct)
ok "Alarm date changed: ${initial_alarm_time}${post_rollover_alarm_time}" # If we also have initial_alarm_time, check if it advanced
rollover_verified=true if [ -n "${initial_alarm_time}" ]; then
local initial_date=$(echo "${initial_alarm_time}" | cut -d' ' -f1)
if [ "${initial_date}" != "${post_date}" ]; then
ok "Alarm date changed: ${initial_alarm_time}${post_rollover_alarm_time}"
rollover_verified=true
elif [ "${post_date}" \> "${current_date}" ] || [ "${post_date}" = "${current_date}" ]; then
# Alarm is scheduled for today or future - this is correct
# If initial was also tomorrow, that's fine - rollover logs will confirm it occurred
info "Alarm scheduled for ${post_date} (current: ${current_date}) - date unchanged from initial, checking rollover logs"
# Don't set rollover_verified yet - let log check determine it
else
warn "Alarm date ${post_date} is in the past (current: ${current_date}) - rollover may have failed"
rollover_verified=false
fi
else else
warn "Alarm date did NOT change: ${post_rollover_alarm_time} (same date as initial: ${initial_date})" # No initial alarm time to compare, just check if it's scheduled for future
warn "This indicates the notification did not fire and rollover did not occur" if [ "${post_date}" \> "${current_date}" ] || [ "${post_date}" = "${current_date}" ]; then
rollover_verified=false info "Alarm scheduled for ${post_date} (current: ${current_date}) - checking rollover logs for confirmation"
# Don't set rollover_verified yet - let log check determine it
else
warn "Alarm date ${post_date} is in the past (current: ${current_date}) - rollover may have failed"
rollover_verified=false
fi
fi fi
fi fi
fi fi