summary refs log tree commit diff
path: root/nixos/lib/test-driver
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-03-22 15:49:32 +0000
committerAlyssa Ross <hi@alyssa.is>2023-03-22 15:54:06 +0000
commit27f97953e06b3b9e7a4df4d43b26184db6a6625a (patch)
treeaf65ae830b0d8dfa93902f49d0128659862d3153 /nixos/lib/test-driver
parent78cd6d98336a57526850d976ae8caf1e459de30c (diff)
downloadnixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.tar
nixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.tar.gz
nixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.tar.bz2
nixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.tar.lz
nixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.tar.xz
nixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.tar.zst
nixpkgs-27f97953e06b3b9e7a4df4d43b26184db6a6625a.zip
nixos/test-driver: accept non-\w* filenames
What the code was trying to do was helpfully add a directory and
extension if none were specified, but it did this by checking whether
the filename was composed of a very limited character set that didn't
even include dashes.

With this change, the intention of the code is clearer, and I can put
dashes in my screenshot names.
Diffstat (limited to 'nixos/lib/test-driver')
-rw-r--r--nixos/lib/test-driver/test_driver/machine.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/nixos/lib/test-driver/test_driver/machine.py b/nixos/lib/test-driver/test_driver/machine.py
index 4929f2048ec..9de98c217a5 100644
--- a/nixos/lib/test-driver/test_driver/machine.py
+++ b/nixos/lib/test-driver/test_driver/machine.py
@@ -737,9 +737,10 @@ class Machine:
             self.connected = True
 
     def screenshot(self, filename: str) -> None:
-        word_pattern = re.compile(r"^\w+$")
-        if word_pattern.match(filename):
-            filename = os.path.join(self.out_dir, f"{filename}.png")
+        if "." not in filename:
+            filename += ".png"
+        if "/" not in filename:
+            filename = os.path.join(self.out_dir, filename)
         tmp = f"{filename}.ppm"
 
         with self.nested(