lib/tests/test-with-nix: run misc.nix and fetchers.nix tests in the derivation (#433729)

Emily 47e013c6 c5e2e42c

Changed files
+15 -26
lib
-10
lib/tests/check-eval.nix
···
-
# 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)
···
+9 -14
lib/tests/misc.nix
···
inherit expected;
};
in
runTests {
···
};
testSplitStringsDerivation = {
-
expr = take 3 (
-
strings.splitString "/" (derivation {
-
name = "name";
-
builder = "builder";
-
system = "system";
-
})
-
);
-
expected = [
-
""
-
"nix"
-
"store"
-
];
};
testSplitVersionSingle = {
···
in
{
storePath = isStorePath goodPath;
-
storePathDerivation = isStorePath (import ../.. { system = "x86_64-linux"; }).hello;
storePathAppendix = isStorePath "${goodPath}/bin/python";
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
asPath = isStorePath (/. + goodPath);
···
};
testHasInfixDerivation = {
-
expr = hasInfix "hello" (import ../.. { system = "x86_64-linux"; }).hello;
expected = true;
};
···
inherit expected;
};
+
dummyDerivation = derivation {
+
name = "name";
+
builder = "builder";
+
system = "system";
+
};
in
runTests {
···
};
testSplitStringsDerivation = {
+
expr = lib.dropEnd 1 (strings.splitString "/" dummyDerivation);
+
expected = strings.splitString "/" builtins.storeDir;
};
testSplitVersionSingle = {
···
in
{
storePath = isStorePath goodPath;
+
storePathDerivation = isStorePath dummyDerivation;
storePathAppendix = isStorePath "${goodPath}/bin/python";
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
asPath = isStorePath (/. + goodPath);
···
};
testHasInfixDerivation = {
+
expr = hasInfix "name" dummyDerivation;
expected = true;
};
+6 -2
lib/tests/test-with-nix.nix
···
pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}"
{
buildInputs = [
-
(import ./check-eval.nix)
-
(import ./fetchers.nix)
(import ../path/tests {
inherit pkgs;
})
···
echo "Running lib/tests/systems.nix"
[[ $(nix-instantiate --eval --strict lib/tests/systems.nix | tee /dev/stderr) == '[ ]' ]];
mkdir $out
echo success > $out/${nix.version}
···
pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}"
{
buildInputs = [
(import ../path/tests {
inherit pkgs;
})
···
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}