forked from lix-project/lix
Merge pull request #3881 from matthewbauer/fix-builtins-path
Fix builtins.path
This commit is contained in:
commit
358da474d7
|
@ -1199,7 +1199,7 @@ static void prim_path(EvalState & state, const Pos & pos, Value * * args, Value
|
||||||
string name;
|
string name;
|
||||||
Value * filterFun = nullptr;
|
Value * filterFun = nullptr;
|
||||||
auto method = FileIngestionMethod::Recursive;
|
auto method = FileIngestionMethod::Recursive;
|
||||||
Hash expectedHash(htSHA256);
|
std::optional<Hash> expectedHash;
|
||||||
|
|
||||||
for (auto & attr : *args[0]->attrs) {
|
for (auto & attr : *args[0]->attrs) {
|
||||||
const string & n(attr.name);
|
const string & n(attr.name);
|
||||||
|
|
|
@ -10,10 +10,16 @@ touch $TEST_ROOT/filterin/bak
|
||||||
touch $TEST_ROOT/filterin/bla.c.bak
|
touch $TEST_ROOT/filterin/bla.c.bak
|
||||||
ln -s xyzzy $TEST_ROOT/filterin/link
|
ln -s xyzzy $TEST_ROOT/filterin/link
|
||||||
|
|
||||||
nix-build ./filter-source.nix -o $TEST_ROOT/filterout
|
checkFilter() {
|
||||||
|
test ! -e $1/foo/bar
|
||||||
|
test -e $1/xyzzy
|
||||||
|
test -e $1/bak
|
||||||
|
test ! -e $1/bla.c.bak
|
||||||
|
test ! -L $1/link
|
||||||
|
}
|
||||||
|
|
||||||
test ! -e $TEST_ROOT/filterout/foo/bar
|
nix-build ./filter-source.nix -o $TEST_ROOT/filterout1
|
||||||
test -e $TEST_ROOT/filterout/xyzzy
|
checkFilter $TEST_ROOT/filterout1
|
||||||
test -e $TEST_ROOT/filterout/bak
|
|
||||||
test ! -e $TEST_ROOT/filterout/bla.c.bak
|
nix-build ./path.nix -o $TEST_ROOT/filterout2
|
||||||
test ! -L $TEST_ROOT/filterout/link
|
checkFilter $TEST_ROOT/filterout2
|
||||||
|
|
14
tests/path.nix
Normal file
14
tests/path.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
with import ./config.nix;
|
||||||
|
|
||||||
|
mkDerivation {
|
||||||
|
name = "filter";
|
||||||
|
builder = builtins.toFile "builder" "ln -s $input $out";
|
||||||
|
input =
|
||||||
|
builtins.path {
|
||||||
|
path = ((builtins.getEnv "TEST_ROOT") + "/filterin");
|
||||||
|
filter = path: type:
|
||||||
|
type != "symlink"
|
||||||
|
&& baseNameOf path != "foo"
|
||||||
|
&& !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path));
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue