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.
This commit is contained in:
Alyssa Ross 2023-03-22 15:49:32 +00:00
parent 78cd6d9833
commit 27f97953e0
No known key found for this signature in database
GPG key ID: F9DBED4859B271C0

View file

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