5 nix-build -A tests.trivial-builders.writeTextFile
7 or to run an individual test case
10 nix-build -A tests.trivial-builders.writeTextFile.foo
12 { lib, runCommand, runtimeShell, writeTextFile }:
14 veryWeirdName = ''here's a name with some "bad" characters, like spaces and quotes'';
16 lib.recurseIntoAttrs {
22 destination = "/bin/foo";
30 assert pkg.meta.mainProgram == "foo";
31 assert baseNameOf (lib.getExe pkg) == "foo";
32 assert pkg.name == "bar";
33 runCommand "test-writeTextFile-different-exe-name" {} ''
34 PATH="${lib.makeBinPath [ pkg ]}:$PATH"
40 weird-name = writeTextFile {
42 destination = "/etc/${veryWeirdName}";
45 # intentionally hardcode everything here, to make sure
46 # Nix does not mess with file paths
48 name="here's a name with some \"bad\" characters, like spaces and quotes"
49 fullPath="$out/etc/$name"
51 if [ -f "$fullPath" ]; then
52 echo "[PASS] File exists!"
54 echo "[FAIL] File was not created at expected path!"
58 content=$(<"$fullPath")
61 if [ "$content" = "$expected" ]; then
62 echo "[PASS] Contents match!"
64 echo "[FAIL] File contents don't match!"
65 echo " Expected: $expected"