Whole file
cuu508/cronsim
The author described this change as “Fix more weekday handling bugs”. It counts as a record because the check below fails on the code as it stood at 9325f729b and passes on 03fc8bd91, with nothing else changed between the two runs.
Projectcuu508/cronsim
Fix saved2021-04-28
Sharing licenceBSD-3-Clause · LICENSE
Change size+10 −7
What the code was meant to do, written into the code itself as a save note
Fix more weekday handling bugs
The change
| 19 | 19 | list(range(0, 7)), | |
| 20 | 20 | ] | |
| 21 | 21 | ||
| 22 | - | SYMBOLIC_DAYS = "MON TUE WED THU FRI SAT SUN".split() | |
| 22 | + | SYMBOLIC_DAYS = "SUN MON TUE WED THU FRI SAT".split() | |
| 23 | 23 | SYMBOLIC_MONTHS = "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC".split() | |
| 24 | 24 | ||
| 25 | 25 | ||
| ⋯ | |||
| 30 | 30 | ||
| 31 | 31 | if field == Field.DOW: | |
| 32 | 32 | if value.upper() in SYMBOLIC_DAYS: | |
| 33 | - | value = SYMBOLIC_DAYS.index(value.upper()) + 1 | |
| 33 | + | value = SYMBOLIC_DAYS.index(value.upper()) | |
| 34 | 34 | ||
| 35 | 35 | return int(value) | |
| 36 | 36 | ||
| ⋯ | |||
| 54 | 54 | items = _parse(field, term) | |
| 55 | 55 | if len(items) == 1: | |
| 56 | 56 | start = items[0] | |
| 57 | - | items = [v for v in RANGES[field] if v >= start] | |
| 57 | + | end = max(RANGES[field]) | |
| 58 | + | items = list(range(start, end + 1)) | |
| 58 | 59 | ||
| 59 | 60 | return items[::int(step)] | |
| 60 | 61 | ||
| ⋯ | |||
| 64 | 65 | end = _int(field, end) | |
| 65 | 66 | return list(range(start, end + 1)) | |
| 66 | 67 | ||
| 67 | - | if value == "L" and field == Field.DAY: | |
| 68 | + | if field == Field.DAY and value in ("L", "l"): | |
| 68 | 69 | return [CronSim.LAST] | |
| 69 | 70 | ||
| 70 | 71 | return [_int(field, value)] | |
| ⋯ | |||
| 206 | 207 | ||
| 207 | 208 | ||
| 208 | 209 | if __name__ == '__main__': | |
| 209 | - | a = CronSim("0 1 * * */2", datetime.now()) | |
| 210 | - | for i in range(0, 10): | |
| 211 | - | print("Here's what we got: ", next(a)) | |
| 210 | + | # a = CronSim("0 1 * * */2", datetime.now()) | |
| 211 | + | # for i in range(0, 10): | |
| 212 | + | # print("Here's what we got: ", next(a)) | |
| 213 | + | ||
| 214 | + | print(_parse(Field.DAY, "0/10")) | |
| 212 | 215 | ||
The check that tells the two apart
fail→pass·test_cronsim.py::TestParse::test_it_parses_day_lowercase_l
Check file test_cronsim.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it9325f729b98d47fe2891969b167dee77712e5d5b
Broken version dated2021-04-28
Modulecronsim
Units changed_int, _parse
Fingerprint3ea150d2f7e5b8de
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in cuu508/cronsim
- 2023-04-27format_time
- 2021-04-28Fix weekday handling bugs