https://github.com/motiva-ai/wait-for
Useful synchronization function for testing multi-threaded apps
https://github.com/motiva-ai/wait-for
Last synced: 4 months ago
JSON representation
Useful synchronization function for testing multi-threaded apps
- Host: GitHub
- URL: https://github.com/motiva-ai/wait-for
- Owner: Motiva-AI
- License: mit
- Created: 2018-07-03T03:01:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-20T21:58:37.000Z (over 6 years ago)
- Last Synced: 2025-02-08T05:46:45.775Z (4 months ago)
- Language: Clojure
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wait-for
[](https://circleci.com/gh/Motiva-AI/wait-for)
A simple but insanely useful little macro for testing concurrent systems.
## Usage
```
user> (require '[wait-for.core :refer [wait-for]])
=> nil
user> (doc wait-for)
-------------------------
wait-for.core/wait-for
([predicate & {:as opts, :keys [interval timeout timeout-fn], :or {interval 3, timeout 120}}])
Macro
Invoke predicate every interval (default 3) seconds until it returns true,
or timeout (default 120) seconds have elapsed. E.g.:(wait-for #(< (rand) 0.2) :interval 1 :timeout 10)
Optionally takes a `:timeout-fn` key the value of which will be
called when the timeout occurs. The default behaviour is to throw
an `(ex-info ...)` with a useful message.Setting `timeout-fn` explicitly to `false` cause the results of the
last call to `predicate` to be returned regardless. This allows the
following form to work as expected in tests:(is (wait-for #(< (rand) 0.2) :interval 1 :timeout 10))
=> nil
user>
```## Latest Version
The latest release version of wait-for is hosted on [Clojars](https://clojars.org):
[](https://clojars.org/motiva/wait-for)
## License
The MIT License (MIT)
Copyright © 2018 Motiva Inc