nix-super/tests/unit/libutil/package.nix

83 lines
1.7 KiB
Nix
Raw Normal View History

{ lib
, buildPackages
, stdenv
, mkMesonExecutable
, nix-util
, nix-util-c
, nix-util-test-support
, rapidcheck
, gtest
, runCommand
# Configuration Options
2024-07-06 18:36:31 +03:00
, version
}:
let
inherit (lib) fileset;
in
mkMesonExecutable (finalAttrs: {
pname = "nix-util-tests";
inherit version;
2024-07-01 21:36:46 +03:00
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
2024-07-01 21:36:46 +03:00
./build-utils-meson
../../../.version
2024-07-01 21:36:46 +03:00
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
buildInputs = [
nix-util
nix-util-c
nix-util-test-support
rapidcheck
gtest
];
preConfigure =
2024-06-28 02:19:32 +03:00
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
2024-07-01 21:36:46 +03:00
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
} (lib.optionalString stdenv.hostPlatform.isWindows ''
export HOME="$PWD/home-dir"
mkdir -p "$HOME"
'' + ''
export _NIX_TEST_UNIT_DATA=${./data}
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out
'');
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
};
})