-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit test for derivation "advanced attrs"
Co-Authored-By: John Ericson <[email protected]>
- Loading branch information
1 parent
2f5fdab
commit 84b53a1
Showing
20 changed files
with
493 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/unit/libexpr/data/derivation/advanced-attributes-defaults.drv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Derive([("out","/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults","","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("builder","/bin/bash"),("name","advanced-attributes-defaults"),("out","/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults"),("system","my-system")]) |
6 changes: 6 additions & 0 deletions
6
tests/unit/libexpr/data/derivation/advanced-attributes-defaults.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
derivation { | ||
name = "advanced-attributes-defaults"; | ||
system = "my-system"; | ||
builder = "/bin/bash"; | ||
args = [ "-c" "echo hello > $out" ]; | ||
} |
1 change: 1 addition & 0 deletions
1
tests/unit/libexpr/data/derivation/advanced-attributes-structured-attrs-defaults.drv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Derive([("dev","/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev","",""),("out","/nix/store/f8f8nvnx32bxvyxyx2ff7akbvwhwd9dw-advanced-attributes-structured-attrs-defaults","","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}"),("dev","/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev"),("out","/nix/store/f8f8nvnx32bxvyxyx2ff7akbvwhwd9dw-advanced-attributes-structured-attrs-defaults")]) |
8 changes: 8 additions & 0 deletions
8
tests/unit/libexpr/data/derivation/advanced-attributes-structured-attrs-defaults.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
derivation { | ||
name = "advanced-attributes-structured-attrs-defaults"; | ||
system = "my-system"; | ||
builder = "/bin/bash"; | ||
args = [ "-c" "echo hello > $out" ]; | ||
outputs = [ "out" "dev" ]; | ||
__structuredAttrs = true; | ||
} |
1 change: 1 addition & 0 deletions
1
tests/unit/libexpr/data/derivation/advanced-attributes-structured-attrs.drv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Derive([("bin","/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin","",""),("dev","/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev","",""),("out","/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs","","")],[("/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv",["out"]),("/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-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\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"],\"disallowedRequisites\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"],\"allowedRequisites\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin"),("dev","/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev"),("out","/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs")]) |
45 changes: 45 additions & 0 deletions
45
tests/unit/libexpr/data/derivation/advanced-attributes-structured-attrs.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
let | ||
system = "my-system"; | ||
foo = derivation { | ||
inherit system; | ||
name = "foo"; | ||
builder = "/bin/bash"; | ||
args = ["-c" "echo foo > $out"]; | ||
}; | ||
bar = derivation { | ||
inherit system; | ||
name = "bar"; | ||
builder = "/bin/bash"; | ||
args = ["-c" "echo bar > $out"]; | ||
}; | ||
in | ||
derivation { | ||
inherit system; | ||
name = "advanced-attributes-structured-attrs"; | ||
builder = "/bin/bash"; | ||
args = [ "-c" "echo hello > $out" ]; | ||
__sandboxProfile = "sandcastle"; | ||
__noChroot = true; | ||
__impureHostDeps = ["/usr/bin/ditto"]; | ||
impureEnvVars = ["UNICORN"]; | ||
__darwinAllowLocalNetworking = true; | ||
outputs = [ "out" "bin" "dev" ]; | ||
__structuredAttrs = true; | ||
outputChecks = { | ||
out = { | ||
allowedReferences = [foo]; | ||
allowedRequisites = [foo]; | ||
}; | ||
bin = { | ||
disallowedReferences = [bar]; | ||
disallowedRequisites = [bar]; | ||
}; | ||
dev = { | ||
maxSize = 789; | ||
maxClosureSize = 5909; | ||
}; | ||
}; | ||
requiredSystemFeatures = ["rainbow" "uid-range"]; | ||
preferLocalBuild = true; | ||
allowSubstitutes = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Derive([("out","/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes","","")],[("/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv",["out"]),("/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo"),("allowedRequisites","/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo"),("builder","/bin/bash"),("disallowedReferences","/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"),("disallowedRequisites","/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")]) |
33 changes: 33 additions & 0 deletions
33
tests/unit/libexpr/data/derivation/advanced-attributes.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let | ||
system = "my-system"; | ||
foo = derivation { | ||
inherit system; | ||
name = "foo"; | ||
builder = "/bin/bash"; | ||
args = ["-c" "echo foo > $out"]; | ||
}; | ||
bar = derivation { | ||
inherit system; | ||
name = "bar"; | ||
builder = "/bin/bash"; | ||
args = ["-c" "echo bar > $out"]; | ||
}; | ||
in | ||
derivation { | ||
inherit system; | ||
name = "advanced-attributes"; | ||
builder = "/bin/bash"; | ||
args = [ "-c" "echo hello > $out" ]; | ||
__sandboxProfile = "sandcastle"; | ||
__noChroot = true; | ||
__impureHostDeps = ["/usr/bin/ditto"]; | ||
impureEnvVars = ["UNICORN"]; | ||
__darwinAllowLocalNetworking = true; | ||
allowedReferences = [foo]; | ||
allowedRequisites = [foo]; | ||
disallowedReferences = [bar]; | ||
disallowedRequisites = [bar]; | ||
requiredSystemFeatures = ["rainbow" "uid-range"]; | ||
preferLocalBuild = true; | ||
allowSubstitutes = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "gtest/gtest.h" | ||
#include <string> | ||
#include "tests/characterization.hh" | ||
#include "tests/libexpr.hh" | ||
#include "derivations.hh" | ||
|
||
namespace nix { | ||
|
||
class DerivationTest : public CharacterizationTest, public LibExprTest | ||
{ | ||
Path unitTestData = getUnitTestData() + "/derivation"; | ||
|
||
public: | ||
Path goldenMaster(std::string_view testStem) const override | ||
{ | ||
return unitTestData + "/" + testStem; | ||
} | ||
}; | ||
|
||
#define EXPR_DRV_TEST(NAME, STEM) \ | ||
TEST_F(DerivationTest, Derivation_##NAME) \ | ||
{ \ | ||
writeTest( \ | ||
STEM ".drv", \ | ||
[&]() -> Derivation { \ | ||
Value v = eval(readFile(goldenMaster(STEM ".nix"))); \ | ||
Symbol s = state.symbols.create("drvPath"); \ | ||
auto attr = v.attrs() -> get(s); \ | ||
state.forceValueDeep(*attr->value); \ | ||
NixStringContext context; \ | ||
auto storePath = state.coerceToStorePath(attr->pos, *attr->value, context, ""); \ | ||
\ | ||
return store->readDerivation(storePath); \ | ||
}, \ | ||
[&](const auto & file) { \ | ||
auto s = readFile(file); \ | ||
return parseDerivation(*store, std::move(s), STEM); \ | ||
}, \ | ||
[&](const auto & file, const auto & got) { \ | ||
auto s = got.unparse(*store, false); \ | ||
return writeFile(file, std::move(s)); \ | ||
}); \ | ||
} | ||
|
||
EXPR_DRV_TEST(advancedAttributes, "advanced-attributes"); | ||
EXPR_DRV_TEST(advancedAttributes_defaults, "advanced-attributes-defaults"); | ||
EXPR_DRV_TEST(advancedAttributes_structuredAttrs, "advanced-attributes-structured-attrs"); | ||
EXPR_DRV_TEST(advancedAttributes_structuredAttrs_defaults, "advanced-attributes-structured-attrs-defaults"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/unit/libstore/data/derivation/advanced-attributes-defaults.drv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../libexpr/data/derivation/advanced-attributes-defaults.drv |
22 changes: 22 additions & 0 deletions
22
tests/unit/libstore/data/derivation/advanced-attributes-defaults.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"args": [ | ||
"-c", | ||
"echo hello > $out" | ||
], | ||
"builder": "/bin/bash", | ||
"env": { | ||
"builder": "/bin/bash", | ||
"name": "advanced-attributes-defaults", | ||
"out": "/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults", | ||
"system": "my-system" | ||
}, | ||
"inputDrvs": {}, | ||
"inputSrcs": [], | ||
"name": "advanced-attributes-defaults", | ||
"outputs": { | ||
"out": { | ||
"path": "/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults" | ||
} | ||
}, | ||
"system": "my-system" | ||
} |
1 change: 1 addition & 0 deletions
1
tests/unit/libstore/data/derivation/advanced-attributes-structured-attrs-defaults.drv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../libexpr/data/derivation/advanced-attributes-structured-attrs-defaults.drv |
24 changes: 24 additions & 0 deletions
24
tests/unit/libstore/data/derivation/advanced-attributes-structured-attrs-defaults.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"args": [ | ||
"-c", | ||
"echo hello > $out" | ||
], | ||
"builder": "/bin/bash", | ||
"env": { | ||
"__json": "{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}", | ||
"dev": "/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev", | ||
"out": "/nix/store/f8f8nvnx32bxvyxyx2ff7akbvwhwd9dw-advanced-attributes-structured-attrs-defaults" | ||
}, | ||
"inputDrvs": {}, | ||
"inputSrcs": [], | ||
"name": "advanced-attributes-structured-attrs-defaults", | ||
"outputs": { | ||
"dev": { | ||
"path": "/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev" | ||
}, | ||
"out": { | ||
"path": "/nix/store/f8f8nvnx32bxvyxyx2ff7akbvwhwd9dw-advanced-attributes-structured-attrs-defaults" | ||
} | ||
}, | ||
"system": "my-system" | ||
} |
1 change: 1 addition & 0 deletions
1
tests/unit/libstore/data/derivation/advanced-attributes-structured-attrs.drv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../libexpr/data/derivation/advanced-attributes-structured-attrs.drv |
41 changes: 41 additions & 0 deletions
41
tests/unit/libstore/data/derivation/advanced-attributes-structured-attrs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"args": [ | ||
"-c", | ||
"echo hello > $out" | ||
], | ||
"builder": "/bin/bash", | ||
"env": { | ||
"__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\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"],\"disallowedRequisites\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"],\"allowedRequisites\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}", | ||
"bin": "/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin", | ||
"dev": "/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev", | ||
"out": "/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs" | ||
}, | ||
"inputDrvs": { | ||
"/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv": { | ||
"dynamicOutputs": {}, | ||
"outputs": [ | ||
"out" | ||
] | ||
}, | ||
"/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv": { | ||
"dynamicOutputs": {}, | ||
"outputs": [ | ||
"out" | ||
] | ||
} | ||
}, | ||
"inputSrcs": [], | ||
"name": "advanced-attributes-structured-attrs", | ||
"outputs": { | ||
"bin": { | ||
"path": "/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin" | ||
}, | ||
"dev": { | ||
"path": "/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev" | ||
}, | ||
"out": { | ||
"path": "/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs" | ||
} | ||
}, | ||
"system": "my-system" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../libexpr/data/derivation/advanced-attributes.drv |
Oops, something went wrong.