cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

testkit: add clockStart parameter to TestControl.execute and executeE…

Open najuna-brian opened this issue 2 months ago • 4 comments

Description

Adds optional clockStart parameter to TestControl.execute and executeEmbed to set initial time offset, making it easier to test time-sensitive code at specific timestamps.

Use Case

This directly addresses the need for testing time-sensitive functionality like HTTP message signatures, authentication tokens, and expiration logic at specific timestamps.

// Before
TestControl.execute(program).flatMap { control =>
  control.tick *> control.advance(timestamp) *> control.tick *> control.results
}

// After  
TestControl.executeEmbed(program, clockStart = timestamp)

Backward compatible with comprehensive test coverage.

Refs #3309

najuna-brian avatar Oct 13 '25 09:10 najuna-brian

Hi @armanbilge , @samspills the macOS CI failed due to a network timeout while downloading dependencies. Could you please rerun the jobs? Thanks!

najuna-brian avatar Oct 13 '25 12:10 najuna-brian

Follow-up: I also tried triggering CI with an empty commit, but the Windows job failed with a ServerAlreadyBootingException (SBT lock issue)

najuna-brian avatar Oct 13 '25 14:10 najuna-brian

Backward compatible

No, it's not binary backward compatible, and mima (rightly) complained.

durban avatar Oct 14 '25 23:10 durban

Backward compatible

No, it's not binary backward compatible, and mima (rightly) complained.

Thank you @durban for guidance in regard to the binary compatibility issue.

I've created #4511 with a binary-compatible approach using new methods (setTime/advanceTo) instead of modifying existing ones. All CI checks are passing. Please look through it when you have some time Thank you :relaxed:

najuna-brian avatar Oct 17 '25 05:10 najuna-brian