mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
redisTestHook: init
This commit is contained in:
parent
c3acc2b5d4
commit
aa01fb4e17
4 changed files with 157 additions and 0 deletions
60
doc/hooks/redis-test-hook.section.md
Normal file
60
doc/hooks/redis-test-hook.section.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
# `redisTestHook` {#sec-redisTestHook}
|
||||
|
||||
This hook starts a Redis server during `checkPhase`. Example:
|
||||
|
||||
```nix
|
||||
{
|
||||
stdenv,
|
||||
redis,
|
||||
redisTestHook
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
|
||||
# ...
|
||||
|
||||
nativeCheckInputs = [
|
||||
redisTestHook
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
If you use a custom `checkPhase`, remember to add the `runHook` calls:
|
||||
```nix
|
||||
checkPhase ''
|
||||
runHook preCheck
|
||||
|
||||
# ... your tests
|
||||
|
||||
runHook postCheck
|
||||
''
|
||||
```
|
||||
|
||||
## Variables {#sec-redisTestHook-variables}
|
||||
|
||||
The hook logic will read the following variables and set them to a default value if unset or empty.
|
||||
|
||||
Exported variables:
|
||||
|
||||
- `REDIS_SOCKET`: UNIX domain socket path
|
||||
|
||||
Bash-only variables:
|
||||
|
||||
- `redisTestPort`: Port to use by Redis. Defaults to `6379`
|
||||
|
||||
Example usage:
|
||||
|
||||
```nix
|
||||
{ stdenv, redis, redisTestHook }:
|
||||
stdenv.mkDerivation {
|
||||
|
||||
# ...
|
||||
|
||||
nativeCheckInputs = [
|
||||
redisTestHook
|
||||
];
|
||||
|
||||
preCheck = ''
|
||||
redisTestPort=6390
|
||||
''
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue