Home Explore Blog CI



nixpkgs

doc/hooks/memcached-test-hook.section.md
7af2e1b5106ccf90f337255b1126db51e139b5133d9a886900000003000002f6

# `memcachedTestHook` {#sec-memcachedTestHook}

This hook starts a Memcached server during `checkPhase`. Example:

```nix
{
  stdenv,
  memcachedTestHook,
}:
stdenv.mkDerivation {

  # ...

  nativeCheckInputs = [
    memcachedTestHook
  ];
}
```

If you use a custom `checkPhase`, remember to add the `runHook` calls:
```nix
{
  checkPhase = ''
    runHook preCheck

    # ... your tests

    runHook postCheck
  '';
}
```

## Variables {#sec-memcachedTestHook-variables}

Bash-only variables:

 - `memcachedTestPort`: Port to use by Memcached. Defaults to `11211`

Example usage:

```nix
{ stdenv, memcachedTestHook }:
stdenv.mkDerivation {

  # ...

  nativeCheckInputs = [
    memcachedTestHook
  ];

  preCheck = ''
    memcachedTestPort=1234;
  '';
}

Chunks
5165f42d (1st chunk of `doc/hooks/memcached-test-hook.section.md`)
Title: memcachedTestHook: Running Memcached during checkPhase
Summary
The `memcachedTestHook` is a Nix hook that starts a Memcached server during the `checkPhase` of a derivation. To use it, add it to `nativeCheckInputs` and ensure `runHook` calls are included in a custom `checkPhase`. The `memcachedTestPort` variable (defaulting to 11211) can be set to specify the port Memcached uses. This is demonstrated via example Nix code.