faketime

Crates.iofaketime
lib.rsfaketime
version0.2.1
sourcesrc
created_at2018-12-20 15:59:56.501334
updated_at2020-12-17 08:20:38.676524
descriptionFake time to ease testing and debugging
homepage
repositoryhttps://github.com/nervosnetwork/faketime
max_upload_size
id102944
size16,982
ian (doitian)

documentation

README

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
Commit count: 13

cargo fmt