lol

nixVersions: give unit tests access to a $HOME directory

Also, don't try to access cache.nixos.org in the libstore unit tests.
We have to disable the test in versions prior to 2.31; that's OK, since
it was being skipped when run under Nix anyway before that.

(cherry picked from commit 01388b3e78582553cc30ee772db5b5aba8d89edd)

Co-authored-by: Philip Taron <philip.taron@gmail.com>

+20 -23
+8 -12
pkgs/tools/package-management/nix/modular/src/libflake-tests/package.nix
··· 42 42 { 43 43 meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages; 44 44 } 45 - ( 46 - lib.optionalString stdenv.hostPlatform.isWindows '' 47 - export HOME="$PWD/home-dir" 48 - mkdir -p "$HOME" 49 - '' 50 - + '' 51 - export _NIX_TEST_UNIT_DATA=${resolvePath ./data} 52 - export NIX_CONFIG="extra-experimental-features = flakes" 53 - ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage} 54 - touch $out 55 - '' 56 - ); 45 + ('' 46 + export _NIX_TEST_UNIT_DATA=${resolvePath ./data} 47 + export NIX_CONFIG="extra-experimental-features = flakes" 48 + export HOME="$TMPDIR/home" 49 + mkdir -p "$HOME" 50 + ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage} 51 + touch $out 52 + ''); 57 53 }; 58 54 }; 59 55
+12 -11
pkgs/tools/package-management/nix/modular/src/libstore-tests/package.nix
··· 41 41 mesonFlags = [ 42 42 ]; 43 43 44 + excludedTestPatterns = lib.optionals (lib.versionOlder finalAttrs.version "2.31") [ 45 + "nix_api_util_context.nix_store_real_path_binary_cache" 46 + ]; 47 + 44 48 passthru = { 45 49 tests = { 46 50 run = ··· 59 63 { 60 64 meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages; 61 65 } 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 - ); 66 + ('' 67 + export _NIX_TEST_UNIT_DATA=${data + "/src/libstore-tests/data"} 68 + export HOME="$TMPDIR/home" 69 + mkdir -p "$HOME" 70 + ${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage} \ 71 + --gtest_filter=-${lib.concatStringsSep ":" finalAttrs.excludedTestPatterns} 72 + touch $out 73 + ''); 73 74 }; 74 75 }; 75 76