From 19a4a309e4a8d4db9d23d404f6e1f7a9393d0a87 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:01:13 +0100 Subject: [PATCH] test: cover generated device-name path components Exercise device names, extensions, nested components and safe near-matches using the existing device-name classification. --- .../src/automation/file_access/tests.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/engine/src/automation/file_access/tests.rs b/crates/engine/src/automation/file_access/tests.rs index d642befb1..0e80de0f6 100644 --- a/crates/engine/src/automation/file_access/tests.rs +++ b/crates/engine/src/automation/file_access/tests.rs @@ -9,6 +9,27 @@ use serde_json::json; use super::{Access, Roots, allow, confined, current}; use crate::Session; +#[test] +fn generated_export_paths_escape_device_components_and_preserve_other_names() { + for (path, expected) in [ + ("CON", "_CON"), + ("CoN.txt", "_CoN.txt"), + ("nul.txt", "_nul.txt"), + ("PRN/icon", "_PRN/icon"), + ("folder/COM1", "folder/_COM1"), + ("LPT9.png", "_LPT9.png"), + ("COM¹", "_COM¹"), + ("LPT²/icon", "_LPT²/icon"), + ("CONIN$", "_CONIN$"), + ("HomeCON", "HomeCON"), + ("COM10", "COM10"), + ("CON@2x", "CON@2x"), + ("folder/.NUL", "folder/.NUL"), + ] { + assert_eq!(super::escape_device_names(path), expected, "{path}"); + } +} + /// A fresh folder for one test: `/figcraft-roots--`, holding `root/`, `root2/` /// (a sibling whose name starts like the root's) and `outside/`. struct Fixture(PathBuf);