diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-03-22 15:49:32 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-03-22 15:54:06 +0000 |
commit | 27f97953e06b3b9e7a4df4d43b26184db6a6625a (patch) | |
tree | af65ae830b0d8dfa93902f49d0128659862d3153 /nixos/lib | |
parent | 78cd6d98336a57526850d976ae8caf1e459de30c (diff) |
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')
-rw-r--r-- | nixos/lib/test-driver/test_driver/machine.py | 7 |
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 4929f2048ecc3..9de98c217a583 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( |