about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2018-12-18 01:03:34 +0000
committerGitHub <noreply@github.com>2018-12-18 01:03:34 +0000
commit670c5ac8ef2e1c6ad74af7d035e072afcd431aad (patch)
tree51944650274bd4c0b059689fc403fead5fdb2b0b /nixos
parentb72dc8c2f209d72455802d52852207d4e0f14752 (diff)
parent113a6b9325b92d483e6c2f12c35c2887ab175a8d (diff)
downloadnixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.tar
nixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.tar.gz
nixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.tar.bz2
nixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.tar.lz
nixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.tar.xz
nixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.tar.zst
nixlib-670c5ac8ef2e1c6ad74af7d035e072afcd431aad.zip
Merge pull request #46806 from Ma27/disallow-dash-separators-in-machine-declarations
nixos/testing: disallow special chars in machine names in network expressions
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/testing.nix20
1 files changed, 17 insertions, 3 deletions
diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix
index 0bb3fd53e853..96a42c2f3058 100644
--- a/nixos/lib/testing.nix
+++ b/nixos/lib/testing.nix
@@ -156,9 +156,23 @@ in rec {
       test = passMeta (runTests driver);
       report = passMeta (releaseTools.gcovReport { coverageRuns = [ test ]; });
 
-    in (if makeCoverageReport then report else test) // {
-      inherit nodes driver test;
-    };
+      nodeNames = builtins.attrNames nodes;
+      invalidNodeNames = lib.filter
+        (node: builtins.match "^[A-z_][A-z0-9_]+$" node == null) nodeNames;
+
+    in
+      if lib.length invalidNodeNames > 0 then
+        throw ''
+          Cannot create machines out of (${lib.concatStringsSep ", " invalidNodeNames})!
+          All machines are references as perl variables in the testing framework which will break the
+          script when special characters are allowed.
+
+          Please stick to alphanumeric chars and underscores as separation.
+        ''
+      else
+        (if makeCoverageReport then report else test) // {
+          inherit nodes driver test;
+        };
 
   runInMachine =
     { drv