Skip to content

Commit

Permalink
tests.nixpkgs-check-by-name: Use real lib for tests
Browse files Browse the repository at this point in the history
This way we can also detect regressions caused by lib
  • Loading branch information
infinisil committed Jan 10, 2024
1 parent cbff028 commit d659d5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
6 changes: 4 additions & 2 deletions pkgs/test/nixpkgs-check-by-name/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
})?;
Expand Down
20 changes: 1 addition & 19 deletions pkgs/test/nixpkgs-check-by-name/tests/mock-nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit d659d5f

Please sign in to comment.