Make functional tests on NixOS use Meson not Make

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
John Ericson 2024-11-03 17:10:34 -05:00
parent f07aee934a
commit f018a0b0c8
5 changed files with 33 additions and 36 deletions

View File

@ -19,7 +19,7 @@ EOF
# When we're doing everything in the same store, we need to bring # When we're doing everything in the same store, we need to bring
# dependencies into context. # dependencies into context.
sed -i "$(dirname "${BASH_SOURCE[0]}")"/../config.nix \ sed -i "${_NIX_TEST_BUILD_DIR}/config.nix" \
-e 's^\(shell\) = "/nix/store/\([^/]*\)/\(.*\)";^\1 = builtins.appendContext "/nix/store/\2" { "/nix/store/\2".path = true; } + "/\3";^' \ -e 's^\(shell\) = "/nix/store/\([^/]*\)/\(.*\)";^\1 = builtins.appendContext "/nix/store/\2" { "/nix/store/\2".path = true; } + "/\3";^' \
-e 's^\(path\) = "/nix/store/\([^/]*\)/\(.*\)";^\1 = builtins.appendContext "/nix/store/\2" { "/nix/store/\2".path = true; } + "/\3";^' \ -e 's^\(path\) = "/nix/store/\([^/]*\)/\(.*\)";^\1 = builtins.appendContext "/nix/store/\2" { "/nix/store/\2".path = true; } + "/\3";^' \
; ;

View File

@ -1,4 +1,4 @@
# NOTE: instances of @variable@ are substituted as defined in /mk/templates.mk # NOTE: instances of @variable@ are substituted by the build system
if [[ -z "${COMMON_SUBST_VARS_SH_SOURCED-}" ]]; then if [[ -z "${COMMON_SUBST_VARS_SH_SOURCED-}" ]]; then

View File

@ -1,4 +1,4 @@
project('nix-functional-tests', 'cpp', project('nix-functional-tests',
version : files('.version'), version : files('.version'),
default_options : [ default_options : [
'cpp_std=c++2a', 'cpp_std=c++2a',
@ -170,6 +170,7 @@ suites = [
nix_store = dependency('nix-store', required : false) nix_store = dependency('nix-store', required : false)
if nix_store.found() if nix_store.found()
add_languages('cpp')
subdir('test-libstoreconsumer') subdir('test-libstoreconsumer')
suites += { suites += {
'name': 'libstoreconsumer', 'name': 'libstoreconsumer',
@ -187,6 +188,7 @@ endif
# Plugin tests require shared libraries support. # Plugin tests require shared libraries support.
nix_expr = dependency('nix-expr', required : false) nix_expr = dependency('nix-expr', required : false)
if nix_expr.found() and get_option('default_library') != 'static' if nix_expr.found() and get_option('default_library') != 'static'
add_languages('cpp')
subdir('plugins') subdir('plugins')
suites += { suites += {
'name': 'plugins', 'name': 'plugins',

View File

@ -21,7 +21,8 @@ let
defaults = { defaults = {
nixpkgs.pkgs = nixpkgsFor.${system}.native; nixpkgs.pkgs = nixpkgsFor.${system}.native;
nix.checkAllErrors = false; nix.checkAllErrors = false;
nix.package = noTests nixpkgsFor.${system}.native.nix; # TODO: decide which packaging stage to use. `nix-cli` is efficient, but not the same as the user-facing `everything.nix` package (`default`). Perhaps a good compromise is `everything.nix` + `noTests` defined above?
nix.package = nixpkgsFor.${system}.native.nixComponents.nix-cli;
}; };
_module.args.nixpkgs = nixpkgs; _module.args.nixpkgs = nixpkgs;
_module.args.system = system; _module.args.system = system;
@ -33,10 +34,9 @@ let
forNix = nixVersion: runNixOSTestFor system { forNix = nixVersion: runNixOSTestFor system {
imports = [test]; imports = [test];
defaults.nixpkgs.overlays = [(curr: prev: { defaults.nixpkgs.overlays = [(curr: prev: {
# NOTE: noTests pkg might not have been built yet for some older versions of the package nix = let
# and in versions before 2.25, the untested build wasn't shared with the tested build yet packages = (builtins.getFlake "nix/${nixVersion}").packages.${system};
# Add noTests here when those versions become irrelevant. in packages.nix-cli or packages.nix;
nix = (builtins.getFlake "nix/${nixVersion}").packages.${system}.nix;
})]; })];
}; };
}; };

View File

@ -24,47 +24,42 @@ in
environment.systemPackages = let environment.systemPackages = let
run-test-suite = pkgs.writeShellApplication { run-test-suite = pkgs.writeShellApplication {
name = "run-test-suite"; name = "run-test-suite";
runtimeInputs = [ pkgs.gnumake pkgs.jq pkgs.git ]; runtimeInputs = [
pkgs.meson
pkgs.ninja
pkgs.jq
pkgs.git
# Want to avoid `/run/current-system/sw/bin/bash` because we
# want a store path. Likewise for coreutils.
pkgs.bash
pkgs.coreutils
];
text = '' text = ''
set -x set -x
cat /proc/sys/fs/file-max cat /proc/sys/fs/file-max
ulimit -Hn ulimit -Hn
ulimit -Sn ulimit -Sn
cd ~ cd ~
cp -r ${pkgs.nix.overrideAttrs (o: {
name = "nix-configured-source"; cp -r ${pkgs.nixComponents.nix-functional-tests.src} nix
outputs = [ "out" ];
separateDebugInfo = false;
disallowedReferences = [ ];
buildPhase = ":";
checkPhase = ":";
installPhase = ''
cp -r . $out
'';
installCheckPhase = ":";
fixupPhase = ":";
doInstallCheck = true;
})} nix
chmod -R +w nix chmod -R +w nix
cd nix
# Tests we don't need chmod u+w nix/.version
echo >tests/functional/plugins/local.mk echo ${pkgs.nixComponents.version} > nix/.version
sed -i tests/functional/local.mk \
-e 's!nix_tests += plugins\.sh!!' \
-e 's!nix_tests += test-libstoreconsumer\.sh!!' \
;
_NIX_TEST_SOURCE_DIR="$(realpath tests/functional)"
export _NIX_TEST_SOURCE_DIR
export _NIX_TEST_BUILD_DIR="''${_NIX_TEST_SOURCE_DIR}"
export isTestOnNixOS=1 export isTestOnNixOS=1
export version=${config.nix.package.version}
export NIX_REMOTE_=daemon export NIX_REMOTE_=daemon
export NIX_REMOTE=daemon export NIX_REMOTE=daemon
export NIX_STORE=${builtins.storeDir} export NIX_STORE=${builtins.storeDir}
make -j1 installcheck --keep-going
meson setup nix/tests/functional build
cd build
meson test -j1 --print-errorlogs
''; '';
}; };
in [ in [