Home Explore Blog Models CI



nixpkgs

1st chunk of `doc/hooks/memcached-test-hook.section.md`
fd8d70cf9c73f8e17f88f0a6f9bdfa41da8c08eead6a529900000001000002e9

# `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;
  '';
}
```

Title: Memcached Test Hook for Nix Builds
Summary
This document describes `memcachedTestHook`, a Nix hook designed to launch a Memcached server during the `checkPhase` of a build. It details how to include the hook using `nativeCheckInputs` and provides instructions for integrating it with custom `checkPhase` scripts by ensuring `runHook preCheck` and `runHook postCheck` calls are present. Additionally, it introduces the `memcachedTestPort` variable, which allows users to specify a custom port for the Memcached server, overriding the default `11211`.