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:
1 parent
d1eb32b4f7
commit
1431a8a1d8
30 files changed
+1668
-240
No files matched your search
@@ -245,6 +245,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn init_is_a_noop_on_windows() {
|
||||
// i18n is unsupported on Windows (Zig returns before looking at it).
|
||||
assert!(init(std::path::Path::new("ghostty")).is_ok());
|
||||
assert!(init(std::path::Path::new("/")).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn init_rejects_dirless_resources_dir() {
|
||||
assert!(matches!(
|
||||
init(std::path::Path::new("ghostty")),
|
||||
|
||||
@@ -25,6 +25,39 @@ pub enum Error {
|
||||
Io(#[from] io::Error),
|
||||
}
|
||||
|
||||
/// `std.fs.Dir.realpath` / `posix.realpath`: the canonical absolute path.
|
||||
///
|
||||
/// `std::fs::canonicalize` returns an extended-length `\\?\C:\...` path on
|
||||
/// Windows, while Zig's `realpath` (`GetFinalPathNameByHandle` through the NT
|
||||
/// object name) yields the plain DOS path `C:\...`. The verbatim form rejects
|
||||
/// `/` separators and is not accepted as a working directory by `cmd.exe`, so
|
||||
/// it must not leak into config values or child processes.
|
||||
pub fn realpath(path: impl AsRef<std::path::Path>) -> io::Result<PathBuf> {
|
||||
let real = std::fs::canonicalize(path)?;
|
||||
#[cfg(windows)]
|
||||
let real = strip_verbatim_prefix(real);
|
||||
Ok(real)
|
||||
}
|
||||
|
||||
/// Turn `\\?\C:\x` into `C:\x` and `\\?\UNC\srv\share\x` into
|
||||
/// `\\srv\share\x`; other paths are returned unchanged.
|
||||
#[cfg_attr(not(windows), allow(dead_code))]
|
||||
pub(crate) fn strip_verbatim_prefix(path: PathBuf) -> PathBuf {
|
||||
let Some(s) = path.to_str() else {
|
||||
return path;
|
||||
};
|
||||
if let Some(rest) = s.strip_prefix(r"\\?\UNC\") {
|
||||
return PathBuf::from(format!(r"\\{rest}"));
|
||||
}
|
||||
if let Some(rest) = s.strip_prefix(r"\\?\") {
|
||||
let b = rest.as_bytes();
|
||||
if b.len() >= 2 && b[0].is_ascii_alphabetic() && b[1] == b':' {
|
||||
return PathBuf::from(rest);
|
||||
}
|
||||
}
|
||||
path
|
||||
}
|
||||
|
||||
/// Search for "cmd" in the PATH and return the absolute path. Non-UTF-8
|
||||
/// bytes are carried via [`crate::osbytes`]; see [`expand_os`].
|
||||
pub fn expand(cmd: &crate::osbytes::EncodedOs) -> Result<Option<crate::osbytes::EncodedOs>, Error> {
|
||||
@@ -104,6 +137,24 @@ fn is_executable(_meta: &std::fs::Metadata) -> bool {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn strip_verbatim_prefix_cases() {
|
||||
let t = |a: &str| strip_verbatim_prefix(PathBuf::from(a));
|
||||
assert_eq!(t(r"\\?\C:\a\b"), PathBuf::from(r"C:\a\b"));
|
||||
assert_eq!(t(r"\\?\UNC\srv\share\x"), PathBuf::from(r"\\srv\share\x"));
|
||||
assert_eq!(t(r"\\?\GLOBALROOT\x"), PathBuf::from(r"\\?\GLOBALROOT\x"));
|
||||
assert_eq!(t(r"C:\a"), PathBuf::from(r"C:\a"));
|
||||
assert_eq!(t("/usr/bin"), PathBuf::from("/usr/bin"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn realpath_has_no_verbatim_prefix() {
|
||||
let tmp = crate::TempDir::init().unwrap();
|
||||
let p = realpath(tmp.path()).unwrap();
|
||||
assert!(!p.to_string_lossy().starts_with(r"\\?\"), "{p:?}");
|
||||
assert!(p.is_dir());
|
||||
}
|
||||
|
||||
/// Plain-text wrapper over [`expand`] for the literals used below.
|
||||
fn expand(cmd: &str) -> Result<Option<String>, Error> {
|
||||
super::expand(&crate::osbytes::EncodedOs::from_plain_text(cmd))
|
||||
|
||||
@@ -180,7 +180,13 @@ mod tests {
|
||||
let _g = LOCK.lock().unwrap();
|
||||
detect().unwrap();
|
||||
let before = backend();
|
||||
assert!(!prefer(Backend::Iocp));
|
||||
// Iocp is the Windows candidate; Epoll is never one there.
|
||||
let non_candidate = if cfg!(windows) {
|
||||
Backend::Epoll
|
||||
} else {
|
||||
Backend::Iocp
|
||||
};
|
||||
assert!(!prefer(non_candidate));
|
||||
assert_eq!(backend(), before);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user