macos: Ghostty.Shell.escape unit tests (#11162)

*AI Disclosure:* These were written using the Claude Agent in Xcode
26.3, partly as an excuse to try out that latest integration.
This commit is contained in:
Mitchell Hashimoto
2026-03-04 08:12:15 -08:00
committed by GitHub

View File

@@ -2,6 +2,34 @@ import Testing
@testable import Ghostty
struct ShellTests {
@Test(arguments: [
("hello", "hello"),
("", ""),
("file name", "file\\ name"),
("a\\b", "a\\\\b"),
("(foo)", "\\(foo\\)"),
("[bar]", "\\[bar\\]"),
("{baz}", "\\{baz\\}"),
("<qux>", "\\<qux\\>"),
("say\"hi\"", "say\\\"hi\\\""),
("it's", "it\\'s"),
("`cmd`", "\\`cmd\\`"),
("wow!", "wow\\!"),
("#comment", "\\#comment"),
("$HOME", "\\$HOME"),
("a&b", "a\\&b"),
("a;b", "a\\;b"),
("a|b", "a\\|b"),
("*.txt", "\\*.txt"),
("file?.log", "file\\?.log"),
("col1\tcol2", "col1\\\tcol2"),
("$(echo 'hi')", "\\$\\(echo\\ \\'hi\\'\\)"),
("/tmp/my file (1).txt", "/tmp/my\\ file\\ \\(1\\).txt"),
])
func escape(input: String, expected: String) {
#expect(Ghostty.Shell.escape(input) == expected)
}
@Test(arguments: [
("", "''"),
("filename", "filename"),