Studio: run the src-tauri unit tests in CI and fix the two that never ran (#7558)

studio-tauri-smoke.yml only ever built the crate, so none of its ~100 unit
tests executed. Running them surfaced two that were broken on platforms CI
never exercised:

- non_utf8_import_name_preserves_csv_extension built a filename containing a
  raw 0xFF byte. Linux stores that fine, macOS enforces UTF-8 on APFS/HFS+ and
  refuses to create it, so the test panicked on the unwrap. Skip when the
  filesystem rejects the name; the branch under test is only reachable where
  such a file can exist.

- losing_a_studio_package_changes_the_fingerprint created the posix venv
  layout unconditionally, but site_packages_dirs() only walks
  lib/<pyver>/site-packages on unix and looks at Lib/site-packages on Windows.
  The dist-info was therefore invisible to the fingerprint there, removing it
  changed nothing and the assert_ne could never hold. Build the layout the
  code actually reads for the target platform.

Add the cargo test step to the existing Tauri job, where the toolchain and
WebKit dev packages are already installed.
This commit is contained in:
Daniel Han 2026-07-28 07:01:13 -07:00 committed by GitHub
commit 71f7e1087b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 2 deletions

View file

@ -335,7 +335,13 @@ mod tests {
let path = std::env::temp_dir().join(OsString::from_vec(vec![
b'u', b'n', b's', b'l', b'o', b't', b'h', 0xff, b'.', b'c', b's', b'v',
]));
fs::write(&path, "role,content\nuser,hello\n").unwrap();
// Linux happily stores arbitrary bytes in a filename, but macOS enforces
// UTF-8 on APFS/HFS+ and rejects this name outright. The name-recovery
// path being asserted here is only reachable where such a file can
// exist, so skip rather than fail on filesystems that forbid it.
if fs::write(&path, "role,content\nuser,hello\n").is_err() {
return;
}
let imported = read_selected_import(Some(path.clone())).unwrap().unwrap();
assert_eq!(imported.name, "chat-import.csv");
let _ = fs::remove_file(path);

View file

@ -704,7 +704,15 @@ mod tests {
fs::write(venv.join("pyvenv.cfg"), "home = /usr/bin\n").unwrap();
fs::write(venv.join("unsloth_install_manifest.json"), "{}").unwrap();
let site_packages = venv.join("lib").join("python3.11").join("site-packages");
// site_packages_dirs() only walks lib/<pyver>/site-packages on unix; on
// Windows it looks at Lib/site-packages. Building the posix layout
// everywhere left the dist-info invisible to the fingerprint on Windows,
// so removing it changed nothing and the assert_ne below could not hold.
let site_packages = if cfg!(windows) {
venv.join("Lib").join("site-packages")
} else {
venv.join("lib").join("python3.11").join("site-packages")
};
fs::create_dir_all(site_packages.join("unsloth_cli").join("commands")).unwrap();
fs::write(
site_packages