nix-helpers: a3b492440ecc15ba9f7302200ebafa7fc5913bd8
1: { attrsToDirs', hello, runCommand, writeScript }:
2:
3: {
4: # Our filename contains a "'" which means it isn't a valid Nix store path.
5: # Make sure we can still include it.
6: punctuated = attrsToDirs' "attrsToDirsTest" {
7: foo = { bar = ./.. + "/attrsToDirs'/default.nix"; };
8: };
9:
10: # Nix complains if strings refer to store paths, so check that we avoid this
11: storePaths =
12: attrsToDirs' "storePathTest" { foo = { bar = "${hello}/bin/hello"; }; };
13:
14: # Combine the above problems
15: punctuatedStore = attrsToDirs' "punctuatedStorePathTest" {
16: foo = { bar = "${./..}/attrsToDirs'/default.nix"; };
17: };
18:
19: # Check that dependencies of (strings of) paths become dependencies of the
20: # resulting derivation.
21: dependenciesPreserved = with rec {
22: file1 = writeScript "test-file1" "content1";
23: file2 = writeScript "test-file2" "content2";
24: link1 = runCommand "test-link1" { inherit file1; } ''
25: mkdir "$out"
26: ln -s "$file1" "$out/link1"
27: '';
28: link2 = runCommand "test-link2" { inherit file2; } ''
29: ln -s "$file2" "$out"
30: '';
31: dir = attrsToDirs' "dirsWithDeps" {
32: entry1 = "${link1}/link1";
33: entry2 = "${link2}";
34: };
35: };
36: runCommand "dependenciesPreservedTest" { inherit dir; } ''
37: function fail {
38: echo "$*" 1>&2
39: exit 1
40: }
41:
42: [[ -d "$dir" ]] || fail "No such directory '$dir'"
43: [[ -e "$dir"/entry1 ]] || fail "No entry1 in '$dir'"
44: [[ -e "$dir"/entry2 ]] || fail "No entry2 in '$dir'"
45:
46: file1=$(readlink -f "$dir"/entry1)
47: file2=$(readlink -f "$dir"/entry2)
48:
49: [[ -e "$file1" ]] || fail "Destination '$file1' not found"
50: [[ -e "$file2" ]] || fail "Destination '$file2' not found"
51:
52: grep 'content1' < "$file1" > /dev/null || fail "No content in '$file1'"
53: grep 'content2' < "$file2" > /dev/null || fail "No content in '$file2'"
54:
55: mkdir "$out"
56: '';
57: }
Generated by git2html.