Merge pull request #46806 from Ma27/disallow-dash-separators-in-machine-declarations

nixos/testing: disallow special chars in machine names in network expressions
This commit is contained in:
Franz Pletz 2018-12-18 01:03:34 +00:00 committed by GitHub
commit 670c5ac8ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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