Sitelet https://github.com/fsprojects/FSharp.Control.R3/pull/22
Skip to content

test: cover the library with integration tests - #22

Open
xperiandri wants to merge 10 commits into
test/categoriesfrom
tests/integration-coverage
Open

xperiandri wants to merge 10 commits into
test/categoriesfrom
tests/integration-coverage

Conversation

@xperiandri

@xperiandri xperiandri commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Proposed Changes

Covers the whole public API of FSharp.Control.R3 with 429 deterministic integration tests that run real R3 1.3.1 pipelines – hot subjects, synchronous sources, chunking driven by FakeTimeProvider, gated asynchronous selectors, errors, cancellation and disposal. Closes #11 and supersedes the draft #12.

The library fixes, the new API, the documentation and the test categories that this pull request used to carry are now the separate pull requests stacked below it (see the list at the end). This one is based on the top of that stack, #43, so it shows only the tests.

Types of changes

What types of changes does your code introduce to FSharp.Control.R3?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Build and tests pass locally – 0 warnings and Fantomas clean at every commit, all 429 tests green in Debug and Release; before the split the suite passed 50 consecutive runs in Debug and 30 in Release with method-level parallelism
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Further comments

Commits – the test infrastructure first, then one commit per test file (processing options, chunking, rxquery, the Observable module, mapAsync, the Async flavour, the Task flavour, cross-cutting scenarios), ordered so that no test class refers to a test file that does not exist yet, and finally the changelog line and the agent instructions. Every commit builds on its own and passes the tests that exist at that point.

Test infrastructure

  • TestHelpers.fs provides:
    • a Recorder that also captures OnErrorResume;
    • SubscriptionProbe, which counts subscriptions and disposals;
    • GatedSelector, whose results the test releases;
    • the Flavour and Terminals dispatchers, which run the same test against both flavours.
  • Microsoft.Extensions.TimeProvider.Testing 10.10.0 is added for the test project only.
  • testconfig.json fails a hung test after 10 s.
  • Every test class carries a category attribute from TestCategories.fs (test: categorize the tests per tested component #43), so a subset runs with --filter TestCategory=....

Verification

Stack – every pull request is based on the one before it, so each shows only its own change. Merge them in this order:

  1. refactor!: prefix AwaitOperationConfiguration cases with Await #23 refactor!: prefix AwaitOperationConfiguration cases with Await
  2. fix: validate the concurrency limit of mapAsync options eagerly #24 fix: validate the concurrency limit of mapAsync options eagerly
  3. fix(rxquery): emit yield/zero synchronously to keep element order #25 fix(rxquery): emit yield/zero synchronously to keep element order
  4. fix(rxquery)!: stop seeding sumBy with Unchecked.defaultof #26 fix(rxquery)!: stop seeding sumBy with Unchecked.defaultof
  5. feat(rxquery): add rxqueryWith to cancel the terminal query operators #27 feat(rxquery): add rxqueryWith to cancel the terminal query operators
  6. docs(rxquery): document the query builder and every query operator #28 docs(rxquery): document the query builder and every query operator
  7. feat(observable)!: make ofSeq reachable as Observable.ofSeq #29 feat(observable)!: make ofSeq reachable as Observable.ofSeq
  8. feat(observable)!: make Observable.choose take a voption chooser, add ObservableOption #30 feat(observable)!: make Observable.choose take a voption chooser, add ObservableOption
  9. feat(observable): add chunkByBoundaries for boundaries of any element type #31 feat(observable): add chunkByBoundaries for boundaries of any element type
  10. fix(observable): validate every chunk length eagerly #32 fix(observable): validate every chunk length eagerly
  11. docs: document the processing and chunk configuration types #33 docs: document the processing and chunk configuration types
  12. docs(observable): correct misleading XML docs and document every function #34 docs(observable): correct misleading XML docs and document every function
  13. fix(async)!: remove the ignored cancellationToken from toLookup #35 fix(async)!: remove the ignored cancellationToken from toLookup
  14. fix(async)!: surface the original exception and cancellation from Async wrappers #36 fix(async)!: surface the original exception and cancellation from Async wrappers
  15. fix: wait for iterAsync through ForEachAsync instead of CountAsync #37 fix: wait for iterAsync through ForEachAsync instead of CountAsync
  16. fix: stop iterAsync reliably and never lose a failure of its action #38 fix: stop iterAsync reliably and never lose a failure of its action
  17. fix(task)!: default ofTask configureAwait to true #39 fix(task)!: default ofTask configureAwait to true
  18. feat(task)!: move toArray and toList into the Task.Observable module #40 feat(task)!: move toArray and toList into the Task.Observable module
  19. docs: correct the Async and Task module docs and document every member #41 docs: correct the Async and Task module docs and document every member
  20. docs: document the R3 1.3.1 limitations of bind, catch and mapAsync #42 docs: document the R3 1.3.1 limitations of bind, catch and mapAsync
  21. test: categorize the tests per tested component #43 test: categorize the tests per tested component
  22. test: cover the library with integration tests #22 test: cover the library with integration tests ← this pull request

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 4, 2026 22:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Broad breaking API and concurrency changes warrant final human review despite extensive deterministic coverage.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds comprehensive deterministic integration coverage while fixing observable ordering, exception, cancellation, and asynchronous iteration defects.

Changes:

  • Adds new observable factories/operators and cancellable query support.
  • Corrects Async/Task behavior and processing validation.
  • Expands tests, XML documentation, and changelog coverage.
File Description
.github/​copilot-instructions.md Updates project structure guidance.
CHANGELOG.md Documents features and breaking changes.
Directory.Packages.props Adds fake-time testing dependency.
src/​FSharp.Control.R3/​AsyncObservable.fs Fixes Async errors, cancellation, and iteration.
src/​FSharp.Control.R3/​FSharp.Control.R3.fsproj Includes new library sources.
src/​FSharp.Control.R3/​IterationGuard.fs Tracks and propagates iteration failures.
src/​FSharp.Control.R3/​Observable.fs Adds operators, validation, and builder fixes.
src/​FSharp.Control.R3/​ObservableFactories.fs Adds ofSeq factories.
src/​FSharp.Control.R3/​ProcessingOptions.fs Renames modes and expands configuration.
src/​FSharp.Control.R3/​TaskObservable.fs Fixes Task iteration and terminal APIs.
tests/​FSharp.Control.R3.Tests/​AsyncObservableTests.fs Covers Async behavior.
tests/​FSharp.Control.R3.Tests/​BuilderTests.fs Expands query-builder coverage.
tests/​FSharp.Control.R3.Tests/​ChunkTests.fs Covers deterministic chunking behavior.
tests/​FSharp.Control.R3.Tests/​FSharp.Control.R3.Tests.fsproj Registers tests and dependency.
tests/​FSharp.Control.R3.Tests/​IntegrationTests.fs Adds end-to-end scenarios.
tests/​FSharp.Control.R3.Tests/​MapAsyncTests.fs Covers all asynchronous processing modes.
tests/​FSharp.Control.R3.Tests/​ObservableTests.fs Covers observable operators and factories.
tests/​FSharp.Control.R3.Tests/​ProcessingOptionsTests.fs Verifies processing mappings and defaults.
tests/​FSharp.Control.R3.Tests/​TaskObservableTests.fs Covers Task behavior and factories.
tests/​FSharp.Control.R3.Tests/​TestHelpers.fs Adds deterministic testing infrastructure.
tests/​FSharp.Control.R3.Tests/​testconfig.json Adds per-test timeout.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Assert.AreEqual (1, rightProbe.Disposed, "The failure must unsubscribe the pipeline from the source that is still open")

[<TestMethod>]
member _.``a failure the catch handler does not handle fails the merged pipeline and unsubscribes from the open source`` () =
xperiandri and others added 10 commits October 5, 2026 02:14
- `Microsoft.Extensions.TimeProvider.Testing` drives time-based
  operators with `FakeTimeProvider`.
- `TestHelpers.fs` provides synchronous sources, a `Recorder` observer
  that also captures `OnErrorResume` and can be awaited, a
  `SubscriptionProbe` that counts subscriptions and disposals, a
  `GatedSelector` that lets a test decide when asynchronous selectors
  finish, a recording `SynchronizationContext`, the shared assertions
  `assertFailedWith` and `assertArgumentRejected`, `dataRows`, the
  `Fruits` grouping fixture, and `Flavour` and `Terminals`, which run
  `mapAsync` and every terminal function in either flavour.
- `testconfig.json` fails a hung test after 10 seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ProcessingOptionsTests` pin `Default`, `Parallel`, and the
`AwaitOperation` and `MaxConcurrent` of every
`AwaitOperationConfiguration` case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ChunkTests` cover `chunkBySize`, `chunkBy` for every
`ChunkConfiguration` case with time driven by `FakeTimeProvider`,
`chunkByBoundaries` and the `ChunkConfiguration` helpers: empty
sources, resumed errors, failures, eager validation, window tokens,
disposal and `ConfigureAwait`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the `Thread.Sleep` test with deterministic tests of the rxquery
builder over R3 1.3.1: `for`, `yield`, `zero` and every custom operation
in order and with synchronous completion, empty sources, terminal
failures and `OnErrorResume`, short-circuit disposal on hot subjects,
the `sumBy` regressions and the `rxqueryWith` token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the two smoke tests with tests of every function of the
Observable module except chunking and rxquery, against R3 1.3.1 with
synchronous sources: values, errors reported through `OnErrorResume`
and completion for each wrapper, terminal failures, empty sources,
disposal and unsubscription proven on open subjects, `choose` and
`ObservableOption.choose`, and `ofSeq`, including its R3 behaviour with
cancellation, enumeration exceptions and early unsubscription.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exercise both flavours of mapAsync (Task and Async, one data row each)
against R3 1.3.1 SelectAwait: every await operation, CancelOnCompleted,
source failures, selector exceptions, resumed source errors, empty
sources, the eager concurrency-limit validation, disposal and the
ConfigureAwait option. Gated selectors and awaited signals keep every
test deterministic; the unlimited parallel cases complete the source
before releasing the last selector to avoid the R3 completion race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exercise every function of `FSharp.Control.R3.Async` against R3 1.3.1:
the cold subscription of `length`, `aggregate`, `all`, `existsAsync`,
`firstAsync`, `iter`, `toArray`, `toList`, `ofAsync`, `iterAsync`, a
default `mapAsync` projection and the four `toLookup` overloads,
including the positional `keyComparer` and `elementSelector` calls that
the removed `cancellationToken` parameter used to swallow.

Every terminal function is checked for raising the original exception
of a source failure or `OnErrorResume`, for cancellation through the
Async token, for keeping no subscription with a cancelled token and for
resuming on the synchronization context it started to wait on.
`iterAsync` is checked for every way it used to keep running, hang or
lose a failure of its action.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover every function of `FSharp.Control.R3.Task` except the selector
modes of `mapAsync`, against R3 1.3.1 behaviour and deterministically:

- `length`, `aggregate`, `all`, `existsAsync`, `firstAsync`, `iter`,
  `toArray` and `toList` for values, empty sources, short-circuiting
  and callback exceptions.
- `iterAsync`: order, failures of the action, including a late one and
  an `OperationCanceledException` of its own, synchronous sources,
  cancellation of the running action, and eager rejection of an invalid
  concurrency limit.
- `ofTask` (both overloads): synchronous emission, one invocation per
  subscription, failures, disposal, and `configureAwait` defaulting to
  `true`, observed through a recording synchronization context.
- Every `toLookup` overload, positional, with and without a token,
  including the empty lookup.
- Every terminal function, through data rows: terminal failures and
  resumed errors fault with the same exception, and cancellation
  disposes the subscription, both while waiting and up front.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A hot subject through filter, distinct, mapi and chunkBySize, including
  a failed completion, a resumed predicate error and disposal.
- Merged sources behind catch: the fallback, an unhandled exception type
  and resumed errors, each unsubscribing from the source still open.
- The Task and Async terminal functions agree on the same pipeline, on an
  empty one, and fail with the same exception instance.
- mapAsync failures and cancellation of the terminal function, time
  chunks driven by FakeTimeProvider, ofTask and ofAsync inside bind,
  rxquery feeding both flavours, chunkByBoundaries with a unit trigger
  feeding choose, and ofSeq feeding a whole pipeline.

The type abbreviations are wrapped in a file-specific module, because
namespace-level abbreviations with the same names in another test file
fail to compile with FS0249.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover the functionality with integration tests

2 participants