test(windows): run the Windows code under Wine; theme preview parity

Windows was previously only compile-checked. With Wine 11 (staging)
and mingw available, scripts/windows-wine-test.sh (`just
test-windows-wine`) builds expat/FreeType/fontconfig for mingw under
target/wine-deps and runs the test suites of ghostty-vt, unicode,
datastruct, input, os, config, terminal, crash, termio and cli under
Wine (~2,700 tests). New termio/tests/exec_windows.rs drives real
cmd.exe children over ConPTY through Termio (output, exit codes,
typing, 120 KiB writes, stop, start failure). Fixes found: Windows
paths from fs::canonicalize leaked the \\?\ prefix (new
ghostty_os::path::realpath strips it like Zig); ghostty-font compiles
hb-ft for bundled HarfBuzz on Windows; ~25 tests had Unix assumptions.
Wine limitations are ignored with reasons (ResizePseudoConsole stub,
no POSIX rename over existing files) - docs/rewrite/notes/windows-wine.md.

+list-themes preview parity (former KNOWN_DIFFERENCES rows 5-9): the
search box ports vaxis TextInput (word navigation and editing bindings,
grapheme-wise editing), ASCII-only case folding, light initial colors
until terminal reports arrive (no COLORFGBG), and load errors end the
preview with exit 1; PTY tests compare with /usr/bin/ghostty.

Test Plan:
- just test-windows-wine
- cargo test -p ghostty-cli --test list_themes_pty
- cargo test --workspace --no-fail-fast (3601 passed)
This commit is contained in:
ddidderr committed 2026-10-12 17:23:24 +02:00
1 parent b95aae16ae
commit a8d0d624da
30 files changed
+1668 -240

No files matched your search

+22 -4
View File
@@ -4216,7 +4216,7 @@ impl Config {
// Any paths referenced from the CLI are relative to the current working
// directory.
let cwd = std::fs::canonicalize(".")?;
let cwd = crate::path::realpath(".")?;
self.expand_paths(&EncodedOs::from_path(&cwd))?;
Ok(())
}
@@ -5115,12 +5115,22 @@ mod tests {
fn write_theme(td: &TempDir, name: &str, data: &str) -> String {
let p = td.path().join(name);
std::fs::write(&p, data).unwrap();
std::fs::canonicalize(&p)
crate::path::realpath(&p)
.unwrap()
.to_string_lossy()
.into_owned()
}
/// A path as a `light:`/`dark:` pair value. Backslashes are escapes in
/// the pair syntax (as in Zig), so Windows paths must be quoted.
fn pair_value(path: &str) -> String {
if cfg!(windows) {
format!("\"{}\"", path.replace('\\', "\\\\"))
} else {
path.to_owned()
}
}
#[test]
fn handle_bom_in_config_files() {
{
@@ -5223,7 +5233,11 @@ mod tests {
let dark = write_theme(&td, "theme_dark", include_str!("testdata/theme_dark"));
let mut cfg_light = Config::default();
let mut i = it(&[&format!("--theme=light:{light},dark:{dark}")]);
let mut i = it(&[&format!(
"--theme=light:{},dark:{}",
pair_value(&light),
pair_value(&dark)
)]);
cfg_light.load_iter(&mut i).unwrap();
cfg_light.finalize().unwrap();
@@ -5407,7 +5421,11 @@ mod tests {
let td = TempDir::init().unwrap();
let light = write_theme(&td, "theme_light", include_str!("testdata/theme_light"));
let dark = write_theme(&td, "theme_dark", include_str!("testdata/theme_dark"));
let arg = format!("--theme=light:{light},dark:{dark}");
let arg = format!(
"--theme=light:{},dark:{}",
pair_value(&light),
pair_value(&dark)
);
// Light
{
+9 -1
View File
@@ -211,7 +211,15 @@ mod tests {
open(&e("/nonexistent/ghostty/file")).unwrap_err(),
OpenFileError::FileNotFound
);
assert_eq!(open(&e("/tmp")).unwrap_err(), OpenFileError::NotAFile);
// Windows opens a directory with `ERROR_ACCESS_DENIED` (Zig 0.15's
// `OpenFile` maps FILE_IS_A_DIRECTORY to AccessDenied as well), which
// is an "unexpected" open error there.
let dir_err = if cfg!(windows) {
OpenFileError::FileOpenFailed
} else {
OpenFileError::NotAFile
};
assert_eq!(open(&e("/tmp")).unwrap_err(), dir_err);
let p = std::env::temp_dir().join(format!("ghostty-file-load-{}", std::process::id()));
std::fs::write(&p, "").unwrap();
assert_eq!(
+23 -4
View File
@@ -158,7 +158,7 @@ impl Path {
std::fs::read_dir(&base_path)?;
let full = base_path.join(path.to_syscall_path()?);
let abs = match std::fs::canonicalize(&full) {
let abs = match realpath(&full) {
Ok(p) => EncodedOs::from_path(&p),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
// The file doesn't exist. Try to resolve the relative path
@@ -276,6 +276,18 @@ impl ConfigField for RepeatablePath {
}
}
/// `posix.realpath`: the canonical path without the `\\?\` verbatim prefix
/// `std::fs::canonicalize` adds on Windows (Zig's `realpath` has none).
#[cfg(windows)]
pub(crate) fn realpath(path: impl AsRef<std::path::Path>) -> std::io::Result<std::path::PathBuf> {
ghostty_os::path::realpath(path)
}
#[cfg(not(windows))]
pub(crate) fn realpath(path: impl AsRef<std::path::Path>) -> std::io::Result<std::path::PathBuf> {
std::fs::canonicalize(path)
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
@@ -391,7 +403,14 @@ mod tests {
let mut diags = DiagnosticList::default();
let mut p = Path::Required(e("../nope/x.conf"));
p.expand(&e("/tmp"), &mut diags).unwrap();
assert_eq!(p, Path::Required(e("/nope/x.conf")));
// Resolved lexically with the platform's separator (`\nope\x.conf`
// on Windows, like Zig's `std.fs.path.resolve`).
let expected = if cfg!(windows) {
"\\nope\\x.conf"
} else {
"/nope/x.conf"
};
assert_eq!(p, Path::Required(e(expected)));
let mut p = Path::Optional(e("/abs/path"));
p.expand(&e("/tmp"), &mut diags).unwrap();
@@ -403,7 +422,7 @@ mod tests {
#[test]
fn expand_interior_nul_resolves_the_c_string_prefix_like_zig() {
let tmp = ghostty_os::TempDir::init().unwrap();
let base = std::fs::canonicalize(tmp.path()).unwrap();
let base = realpath(tmp.path()).unwrap();
std::fs::write(base.join("exists"), b"x").unwrap();
// The syscall sees only the prefix, which exists: the real path of
@@ -429,7 +448,7 @@ mod tests {
fn expand_symlink_to_non_utf8_target_round_trips() {
use std::os::unix::ffi::OsStrExt;
let tmp = ghostty_os::TempDir::init().unwrap();
let base = std::fs::canonicalize(tmp.path()).unwrap();
let base = realpath(tmp.path()).unwrap();
let target = base.join(std::ffi::OsStr::from_bytes(b"t\xffarget"));
std::fs::write(&target, b"x").unwrap();
std::os::unix::fs::symlink(&target, base.join("link")).unwrap();
+23 -5
View File
@@ -381,9 +381,14 @@ mod tests {
);
let mut d = DiagnosticList::default();
assert!(open(&e("/tmp"), None, &mut d).is_none());
// Windows cannot open a directory as a file (AccessDenied).
assert_eq!(
d.items()[0].message,
"not reading theme from \"/tmp\": it is a directory"
if cfg!(windows) {
"failed to load theme from the path \"/tmp\": error.AccessDenied"
} else {
"not reading theme from \"/tmp\": it is a directory"
}
);
}
@@ -469,7 +474,11 @@ mod tests {
let mut d = DiagnosticList::default();
assert!(open(&e(name), Some(&EncodedOs::from_path(&dir)), &mut d).is_none());
assert!(
d.items()[0].message.ends_with("it is a directory"),
d.items()[0].message.ends_with(if cfg!(windows) {
"error.AccessDenied"
} else {
"it is a directory"
}),
"{}",
d.items()[0].message
);
@@ -484,7 +493,10 @@ mod tests {
std::fs::write(dir.join("themes/mytheme-zzz"), "background = #000000\n").unwrap();
let mut d = DiagnosticList::default();
let t = open(&e("mytheme-zzz"), Some(&EncodedOs::from_path(&dir)), &mut d).unwrap();
assert!(t.path.ends_with_plain("themes/mytheme-zzz"));
assert!(
t.path
.ends_with_plain(&format!("themes{}mytheme-zzz", std::path::MAIN_SEPARATOR))
);
assert!(d.is_empty());
std::fs::remove_dir_all(&dir).unwrap();
}
@@ -493,7 +505,13 @@ mod tests {
fn theme_not_found_lists_tried_paths() {
let mut d = DiagnosticList::default();
assert!(open(&e("nope-zzz"), Some(&e("/nonexistent-res")), &mut d).is_none());
assert!(d.items().iter().any(|x| x.message
== "theme \"nope-zzz\" not found, tried path \"/nonexistent-res/themes/nope-zzz\""));
let tried = std::path::Path::new("/nonexistent-res")
.join("themes")
.join("nope-zzz");
let want = format!(
"theme \"nope-zzz\" not found, tried path \"{}\"",
tried.display()
);
assert!(d.items().iter().any(|x| x.message == want));
}
}