1{
2 lib,
3 buildPackages,
4 stdenv,
5 mkMesonExecutable,
6
7 nix-store,
8 nix-store-c,
9 nix-store-test-support,
10 sqlite,
11
12 rapidcheck,
13 gtest,
14 runCommand,
15
16 # Configuration Options
17
18 version,
19 filesetToSource,
20}:
21
22mkMesonExecutable (finalAttrs: {
23 pname = "nix-store-tests";
24 inherit version;
25
26 workDir = ./.;
27
28 # Hack for sake of the dev shell
29 passthru.externalBuildInputs = [
30 sqlite
31 rapidcheck
32 gtest
33 ];
34
35 buildInputs = finalAttrs.passthru.externalBuildInputs ++ [
36 nix-store
37 nix-store-c
38 nix-store-test-support
39 ];
40
41 mesonFlags = [
42 ];
43
44 passthru = {
45 tests = {
46 run =
47 let
48 # Some data is shared with the functional tests: they create it,
49 # we consume it.
50 data = filesetToSource {
51 root = ../..;
52 fileset = lib.fileset.unions [
53 ./data
54 ../../tests/functional/derivation
55 ];
56 };
57 in
58 runCommand "${finalAttrs.pname}-run"
59 {
60 meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
61 }
62 (
63 lib.optionalString stdenv.hostPlatform.isWindows ''
64 export HOME="$PWD/home-dir"
65 mkdir -p "$HOME"
66 ''
67 + ''
68 export _NIX_TEST_UNIT_DATA=${data + "/src/libstore-tests/data"}
69 ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
70 touch $out
71 ''
72 );
73 };
74 };
75
76 meta = {
77 platforms = lib.platforms.unix ++ lib.platforms.windows;
78 mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
79 };
80
81})