#test #time #testing

faketime

Fake time to ease testing and debugging

4 releases

0.2.1 Dec 17, 2020
0.2.0 Dec 21, 2018
0.1.1 Dec 20, 2018
0.1.0 Dec 20, 2018

#289 in Date and time

Download history 727/week @ 2023-08-11 838/week @ 2023-08-18 1104/week @ 2023-08-25 555/week @ 2023-09-01 543/week @ 2023-09-08 518/week @ 2023-09-15 368/week @ 2023-09-22 228/week @ 2023-09-29 508/week @ 2023-10-06 428/week @ 2023-10-13 480/week @ 2023-10-20 641/week @ 2023-10-27 373/week @ 2023-11-03 385/week @ 2023-11-10 378/week @ 2023-11-17 358/week @ 2023-11-24

1,623 downloads per month
Used in 4 crates (via ckb-extension-fee-estimat…)

MIT license

14KB
148 lines

faketime

Build Status Build status

Provides a method unix_time which returns elapsed time since UNIX EPOCH. The returned time can be faked in each thread separately.

Documentation

Quick Start

Add faketime as dependency and use faketime::unix_time or faketime::unix_time_as_millis to get current time.

To fake time in test:

  • Use faketime::millis_tempfile to create a temp timestamp file.
  • Enable faketime via faketime::enable in current thread.

To fake time in child threads:

  • Use faketime::millis_tempfile to create a temp timestamp file.
  • Set child thread name to FAKETIME=PATH, where PATH is the path to the timestamp file.

To fake time of the generated binary, set the environment variable

echo 123456 > /tmp/faketime
FAKETIME=/tmp/faketime path/to/binary

Dependencies

~0–11MB
~92K SLoC