Run unit tests with wine

Fix #10547

The tests do not all run successfully, but that is a separate issue.
This commit is contained in:
John Ericson 2024-07-21 12:57:49 -04:00
parent dc6dbbc1a5
commit eea63d5f99
5 changed files with 46 additions and 20 deletions

View File

@ -1,4 +1,5 @@
{ lib { lib
, buildPackages
, stdenv , stdenv
, mkMesonDerivation , mkMesonDerivation
, releaseTools , releaseTools
@ -81,17 +82,21 @@ mkMesonDerivation (finalAttrs: {
passthru = { passthru = {
tests = { tests = {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" } (lib.optionalString stdenv.hostPlatform.isWindows ''
export HOME="$PWD/home-dir"
mkdir -p "$HOME"
'' + ''
export _NIX_TEST_UNIT_DATA=${resolvePath ./data} export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-expr-tests ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out touch $out
''; '');
}; };
}; };
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
}; };
}) })

View File

@ -1,4 +1,5 @@
{ lib { lib
, buildPackages
, stdenv , stdenv
, mkMesonDerivation , mkMesonDerivation
, releaseTools , releaseTools
@ -79,17 +80,21 @@ mkMesonDerivation (finalAttrs: {
passthru = { passthru = {
tests = { tests = {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" } (lib.optionalString stdenv.hostPlatform.isWindows ''
export HOME="$PWD/home-dir"
mkdir -p "$HOME"
'' + ''
export _NIX_TEST_UNIT_DATA=${resolvePath ./data} export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-fetchers-tests ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out touch $out
''; '');
}; };
}; };
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
}; };
}) })

View File

@ -1,4 +1,5 @@
{ lib { lib
, buildPackages
, stdenv , stdenv
, mkMesonDerivation , mkMesonDerivation
, releaseTools , releaseTools
@ -79,17 +80,21 @@ mkMesonDerivation (finalAttrs: {
passthru = { passthru = {
tests = { tests = {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" } (lib.optionalString stdenv.hostPlatform.isWindows ''
export HOME="$PWD/home-dir"
mkdir -p "$HOME"
'' + ''
export _NIX_TEST_UNIT_DATA=${resolvePath ./data} export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-flake-tests ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out touch $out
''; '');
}; };
}; };
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
}; };
}) })

View File

@ -1,4 +1,5 @@
{ lib { lib
, buildPackages
, stdenv , stdenv
, mkMesonDerivation , mkMesonDerivation
, releaseTools , releaseTools
@ -92,17 +93,22 @@ mkMesonDerivation (finalAttrs: {
../../functional/derivation ../../functional/derivation
]; ];
}; };
in runCommand "${finalAttrs.pname}-run" {} '' in runCommand "${finalAttrs.pname}-run" {
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" 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 + "/unit/libstore/data"} export _NIX_TEST_UNIT_DATA=${data + "/unit/libstore/data"}
nix-store-tests ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out touch $out
''; '');
}; };
}; };
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
}; };
}) })

View File

@ -1,4 +1,5 @@
{ lib { lib
, buildPackages
, stdenv , stdenv
, mkMesonDerivation , mkMesonDerivation
, releaseTools , releaseTools
@ -80,17 +81,21 @@ mkMesonDerivation (finalAttrs: {
passthru = { passthru = {
tests = { tests = {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" } (lib.optionalString stdenv.hostPlatform.isWindows ''
export HOME="$PWD/home-dir"
mkdir -p "$HOME"
'' + ''
export _NIX_TEST_UNIT_DATA=${./data} export _NIX_TEST_UNIT_DATA=${./data}
nix-util-tests ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
touch $out touch $out
''; '');
}; };
}; };
meta = { meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows; platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
}; };
}) })