5.2 KiB
S021 — Queues, schedule, power: test file
Written by the worker that built it, run by the test phase. Nothing here has been tested until its Result says so.
Built
crates/core/src/schedule.rs · Clock, SystemClock, ManualClock, Schedule::contains, open, opened_between, Grid, cycle.
crates/core/src/power.rs · Action, Scope, WhenDone, Watcher::{arm,cancel,step} (countdown, conditions), Power trait, Logind, Inhibitor.
crates/core/src/run.rs · RunSpec, Vars, expand, run (no shell, timeout, output to log).
crates/core/src/manager/{actor,pick}.rs · choose reads queue paused, max_active, schedule and task after; Config.clock; Error::Cycle on Edit.
Checks
Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken · LOW = looks or comfort.
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | HIGH | Queue with paused, add a task to it |
task stays Queued, nothing downloads; unpause starts it | integration (testserver, Config.clock default) |
pass |
| 2 | HIGH | Queue max_active = 1, three tasks, global max 4 |
only one runs at a time, the others follow in order | integration | pass |
| 3 | HIGH | Queue schedule Mon 22:00-06:00 on a ManualClock at Mon 21:59, then advance 2 minutes | task starts within one look (~15 s real, or send a command to force choose) | integration | pass |
| 4 | HIGH | Running task, clock leaves the window | task goes back to Queued, not Failed; returns when the window opens | integration | pass |
| 5 | HIGH | Start by hand (forced) in a paused or closed queue |
it runs | integration | pass |
| 6 | HIGH | Task B after A; A Running |
B stays Queued; when A is Done, B starts | integration | pass |
| 7 | HIGH | after pointing at itself, at a chain that returns, at a removed task |
first two give Error::Cycle and nothing is saved; the last is accepted and B isn't held |
integration | pass |
| 8 | HIGH | Watcher with even_failed = false, one Done and one Failed |
Step::Blocked, disarmed, never fires |
unit | pass |
| 9 | HIGH | Same with even_failed = true |
countdown starts, fires after the countdown | unit | pass |
| 10 | MED | Cancel during the countdown; a task of the scope starts again | Idle after cancel; a new running task resets the countdown |
unit | pass |
| 11 | MED | Scope Queue(2) while queue 1 still runs | fires when queue 2 is done | unit | pass |
| 12 | HIGH | ManualClock zone with +1 h at the 2026-03-29 01:00 UTC step (Europe), window 02:00-03:00 |
contains follows local time: closed before, open after; no panic in the skipped hour |
unit | pass |
| 13 | MED | Zone change (offset +0 to +9 h) while window 22:00-06:00 | open/closed follows the new wall time at once | unit | pass |
| 14 | MED | opened_between over a 10-hour sleep that spans a window start, and one that spans none or only an end |
true for the first; false for the others; scan capped at 8 days | unit | pass |
| 15 | MED | Night window Mon 22:00-06:00 | Tuesday 05:59 open, 06:00 closed, Monday 05:00 closed; from == to is the whole day |
unit | pass |
| 16 | MED | Grid::new with 167 and 168 cells; at on Monday 00:30 and Sunday 23:30 |
None for 167; first and last cell | unit | pass |
| 17 | HIGH | expand with {file} = /a b/c; rm -rf / |
one argument, unchanged; no shell run | unit | pass |
| 18 | MED | run with sleep 5, timeout 1 s; with echo hi; with a missing program; with exit code 1 |
timeout error naming seconds; Ok("hi\n"); "did not start"; "ended with" error | integration | pass |
| 19 | HIGH | Fake Power that records calls: drive a Fire(Shutdown) through the caller |
only the fake is called; Logind is never used in tests |
unit | pass: S044 Done.power injected; app tests/main.rs::when_done_shuts_down_through_the_power_it_was_given (fake records one Shutdown) |
| 20 | LOW | Logind::can on this PC (capabilities only, no perform) |
Shutdown/Suspend answer without calling the methods; Quit and Run always true | by hand | not run: by hand |
Needs
crates/testserver on 127.0.0.1; a throwaway home; a ManualClock in Config.clock. Never call Logind::perform or Inhibitor::take for real in tests except by hand on check 20 (capabilities only).
Doubts
- Not wired yet: the app's UI for queues, schedules and when-done; nothing calls
Watcher,Logind,Inhibitororrun::runoutside tests; the speedGridis not applied to the limiter; no model fields for once-only schedules (a task'sstart_atis the once rule and is stillHold::Until, untouched). scheduleis read whenchooseruns; a clock jump is seen at most 15 s later (SCHEDULE_LOOK), andHold::Untilstill usesInstant, so time asleep does not count for a start time.- A closed or paused queue pushes running tasks back to Queued; a task running in a queue that gets paused is suspended, not paused.
pickandCandidategot a field and a parameter; the unit tests in pick.rs were edited to match, not run.- Fall-back hour: the window counts twice (documented); not covered by a check.
Notes (S041)
- Run in
crates/core/tests/queues.rs(1-7) andcontrol.rs(8-18). Found and fixed:Rule::fitsrequired extensions AND mime; now OR (rules unit test).