tests.nixpkgs-check-by-name: Use real lib for tests

This way we can also detect regressions caused by lib
This commit is contained in:
Silvan Mosberger 2024-01-10 19:42:02 +01:00
parent cbff02834f
commit d659d5f8ac
2 changed files with 5 additions and 21 deletions

View File

@ -226,7 +226,9 @@ mod tests {
}
fn test_nixpkgs(name: &str, path: &Path, expected_errors: &str) -> anyhow::Result<()> {
let extra_nix_path = Path::new("tests/mock-nixpkgs.nix");
let mock_nixpkgs_path = Path::new("tests/mock-nixpkgs.nix");
let real_lib_path = Path::new("../../../lib");
let extra_nix_path = [mock_nixpkgs_path, real_lib_path];
let base_path = path.join("base");
let base_nixpkgs = if base_path.exists() {
@ -238,7 +240,7 @@ mod tests {
// We don't want coloring to mess up the tests
let writer = temp_env::with_var("NO_COLOR", Some("1"), || -> anyhow::Result<_> {
let mut writer = vec![];
process(base_nixpkgs, &path, &[&extra_nix_path], &mut writer)
process(base_nixpkgs, &path, &extra_nix_path, &mut writer)
.with_context(|| format!("Failed test case {name}"))?;
Ok(writer)
})?;

View File

@ -25,25 +25,7 @@ It returns a Nixpkgs-like function that can be auto-called and evaluates to an a
let
# Simplified versions of lib functions
lib = {
fix = f: let x = f x; in x;
extends = overlay: f: final:
let
prev = f final;
in
prev // overlay final prev;
callPackageWith = autoArgs: fn: args:
let
f = if builtins.isFunction fn then fn else import fn;
fargs = builtins.functionArgs f;
allArgs = builtins.intersectAttrs fargs autoArgs // args;
in
f allArgs;
isDerivation = value: value.type or null == "derivation";
};
lib = import ../../../../lib;
# The base fixed-point function to populate the resulting attribute set
pkgsFun = self: {