Commit | Line | Data |
---|---|---|
69cfce50 LC |
1 | #!/bin/sh |
2 | ||
3 | # Guix --- Nix package management from Guile. -*- coding: utf-8 -*- | |
4 | # Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> | |
5 | # | |
6 | # This file is part of Guix. | |
7 | # | |
8 | # Guix is free software; you can redistribute it and/or modify it | |
9 | # under the terms of the GNU General Public License as published by | |
10 | # the Free Software Foundation; either version 3 of the License, or (at | |
11 | # your option) any later version. | |
12 | # | |
13 | # Guix is distributed in the hope that it will be useful, but | |
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with Guix. If not, see <http://www.gnu.org/licenses/>. | |
20 | ||
21 | # Usage: ./test-env COMMAND ARG... | |
22 | # | |
23 | # Run the daemon in the build directory, and run COMMAND within | |
24 | # `pre-inst-env'. This is used to run unit tests with the just-built | |
25 | # daemon, unless `--disable-daemon' was passed at configure time. | |
26 | ||
27 | if [ -x "@abs_top_builddir@/guix-daemon" ] | |
28 | then | |
29 | NIX_SUBSTITUTERS="" # don't resort to substituters | |
30 | NIX_IGNORE_SYMLINK_STORE=1 # in case the store is a symlink | |
31 | NIX_STORE_DIR="@GUIX_TEST_ROOT@/store" | |
32 | NIX_LOCALSTATE_DIR="@GUIX_TEST_ROOT@/var" | |
33 | NIX_LOG_DIR="@GUIX_TEST_ROOT@/var/log/nix" | |
34 | NIX_STATE_DIR="@GUIX_TEST_ROOT@/var/nix-$$" # allow for parallel tests | |
35 | NIX_DB_DIR="@GUIX_TEST_ROOT@/db" | |
36 | NIX_ROOT_FINDER="@abs_top_builddir@/nix/scripts/list-runtime-roots" | |
37 | export NIX_SUBSTITUTERS NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \ | |
38 | NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \ | |
39 | NIX_ROOT_FINDER | |
40 | ||
41 | # Do that because store.scm calls `canonicalize-path' on it. | |
42 | mkdir -p "$NIX_STORE_DIR" | |
43 | ||
44 | # Launch the daemon without chroot support because is may be | |
45 | # unavailable, for instance if we're not running as root. | |
46 | "@abs_top_builddir@/guix-daemon" --disable-chroot & | |
47 | ||
48 | daemon_pid=$! | |
49 | trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT | |
50 | fi | |
51 | ||
52 | "@abs_top_builddir@/pre-inst-env" "$@" | |
53 | exit $? |