mirror of
https://github.com/NixOS/nix
synced 2025-07-09 03:43:54 +02:00
Test derivation options with content-addressing too
Now, both the unit and functional tests relating to derivation options
are tested both ways -- with input addressing and content-addressing
derivations.
(cherry picked from commit 307dbe9914
)
This commit is contained in:
parent
37bcd29e5f
commit
f19184191e
37 changed files with 560 additions and 94 deletions
6
tests/functional/ca/derivation-advanced-attributes.sh
Executable file
6
tests/functional/ca/derivation-advanced-attributes.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
|
||||
cd ..
|
||||
source derivation-advanced-attributes.sh
|
|
@ -8,10 +8,11 @@ suites += {
|
|||
'name': 'ca',
|
||||
'deps': [],
|
||||
'tests': [
|
||||
'build-cache.sh',
|
||||
'build-with-garbage-path.sh',
|
||||
'build.sh',
|
||||
'build-cache.sh',
|
||||
'concurrent-builds.sh',
|
||||
'derivation-advanced-attributes.sh',
|
||||
'derivation-json.sh',
|
||||
'duplicate-realisation-in-closure.sh',
|
||||
'eval-store.sh',
|
||||
|
|
|
@ -12,11 +12,19 @@ badExitCode=0
|
|||
|
||||
store="$TEST_ROOT/store"
|
||||
|
||||
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
drvDir=ia
|
||||
flags=(--arg contentAddress false)
|
||||
else
|
||||
drvDir=ca
|
||||
flags=(--arg contentAddress true --extra-experimental-features ca-derivations)
|
||||
fi
|
||||
|
||||
for nixFile in derivation/*.nix; do
|
||||
drvPath=$(env -u NIX_STORE nix-instantiate --store "$store" --pure-eval --expr "$(< "$nixFile")")
|
||||
drvPath=$(env -u NIX_STORE nix-instantiate --store "$store" --pure-eval "${flags[@]}" --expr "$(< "$nixFile")")
|
||||
testName=$(basename "$nixFile" .nix)
|
||||
got="${store}${drvPath}"
|
||||
expected="derivation/$testName.drv"
|
||||
expected="derivation/${drvDir}/${testName}.drv"
|
||||
diffAndAcceptInner "$testName" "$got" "$expected"
|
||||
done
|
||||
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
derivation {
|
||||
name = "advanced-attributes-defaults";
|
||||
{ contentAddress }:
|
||||
|
||||
let
|
||||
caArgs =
|
||||
if contentAddress then
|
||||
{
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
derivation' = args: derivation (caArgs // args);
|
||||
|
||||
system = "my-system";
|
||||
|
||||
in
|
||||
derivation' {
|
||||
inherit system;
|
||||
name = "advanced-attributes-defaults";
|
||||
builder = "/bin/bash";
|
||||
args = [
|
||||
"-c"
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
derivation {
|
||||
name = "advanced-attributes-structured-attrs-defaults";
|
||||
{ contentAddress }:
|
||||
|
||||
let
|
||||
caArgs =
|
||||
if contentAddress then
|
||||
{
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
derivation' = args: derivation (caArgs // args);
|
||||
|
||||
system = "my-system";
|
||||
|
||||
in
|
||||
derivation' {
|
||||
inherit system;
|
||||
name = "advanced-attributes-structured-attrs-defaults";
|
||||
builder = "/bin/bash";
|
||||
args = [
|
||||
"-c"
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
{ contentAddress }:
|
||||
|
||||
let
|
||||
caArgs =
|
||||
if contentAddress then
|
||||
{
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
derivation' = args: derivation (caArgs // args);
|
||||
|
||||
system = "my-system";
|
||||
foo = derivation {
|
||||
|
||||
foo = derivation' {
|
||||
inherit system;
|
||||
name = "foo";
|
||||
builder = "/bin/bash";
|
||||
|
@ -9,7 +24,8 @@ let
|
|||
"echo foo > $out"
|
||||
];
|
||||
};
|
||||
bar = derivation {
|
||||
|
||||
bar = derivation' {
|
||||
inherit system;
|
||||
name = "bar";
|
||||
builder = "/bin/bash";
|
||||
|
@ -18,8 +34,9 @@ let
|
|||
"echo bar > $out"
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
derivation {
|
||||
derivation' {
|
||||
inherit system;
|
||||
name = "advanced-attributes-structured-attrs";
|
||||
builder = "/bin/bash";
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
{ contentAddress }:
|
||||
|
||||
let
|
||||
caArgs =
|
||||
if contentAddress then
|
||||
{
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
derivation' = args: derivation (caArgs // args);
|
||||
|
||||
system = "my-system";
|
||||
foo = derivation {
|
||||
|
||||
foo = derivation' {
|
||||
inherit system;
|
||||
name = "foo";
|
||||
builder = "/bin/bash";
|
||||
|
@ -9,7 +24,8 @@ let
|
|||
"echo foo > $out"
|
||||
];
|
||||
};
|
||||
bar = derivation {
|
||||
|
||||
bar = derivation' {
|
||||
inherit system;
|
||||
name = "bar";
|
||||
builder = "/bin/bash";
|
||||
|
@ -18,8 +34,9 @@ let
|
|||
"echo bar > $out"
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
derivation {
|
||||
derivation' {
|
||||
inherit system;
|
||||
name = "advanced-attributes";
|
||||
builder = "/bin/bash";
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Derive([("out","","r:sha256","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("builder","/bin/bash"),("name","advanced-attributes-defaults"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"),("outputHashAlgo","sha256"),("outputHashMode","recursive"),("system","my-system")])
|
|
@ -0,0 +1 @@
|
|||
Derive([("dev","","r:sha256",""),("out","","r:sha256","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}"),("dev","/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9")])
|
|
@ -0,0 +1 @@
|
|||
Derive([("bin","","r:sha256",""),("dev","","r:sha256",""),("out","","r:sha256","")],[("/nix/store/spfzlnkwb1v8s62yvh8vj1apd1kwjr5f-foo.drv",["out"]),("/nix/store/x1vpzav565aqr7ccmkn0wv0svkm1qrbl-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99\"],\"disallowedRequisites\":[\"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8\"],\"allowedRequisites\":[\"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8\"]}},\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/04f3da1kmbr67m3gzxikmsl4vjz5zf777sv6m14ahv22r65aac9m"),("dev","/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9")])
|
1
tests/functional/derivation/ca/advanced-attributes.drv
Normal file
1
tests/functional/derivation/ca/advanced-attributes.drv
Normal file
|
@ -0,0 +1 @@
|
|||
Derive([("out","","r:sha256","")],[("/nix/store/spfzlnkwb1v8s62yvh8vj1apd1kwjr5f-foo.drv",["out"]),("/nix/store/x1vpzav565aqr7ccmkn0wv0svkm1qrbl-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"),("allowedRequisites","/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"),("builder","/bin/bash"),("disallowedReferences","/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"),("disallowedRequisites","/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"),("outputHashAlgo","sha256"),("outputHashMode","recursive"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")])
|
Loading…
Add table
Add a link
Reference in a new issue