mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 06:30:28 +00:00
tests: improve test purity
Before the XDG variables would be set from the user's environment, if available. This would break some tests. With this change the tests should be fully deterministic. Fixes #1190
This commit is contained in:
parent
cfaf213980
commit
95b95b1407
17 changed files with 21 additions and 54 deletions
|
@ -14,7 +14,15 @@ let
|
|||
modules = import ../modules/modules.nix {
|
||||
inherit lib pkgs;
|
||||
check = false;
|
||||
};
|
||||
} ++ [
|
||||
# Fix impurities. Without these some of the user's environment
|
||||
# will leak into the tests through `builtins.getEnv`.
|
||||
{
|
||||
xdg.enable = true;
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
}
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
|
|
|
@ -4,3 +4,6 @@ export __HM_SESS_VARS_SOURCED=1
|
|||
|
||||
export V1="v1"
|
||||
export V2="v2-v1"
|
||||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
. "/test-home/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
||||
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
if [ -e "$HOME/.profile" ]; then
|
||||
. "$HOME/.profile"
|
||||
|
|
|
@ -4,8 +4,6 @@ with lib;
|
|||
|
||||
{
|
||||
config = {
|
||||
home.homeDirectory = "/test-home";
|
||||
|
||||
xsession = {
|
||||
enable = true;
|
||||
windowManager.command = "window manager command";
|
||||
|
|
|
@ -6,8 +6,6 @@ with lib;
|
|||
config = {
|
||||
home.stateVersion = "19.09";
|
||||
|
||||
home.homeDirectory = "/test-home";
|
||||
|
||||
home.keyboard = { options = [ "ctrl:nocaps" "altwin:no_win" ]; };
|
||||
|
||||
xsession = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- mode: sh -*-
|
||||
|
||||
. "/home/testuser/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
||||
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
export V1="v1"
|
||||
export V2="v2-v1"
|
||||
|
|
|
@ -13,8 +13,6 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.homeDirectory = "/home/testuser";
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.profile
|
||||
assertFileContent \
|
||||
|
|
|
@ -6,9 +6,6 @@ with lib;
|
|||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
getmail = {
|
||||
|
|
|
@ -6,9 +6,6 @@ with lib;
|
|||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
|
||||
programs.lieer.enable = true;
|
||||
|
||||
accounts.email.accounts = { "hm@example.com".lieer.enable = true; };
|
||||
|
|
|
@ -6,9 +6,6 @@ with lib;
|
|||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
|
||||
programs.mbsync = {
|
||||
enable = true;
|
||||
groups.inboxes = {
|
||||
|
|
|
@ -6,11 +6,6 @@ with lib;
|
|||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
xdg.configHome = mkForce "/home/hm-user/.config";
|
||||
xdg.cacheHome = mkForce "/home/hm-user/.cache";
|
||||
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
|
|
|
@ -6,11 +6,6 @@ with lib;
|
|||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
xdg.configHome = mkForce "/home/hm-user/.config";
|
||||
xdg.cacheHome = mkForce "/home/hm-user/.cache";
|
||||
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
|
||||
export TMUX_TMPDIR="${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}"
|
|
@ -11,9 +11,8 @@ with lib;
|
|||
|
||||
nmt.script = ''
|
||||
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
||||
assertFileContent home-path/etc/profile.d/hm-session-vars.sh ${
|
||||
./hm-session-vars.sh
|
||||
}
|
||||
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'export TMUX_TMPDIR="''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}"'
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,9 +6,6 @@ with lib;
|
|||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
home.username = "hm-user";
|
||||
home.homeDirectory = "/home/hm-user";
|
||||
|
||||
services.lieer.enable = true;
|
||||
|
||||
accounts.email.accounts = {
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
|
||||
export XDG_DATA_DIRS="/nix/var/nix/profiles/default/share:/homeless-shelter/.nix-profile/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
|
||||
. "@nix@/etc/profile.d/nix.sh"
|
|
@ -4,20 +4,16 @@ with lib;
|
|||
|
||||
{
|
||||
config = {
|
||||
home.homeDirectory = "/homeless-shelter";
|
||||
|
||||
targets.genericLinux.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
||||
assertFileContent \
|
||||
assertFileContains \
|
||||
home-path/etc/profile.d/hm-session-vars.sh \
|
||||
${
|
||||
pkgs.substituteAll {
|
||||
src = ./generic-linux-session-vars-expected.txt;
|
||||
nix = pkgs.nix;
|
||||
}
|
||||
}
|
||||
'export XDG_DATA_DIRS="/nix/var/nix/profiles/default/share:/home/hm-user/.nix-profile/share''${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"'
|
||||
assertFileContains \
|
||||
home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'. "${pkgs.nix}/etc/profile.d/nix.sh"'
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue