tests: rework derivation stubbing
Instead of having to manually stub packages that should not be downloaded we instead automatically stub all packages (except a small list of whitelisted ones). Tests can re-introduce the real package by using the `realPkgs` module argument.
This commit is contained in:
parent
c5c2cbc866
commit
7a3f0b3b8d
480 changed files with 3557 additions and 5511 deletions
|
|
@ -1,25 +1,21 @@
|
|||
modulePath:
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, realPkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
cfg = lib.getAttrFromPath modulePath config;
|
||||
|
||||
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
|
||||
in lib.mkIf config.test.enableBig
|
||||
(lib.setAttrByPath modulePath { enable = true; } // {
|
||||
home.stateVersion = "19.09";
|
||||
|
||||
in {
|
||||
imports = [ firefoxMockOverlay ];
|
||||
_module.args.pkgs = lib.mkForce realPkgs;
|
||||
|
||||
config = lib.mkIf config.test.enableBig
|
||||
(lib.setAttrByPath modulePath { enable = true; } // {
|
||||
home.stateVersion = "19.09";
|
||||
|
||||
nmt.script = ''
|
||||
package=${cfg.package}
|
||||
finalPackage=${cfg.finalPackage}
|
||||
if [[ $package != $finalPackage ]]; then
|
||||
fail "Expected finalPackage ($finalPackage) to equal package ($package)"
|
||||
fi
|
||||
'';
|
||||
});
|
||||
}
|
||||
nmt.script = ''
|
||||
package=${cfg.package}
|
||||
finalPackage=${cfg.finalPackage}
|
||||
if [[ $package != $finalPackage ]]; then
|
||||
fail "Expected finalPackage ($finalPackage) to equal package ($package)"
|
||||
fi
|
||||
'';
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,30 +1,36 @@
|
|||
modulePath:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
{ config, lib, realPkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
cfg = getAttrFromPath modulePath config;
|
||||
cfg = lib.getAttrFromPath modulePath config;
|
||||
|
||||
in {
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
"${cfg.wrappedPackageName}-unwrapped" =
|
||||
pkgs.runCommandLocal "${cfg.wrappedPackageName}-0" {
|
||||
meta.description = "I pretend to be ${cfg.name}";
|
||||
passthru.gtk3 = null;
|
||||
} ''
|
||||
mkdir -p "$out"/{bin,lib}
|
||||
touch "$out/bin/${cfg.wrappedPackageName}"
|
||||
chmod 755 "$out/bin/${cfg.wrappedPackageName}"
|
||||
'';
|
||||
test.stubs = let unwrappedName = "${cfg.wrappedPackageName}-unwrapped";
|
||||
in {
|
||||
"${unwrappedName}" = {
|
||||
name = unwrappedName;
|
||||
extraAttrs = {
|
||||
binaryName = cfg.wrappedPackageName;
|
||||
gtk3 = null;
|
||||
meta.description = "I pretend to be ${cfg.name}";
|
||||
};
|
||||
outPath = null;
|
||||
buildScript = ''
|
||||
echo BUILD
|
||||
mkdir -p "$out"/{bin,lib}
|
||||
touch "$out/bin/${cfg.wrappedPackageName}"
|
||||
chmod 755 "$out/bin/${cfg.wrappedPackageName}"
|
||||
'';
|
||||
};
|
||||
|
||||
chrome-gnome-shell =
|
||||
pkgs.runCommandLocal "dummy-chrome-gnome-shell" { } ''
|
||||
mkdir -p $out/lib/mozilla/native-messaging-hosts
|
||||
touch $out/lib/mozilla/native-messaging-hosts/dummy
|
||||
'';
|
||||
})
|
||||
];
|
||||
chrome-gnome-shell = {
|
||||
buildScript = ''
|
||||
mkdir -p $out/lib/mozilla/native-messaging-hosts
|
||||
touch $out/lib/mozilla/native-messaging-hosts/dummy
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) mozlz4a; }) ];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue