Home Explore Blog Models CI



nixpkgs

doc/hooks/memcached-test-hook.section.md
a72b905d6444255bbfc2c933c16d39f4bce213e69b0a0f4200000003000002e9

# `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
fd8d70cf (1st chunk of `doc/hooks/memcached-test-hook.section.md`)
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`.