[Backport release-25.05] lib/tests/test-with-nix: run misc.nix and fetchers.nix tests in the derivation (#434761)

This commit is contained in:
Emily
2025-08-19 16:00:49 +01:00
committed by GitHub
3 changed files with 15 additions and 26 deletions

View File

@@ -1,10 +0,0 @@
# Throws an error if any of our lib tests fail.
let
tests = [
"misc"
"systems"
];
all = builtins.concatLists (map (f: import (./. + "/${f}.nix")) tests);
in
if all == [ ] then null else throw (builtins.toJSON all)

View File

@@ -145,6 +145,11 @@ let
inherit expected;
};
dummyDerivation = derivation {
name = "name";
builder = "builder";
system = "system";
};
in
runTests {
@@ -782,18 +787,8 @@ runTests {
};
testSplitStringsDerivation = {
expr = take 3 (
strings.splitString "/" (derivation {
name = "name";
builder = "builder";
system = "system";
})
);
expected = [
""
"nix"
"store"
];
expr = lib.dropEnd 1 (strings.splitString "/" dummyDerivation);
expected = strings.splitString "/" builtins.storeDir;
};
testSplitVersionSingle = {
@@ -841,7 +836,7 @@ runTests {
in
{
storePath = isStorePath goodPath;
storePathDerivation = isStorePath (import ../.. { system = "x86_64-linux"; }).hello;
storePathDerivation = isStorePath dummyDerivation;
storePathAppendix = isStorePath "${goodPath}/bin/python";
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
asPath = isStorePath (/. + goodPath);
@@ -926,7 +921,7 @@ runTests {
};
testHasInfixDerivation = {
expr = hasInfix "hello" (import ../.. { system = "x86_64-linux"; }).hello;
expr = hasInfix "name" dummyDerivation;
expected = true;
};

View File

@@ -18,8 +18,6 @@
pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}"
{
buildInputs = [
(import ./check-eval.nix)
(import ./fetchers.nix)
(import ../path/tests {
inherit pkgs;
})
@@ -71,6 +69,12 @@ pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}"
echo "Running lib/tests/systems.nix"
[[ $(nix-instantiate --eval --strict lib/tests/systems.nix | tee /dev/stderr) == '[ ]' ]];
echo "Running lib/tests/misc.nix"
[[ $(nix-instantiate --eval --strict lib/tests/misc.nix | tee /dev/stderr) == '[ ]' ]];
echo "Running lib/tests/fetchers.nix"
[[ $(nix-instantiate --eval --strict lib/tests/fetchers.nix | tee /dev/stderr) == '[ ]' ]];
mkdir $out
echo success > $out/${nix.version}
''