Fallout-build / Fallout-build/Fallout
[Foundation] Make BuildContext's cancellation handlers testable
- Dominant language
- C#
- Stars
- 154
- Forks
- 19
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 15
Description
Follow-up from [#451](https://github.com/Fallout-build/Fallout/pull/451) (FT-2, [#307](https://github.com/Fallout-build/Fallout/issues/307)).
## Problem
`BuildContext.RegisterCancellationHandler` / `UnregisterCancellationHandler` — the two methods `BuildManager.CancellationHandler` exists to delegate to — have no positive coverage. The only spec on the facade (`Cancellation_handler_facade_is_a_no_op_without_an_active_context`) exercises the null-context path.
They can't be tested as written: registered handlers only run from the `Console.CancelKeyPress` subscription, and `ConsoleCancelEventArgs` has no public constructor, so the event can't be raised from a spec.
## Outcome
A registered handler can be shown to run, and an unregistered one shown not to, without depending on a real Ctrl+C.
Needs a seam — e.g. an `internal void InvokeCancellationHandlers()` on `BuildContext` that the `CancelKeyPress` subscription calls, so specs can drive the same path. Worth settling before FT-4/5/6 move more per-run services onto the context.
## Acceptance criteria
- [ ] Registering through `BuildManager.CancellationHandler` with an active context runs the handler when cancellation is signalled.
- [ ] Unregistering stops it running.
- [ ] Handlers registered against one context don't run for another.
- [ ] The seam stays `internal` — no `InternalsVisibleTo` to non-test assemblies.
Contributor guide
Assessment
This issue has not been assessed yet.