tests: fix firefox program tests

This commit is contained in:
Austin Horstman
2026-04-25 19:35:51 -05:00
parent 00b9fac376
commit 8a2fdaf6b4
13 changed files with 60 additions and 26 deletions

View File

@@ -1,11 +1,22 @@
name:
{ lib, name }:
let
withDefaultStateVersion = module: {
imports = [ module ];
# Stronger than the global test default, but weaker than any test-local
# stateVersion assignment.
home.stateVersion = lib.mkOverride 900 "26.05";
};
in
builtins.mapAttrs
(
_test: module:
import module [
"programs"
name
]
withDefaultStateVersion (
import module [
"programs"
name
]
)
)
{
"${name}-deprecated-native-messenger" = ./deprecated-native-messenger.nix;

View File

@@ -1,3 +1,4 @@
{ lib, ... }:
{
"firefox-config-path-explicit-legacy" = ./config-path-explicit-legacy.nix;
"firefox-config-path-explicit-xdg" = ./config-path-explicit-xdg.nix;
@@ -5,6 +6,6 @@
"firefox-config-path-warning" = ./config-path-warning.nix;
"firefox-multiple-derivatives" = ./multiple-derivatives.nix;
}
// (import ./firefox.nix)
// (import ./floorp.nix)
// (import ./librewolf.nix)
// (import ./firefox.nix { inherit lib; })
// (import ./floorp.nix { inherit lib; })
// (import ./librewolf.nix { inherit lib; })

View File

@@ -22,8 +22,6 @@ lib.mkIf config.test.enableBig (
}
)
// {
home.stateVersion = "19.09";
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = ''

View File

@@ -1 +1,5 @@
import ./common.nix "firefox"
{ lib, ... }:
import ./common.nix {
inherit lib;
name = "firefox";
}

View File

@@ -1 +1,5 @@
import ./common.nix "floorp"
{ lib, ... }:
import ./common.nix {
inherit lib;
name = "floorp";
}

View File

@@ -1 +1,5 @@
import ./common.nix "librewolf"
{ lib, ... }:
import ./common.nix {
inherit lib;
name = "librewolf";
}

View File

@@ -1,6 +1,8 @@
{ config, lib, ... }:
lib.mkIf config.test.enableBig {
home.stateVersion = "26.05";
programs.firefox = {
enable = true;
package = null;

View File

@@ -16,10 +16,7 @@ in
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig (
{
home.stateVersion = "23.05";
}
// lib.setAttrByPath modulePath {
lib.setAttrByPath modulePath {
enable = true;
configPath = lib.mkIf pkgs.stdenv.hostPlatform.isLinux ".mozilla/firefox";
policies = {
@@ -40,9 +37,17 @@ in
else
"${cfg.finalPackage}/lib/${cfg.finalPackage.unwrapped.libName or cfg.wrappedPackageName}";
config_file = "${libDir}/distribution/policies.json";
config_file_browser = "${libDir}/browser/distribution/policies.json";
in
''
jq=${lib.getExe pkgs.jq}
if [[ -f "${config_file}" ]]; then
config_file="${config_file}"
elif [[ -f "${config_file_browser}" ]]; then
config_file="${config_file_browser}"
else
fail "Expected ${libDir}/distribution/policies.json to exist but it was not found."
fi
assertFileExists "${config_file}"

View File

@@ -18,11 +18,7 @@ in
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig (
{
# Required for bookmark policy to get set
home.stateVersion = "19.09";
}
// lib.setAttrByPath modulePath {
lib.setAttrByPath modulePath {
enable = true;
configPath = lib.mkIf pkgs.stdenv.hostPlatform.isLinux ".mozilla/firefox";
profiles.bookmarks = {
@@ -95,8 +91,17 @@ in
else
"${cfg.finalPackage}/lib/${cfg.finalPackage.unwrapped.libName or cfg.wrappedPackageName}";
config_file = "${libDir}/distribution/policies.json";
config_file_browser = "${libDir}/browser/distribution/policies.json";
in
''
if [[ -f "${config_file}" ]]; then
config_file="${config_file}"
elif [[ -f "${config_file_browser}" ]]; then
config_file="${config_file_browser}"
else
fail "Expected ${libDir}/distribution/policies.json to exist but it was not found."
fi
assertFileExists "${config_file}"
noDefaultBookmarks_actual_value="$(${lib.getExe pkgs.jq} ".policies.NoDefaultBookmarks" ${config_file})"

View File

@@ -46,7 +46,7 @@ in
in
''
assertFileRegex \
"home-path/${binPath}/${cfg.wrappedPackageName}" \
"home-path/${binPath}/${cfg.finalPackage.meta.mainProgram}" \
MOZ_APP_LAUNCHER
assertDirectoryExists "home-files/${cfg.profilesPath}/basic"

View File

@@ -48,7 +48,7 @@ in
in
''
assertFileRegex \
"home-path/${binPath}/${cfg.wrappedPackageName}" \
"home-path/${binPath}/${cfg.finalPackage.meta.mainProgram}" \
MOZ_APP_LAUNCHER
assertDirectoryExists "home-files/${cfg.profilesPath}/basic"

View File

@@ -44,7 +44,7 @@ in
in
''
assertFileRegex \
"home-path/${binPath}/${cfg.wrappedPackageName}" \
"home-path/${binPath}/${cfg.finalPackage.meta.mainProgram}" \
MOZ_APP_LAUNCHER
assertDirectoryExists "home-files/${cfg.profilesPath}/basic"

View File

@@ -25,7 +25,7 @@ in
binaryName = cfg.wrappedPackageName;
gtk3 = null;
meta.description = "I pretend to be ${cfg.name}";
meta.mainProgram = lib.toLower cfg.name;
meta.mainProgram = cfg.wrappedPackageName;
};
outPath = null;
buildScript =