Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

test(i18n): tests that read English hold the language lock

Jareer4c5055e90226
diff --git a/src/crates/concat/src/format.rs b/src/crates/concat/src/format.rs
index 2724a3c0..27a1f04a 100644
--- a/src/crates/concat/src/format.rs
+++ b/src/crates/concat/src/format.rs
@@ -494,6 +494,7 @@ mod tests {
#[test]
fn phrases_are_coarse() {
+ let _english = crate::i18n::language_lock();
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|elapsed| elapsed.as_millis() as u64)
diff --git a/src/crates/concat/src/i18n.rs b/src/crates/concat/src/i18n.rs
index 1554cfa9..76a1aa13 100644
--- a/src/crates/concat/src/i18n.rs
+++ b/src/crates/concat/src/i18n.rs
@@ -369,14 +369,21 @@ fn parse(text: &str) -> Option<(String, HashMap<String, String>)> {
Some((name, strings))
}
+/// One test at a time may choose the language, since it is the process's;
+/// and a test that reads English must hold this too, or it reads whatever
+/// another thread chose (audit 2026-09-28, the two locale-flaky tests).
+#[cfg(test)]
+pub(crate) fn language_lock() -> std::sync::MutexGuard<'static, ()> {
+ static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
+ LOCK.lock().unwrap_or_else(|poisoned| poisoned.into_inner())
+}
+
#[cfg(test)]
mod tests {
use super::*;
- /// One test at a time may choose the language: it is the process's.
fn language() -> std::sync::MutexGuard<'static, ()> {
- static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
- LOCK.lock().unwrap_or_else(|poisoned| poisoned.into_inner())
+ language_lock()
}
/// The inventory: every key the app can ask for, as `en.json` lists
diff --git a/src/crates/concat/src/panes/speech.rs b/src/crates/concat/src/panes/speech.rs
index 20378db5..9cbcaf58 100644
--- a/src/crates/concat/src/panes/speech.rs
+++ b/src/crates/concat/src/panes/speech.rs
@@ -667,6 +667,7 @@ mod tests {
#[test]
fn a_voice_name_reads_as_a_person_would_say_it() {
+ let _english = crate::i18n::language_lock();
let (title, detail) = voice_label("af_heart");
assert_eq!(title, "Heart");
assert!(detail.contains("American"));