tests.stdenv: deduplicate
This commit is contained in:
parent
fda61e9066
commit
68fb254bf2
|
@ -12,63 +12,12 @@ let
|
||||||
bootStdenv = stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv;
|
bootStdenv = stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv;
|
||||||
pkgsStructured = import pkgs.path { config = { structuredAttrsByDefault = true; }; inherit (stdenv.hostPlatform) system; };
|
pkgsStructured = import pkgs.path { config = { structuredAttrsByDefault = true; }; inherit (stdenv.hostPlatform) system; };
|
||||||
bootStdenvStructuredAttrsByDefault = pkgsStructured.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv;
|
bootStdenvStructuredAttrsByDefault = pkgsStructured.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv;
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
test-env-attrset = bootStdenv.mkDerivation {
|
|
||||||
name = "test-env-attrset";
|
|
||||||
dontUnpack = true;
|
|
||||||
dontConfigure = true;
|
|
||||||
dontBuild = true;
|
|
||||||
dontPatch = true;
|
|
||||||
dontFixup = true;
|
|
||||||
env = {
|
|
||||||
string = "testing-string";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
ccWrapperSubstitutionsTest = { name, stdenv', extraAttrs ? { } }:
|
||||||
declare -p string
|
|
||||||
echo "env.string = $string"
|
|
||||||
[[ $string == "testing-string" ]] || (echo "string was not testing-string" && false)
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
test-structured-env-attrset = bootStdenv.mkDerivation {
|
stdenv'.cc.overrideAttrs (previousAttrs: ({
|
||||||
name = "test-structured-env-attrset";
|
inherit name;
|
||||||
dontUnpack = true;
|
|
||||||
dontConfigure = true;
|
|
||||||
dontBuild = true;
|
|
||||||
dontPatch = true;
|
|
||||||
dontFixup = true;
|
|
||||||
__structuredAttrs = true;
|
|
||||||
env = {
|
|
||||||
string = "testing-string";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
declare -p string
|
|
||||||
echo "env.string = $string"
|
|
||||||
[[ $string == "testing-string" ]] || (echo "string was not testing-string" && false)
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
test-cc-wrapper-substitutions = bootStdenv.cc.overrideAttrs (previousAttrs: {
|
|
||||||
name = "test-cc-wrapper-substitutions";
|
|
||||||
|
|
||||||
postFixup = previousAttrs.postFixup + ''
|
|
||||||
declare -p wrapperName
|
|
||||||
echo "env.wrapperName = $wrapperName"
|
|
||||||
[[ $wrapperName == "CC_WRAPPER" ]] || (echo "wrapperName was not CC_WRAPPER" && false)
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
structuredAttrsByDefault = lib.recurseIntoAttrs {
|
|
||||||
|
|
||||||
test-cc-wrapper-substitutions = bootStdenvStructuredAttrsByDefault.cc.overrideAttrs (previousAttrs: {
|
|
||||||
name = "test-cc-wrapper-substitutions-structuredAttrsByDefault";
|
|
||||||
|
|
||||||
postFixup = previousAttrs.postFixup + ''
|
postFixup = previousAttrs.postFixup + ''
|
||||||
declare -p wrapperName
|
declare -p wrapperName
|
||||||
|
@ -76,32 +25,44 @@ in
|
||||||
[[ $wrapperName == "CC_WRAPPER" ]] || (echo "wrapperName was not CC_WRAPPER" && false)
|
[[ $wrapperName == "CC_WRAPPER" ]] || (echo "wrapperName was not CC_WRAPPER" && false)
|
||||||
declare -p suffixSalt
|
declare -p suffixSalt
|
||||||
echo "env.suffixSalt = $suffixSalt"
|
echo "env.suffixSalt = $suffixSalt"
|
||||||
[[ $suffixSalt == "${bootStdenvStructuredAttrsByDefault.cc.suffixSalt}" ]] || (echo "wrapperName was not ${bootStdenvStructuredAttrsByDefault.cc.suffixSalt}" && false)
|
[[ $suffixSalt == "${stdenv'.cc.suffixSalt}" ]] || (echo "wrapperName was not ${stdenv'.cc.suffixSalt}" && false)
|
||||||
|
|
||||||
grep -q "@out@" $out/bin/cc || echo "@out@ in $out/bin/cc was substituted"
|
grep -q "@out@" $out/bin/cc || echo "@out@ in $out/bin/cc was substituted"
|
||||||
grep -q "@suffixSalt@" $out/bin/cc && (echo "$out/bin/cc contains unsubstituted variables" && false)
|
grep -q "@suffixSalt@" $out/bin/cc && (echo "$out/bin/cc contains unsubstituted variables" && false)
|
||||||
|
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
});
|
} // extraAttrs));
|
||||||
|
|
||||||
test-structured-env-attrset = bootStdenvStructuredAttrsByDefault.mkDerivation {
|
testEnvAttrset = { name, stdenv', extraAttrs ? { } }:
|
||||||
name = "test-structured-env-attrset-structuredAttrsByDefault";
|
stdenv'.mkDerivation
|
||||||
dontUnpack = true;
|
({
|
||||||
dontConfigure = true;
|
inherit name;
|
||||||
dontBuild = true;
|
env = {
|
||||||
dontPatch = true;
|
string = "testing-string";
|
||||||
dontFixup = true;
|
};
|
||||||
env = {
|
|
||||||
string = "testing-string";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
passAsFile = [ "buildCommand" ];
|
||||||
declare -p string
|
buildCommand = ''
|
||||||
echo "env.string = $string"
|
declare -p string
|
||||||
[[ $string == "testing-string" ]] || (echo "string was not testing-string" && false)
|
echo "env.string = $string"
|
||||||
touch $out
|
[[ $string == "testing-string" ]] || (echo "string was not testing-string" && false)
|
||||||
'';
|
touch $out
|
||||||
};
|
'';
|
||||||
|
} // extraAttrs);
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
test-env-attrset = testEnvAttrset { name = "test-env-attrset"; stdenv' = bootStdenv; };
|
||||||
|
|
||||||
|
test-structured-env-attrset = testEnvAttrset { name = "test-structured-env-attrset"; stdenv' = bootStdenv; extraAttrs = { __structuredAttrs = true; }; };
|
||||||
|
|
||||||
|
test-cc-wrapper-substitutions = ccWrapperSubstitutionsTest { name = "test-cc-wrapper-substitutions"; stdenv' = bootStdenv; };
|
||||||
|
|
||||||
|
structuredAttrsByDefault = lib.recurseIntoAttrs {
|
||||||
|
test-cc-wrapper-substitutions = ccWrapperSubstitutionsTest { name = "test-cc-wrapper-substitutions-structuredAttrsByDefault"; stdenv' = bootStdenvStructuredAttrsByDefault; };
|
||||||
|
|
||||||
|
test-structured-env-attrset = testEnvAttrset { name = "test-structured-env-attrset-structuredAttrsByDefault"; stdenv' = bootStdenvStructuredAttrsByDefault; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue