nixpkgs/doc/hooks/redis-test-hook.section.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
905 B
Markdown
Raw Permalink Normal View History

2025-01-15 21:14:31 +01:00
# `redisTestHook` {#sec-redisTestHook}
This hook starts a Redis server during `checkPhase`. Example:
```nix
{
stdenv,
redis,
redisTestHook,
2025-01-15 21:14:31 +01:00
}:
stdenv.mkDerivation {
# ...
nativeCheckInputs = [
redisTestHook
];
}
```
If you use a custom `checkPhase`, remember to add the `runHook` calls:
```nix
2025-04-08 17:36:13 +02:00
{
checkPhase = ''
2025-01-15 21:14:31 +01:00
runHook preCheck
# ... your tests
runHook postCheck
2025-04-08 17:36:13 +02:00
'';
}
2025-01-15 21:14:31 +01:00
```
## 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,
}:
2025-01-15 21:14:31 +01:00
stdenv.mkDerivation {
# ...
nativeCheckInputs = [
redisTestHook
];
preCheck = ''
2025-04-08 17:36:13 +02:00
redisTestPort=6390;
'';
2025-01-15 21:14:31 +01:00
}
```