about summary refs log tree commit diff
path: root/pkgs/pkgs-lib/tests/formats.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/pkgs-lib/tests/formats.nix')
-rw-r--r--pkgs/pkgs-lib/tests/formats.nix25
1 files changed, 21 insertions, 4 deletions
diff --git a/pkgs/pkgs-lib/tests/formats.nix b/pkgs/pkgs-lib/tests/formats.nix
index aa51e2c5842bc..dba7f981cbd9a 100644
--- a/pkgs/pkgs-lib/tests/formats.nix
+++ b/pkgs/pkgs-lib/tests/formats.nix
@@ -18,8 +18,11 @@ let
       }) [ def ]);
     in formatSet.generate "test-format-file" config;
 
-  runBuildTest = name: { drv, expected }: pkgs.runCommand name {} ''
-    if diff -u '${builtins.toFile "expected" expected}' '${drv}'; then
+  runBuildTest = name: { drv, expected }: pkgs.runCommand name {
+    passAsFile = ["expected"];
+    inherit expected drv;
+  } ''
+    if diff -u "$expectedPath" "$drv"; then
       touch "$out"
     else
       echo
@@ -171,11 +174,21 @@ in runBuildTests {
     '';
   };
 
-  # See also java-properties/default.nix for more complete tests
+  # This test is responsible for
+  #   1. testing type coercions
+  #   2. providing a more readable example test
+  # Whereas java-properties/default.nix tests the low level escaping, etc.
   testJavaProperties = {
     drv = evalFormat formats.javaProperties {} {
+      floaty = 3.1415;
+      tautologies = true;
+      contradictions = false;
       foo = "bar";
-      "1" = "2";
+      # # Disallowed at eval time, because it's ambiguous:
+      # # add to store or convert to string?
+      # root = /root;
+      "1" = 2;
+      package = pkgs.hello;
       "ütf 8" = "dûh";
       # NB: Some editors (vscode) show this _whole_ line in right-to-left order
       "الجبر" = "أكثر من مجرد أرقام";
@@ -184,7 +197,11 @@ in runBuildTests {
       # Generated with Nix
 
       1 = 2
+      contradictions = false
+      floaty = 3.141500
       foo = bar
+      package = ${pkgs.hello}
+      tautologies = true
       \u00fctf\ 8 = d\u00fbh
       \u0627\u0644\u062c\u0628\u0631 = \u0623\u0643\u062b\u0631 \u0645\u0646 \u0645\u062c\u0631\u062f \u0623\u0631\u0642\u0627\u0645
     '';