diff --git a/Cargo.lock b/Cargo.lock index 6e52ee0..50e8daa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5800,7 +5800,7 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xpaste" -version = "0.5.2" +version = "0.5.3" dependencies = [ "chrono", "embed-resource", @@ -5830,7 +5830,7 @@ dependencies = [ [[package]] name = "xpaste-core" -version = "0.5.2" +version = "0.5.3" dependencies = [ "chrono", "image", @@ -5845,7 +5845,7 @@ dependencies = [ [[package]] name = "xpaste-platform" -version = "0.5.2" +version = "0.5.3" dependencies = [ "block2", "dispatch2", diff --git a/Cargo.toml b/Cargo.toml index 336010f..ef7b563 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["src-tauri", "crates/xpaste-core", "crates/xpaste-platform"] [workspace.package] -version = "0.5.2" +version = "0.5.3" edition = "2024" rust-version = "1.90" diff --git a/crates/xpaste-platform/src/stream.rs b/crates/xpaste-platform/src/stream.rs index e8379e0..584e476 100644 --- a/crates/xpaste-platform/src/stream.rs +++ b/crates/xpaste-platform/src/stream.rs @@ -231,7 +231,7 @@ mod tests { assert!(s.next(Duration::from_millis(30)).is_none()); let e = t.elapsed(); assert!( - e >= Duration::from_millis(30) && e < Duration::from_millis(200), + e >= Duration::from_millis(30) && e < Duration::from_secs(2), "{e:?}" ); } @@ -246,8 +246,9 @@ mod tests { l2.push(frame(7)); }); let t = Instant::now(); - assert_eq!(s.next(Duration::from_secs(1)).map(|f| f.w), Some(7)); - assert!(t.elapsed() < Duration::from_millis(200)); + // 超时设得远大于上限:耗时低于上限说明是被唤醒的,不是等到了超时 + assert_eq!(s.next(Duration::from_secs(5)).map(|f| f.w), Some(7)); + assert!(t.elapsed() < Duration::from_secs(2)); h.join().unwrap(); } @@ -261,8 +262,8 @@ mod tests { l2.fail(); }); let t = Instant::now(); - assert!(s.next(Duration::from_secs(1)).is_none()); - assert!(t.elapsed() < Duration::from_millis(200)); + assert!(s.next(Duration::from_secs(5)).is_none()); + assert!(t.elapsed() < Duration::from_secs(2)); assert!(s.failed()); h.join().unwrap(); } @@ -300,7 +301,7 @@ mod tests { }, Duration::from_millis(10), ); - let f = s.next(Duration::from_millis(200)).expect("应有帧"); + let f = s.next(Duration::from_secs(5)).expect("应有帧"); assert_eq!((f.h, f.rgba.len()), (1, 4 * f.w as usize)); assert_eq!(s.mode(), "逐帧"); s.stop(); @@ -317,8 +318,9 @@ mod tests { || Err(PlatformError::Capture("x".into())), Duration::from_millis(10), ); + // 只是等待上限,满足即退出:CI 的 macOS 机器上 sleep(10ms) 常拖很久,200 ms 不够 5 次 let t = Instant::now(); - while !s.failed() && t.elapsed() < Duration::from_millis(200) { + while !s.failed() && t.elapsed() < Duration::from_secs(5) { thread::sleep(Duration::from_millis(5)); } assert!(s.failed()); diff --git a/package.json b/package.json index 8b13108..1727e71 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xpaste", "private": true, - "version": "0.5.2", + "version": "0.5.3", "type": "module", "packageManager": "pnpm@10.28.0", "scripts": {