The golang blog mentions two Go features faketime and timejump: https://blog.golang.org/playground
The part that interests me is:
modify scheduler condition to wait for deadlock, then:
- check if timers are pending
- advance clock to trigger-time of first timer
I would like to know how I can leverage this implementation to run unittests with faketime. By this I mean many unitests that use time.Sleep. Testing in realtime is prohibitive since execution time adds up to hours. In faketime the tests run within split-seconds.
To be clear: I do not plan or want to mess up the runtime. I want to build a fake clock that works.
I am pretty convinced that the above referenced implementation works correctly in the concurrent case. If you have a idea, a tip or two on how to borrow this implementation and build a fake clock from it would be great.
My question is based on the assumption that google won't accept a pull request for runtime/time.go to turn faketime into Faketime or to add "func Faketime(f int64) {faketime = f}".