Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio desktop tests: keep temp paths distinct when the clock repeats (#12296)
Daniel Han18e78b2d89d2
diff --git a/studio/src-tauri/src/app_layout.rs b/studio/src-tauri/src/app_layout.rsindex ee97a2d39e5..e8884c0edc5 100644--- a/studio/src-tauri/src/app_layout.rs+++ b/studio/src-tauri/src/app_layout.rs@@ -191,12 +191,17 @@ mod tests {use std::time::{SystemTime, UNIX_EPOCH};fn temp_dir(name: &str) -> PathBuf {+ // Tests run on parallel threads, and macOS's clock resolves only microseconds, so two+ // calls with the same name could get the same path and one test's cleanup or swap would+ // land on the other's file. The counter keeps every name in this process distinct.+ static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);+ let seq = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);let nanos = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();std::env::temp_dir().join(format!(- "unsloth-app-layout-{name}-{}-{nanos}",+ "unsloth-app-layout-{name}-{}-{nanos}-{seq}",std::process::id()))}diff --git a/studio/src-tauri/src/native_file_dialogs.rs b/studio/src-tauri/src/native_file_dialogs.rsindex 8141c862663..924a3b63ae2 100644--- a/studio/src-tauri/src/native_file_dialogs.rs+++ b/studio/src-tauri/src/native_file_dialogs.rs@@ -853,12 +853,17 @@ mod tests {use std::time::{SystemTime, UNIX_EPOCH};fn temp_path(name: &str) -> PathBuf {+ // Tests run on parallel threads, and macOS's clock resolves only microseconds, so two+ // calls with the same name could get the same path and one test's cleanup or swap would+ // land on the other's file. The counter keeps every name in this process distinct.+ static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);+ let seq = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);let nanos = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();std::env::temp_dir().join(format!(- "unsloth-native-files-{name}-{}-{nanos}",+ "unsloth-native-files-{name}-{}-{nanos}-{seq}",std::process::id()))}diff --git a/studio/src-tauri/src/native_intents.rs b/studio/src-tauri/src/native_intents.rsindex 525ab58e5b8..50b12235bce 100644--- a/studio/src-tauri/src/native_intents.rs+++ b/studio/src-tauri/src/native_intents.rs@@ -871,12 +871,17 @@ mod tests {use std::time::{SystemTime, UNIX_EPOCH};fn temp_path(name: &str) -> PathBuf {+ // Tests run on parallel threads, and macOS's clock resolves only microseconds, so two+ // calls with the same name could get the same path and one test's cleanup or swap would+ // land on the other's file. The counter keeps every name in this process distinct.+ static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);+ let seq = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);let nanos = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();crate::native_path_policy::scratch_root().join(format!(- "unsloth-native-intents-{name}-{}-{nanos}",+ "unsloth-native-intents-{name}-{}-{nanos}-{seq}",std::process::id()))}@@ -1265,7 +1270,7 @@ mod tests {let err = state.sign_grant(&intent.path.token, NativePathOperation::ValidateModel).unwrap_err();- assert!(err.contains("changed"));+ assert!(err.contains("changed"), "unexpected error: {err}");let _ = fs::remove_file(path);}diff --git a/studio/src-tauri/src/native_path_policy.rs b/studio/src-tauri/src/native_path_policy.rsindex 3ab291662fb..30e432eb92b 100644--- a/studio/src-tauri/src/native_path_policy.rs+++ b/studio/src-tauri/src/native_path_policy.rs@@ -1252,12 +1252,17 @@ mod tests {use std::time::{SystemTime, UNIX_EPOCH};fn temp_path(name: &str) -> PathBuf {+ // Tests run on parallel threads, and macOS's clock resolves only microseconds, so two+ // calls with the same name could get the same path and one test's cleanup or swap would+ // land on the other's file. The counter keeps every name in this process distinct.+ static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);+ let seq = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);let nanos = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();scratch_root().join(format!(- "unsloth-native-policy-{name}-{}-{nanos}",+ "unsloth-native-policy-{name}-{}-{nanos}-{seq}",std::process::id()))}