YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: tests
Louis Beaumont25f458293ae4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 9e3801f57..841194ed2 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -76,3 +76,41 @@ jobs:- name: Run specific Windows OCR testrun: cargo test test_process_ocr_task_windows++ test-macos:+ runs-on: macos-latest+ steps:+ - uses: actions/checkout@v3+ - uses: actions/cache@v3+ with:+ path: |+ ~\AppData\Local\cargo\+ target\+ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}++ - uses: actions-rs/toolchain@v1+ with:+ profile: minimal+ toolchain: stable++ - name: setup Bun+ uses: oven-sh/setup-bun@v1++ - name: Run pre_build.js on+ shell: bash+ env:+ SKIP_SCREENPIPE_SETUP: true # avoid trying to copy screenpipe binaries, not yet built (next step)+ run: bun ./scripts/pre_build.js+ working-directory: ./examples/apps/screenpipe-app-tauri++ - name: Copy test image+ shell: bash+ run: |+ mkdir -p target/debug/deps || true+ cp screenpipe-vision/tests/testing_OCR.png target/debug/deps/++ - name: Run specific Apple OCR test+ shell: bash+ env:+ DYLD_LIBRARY_PATH: $(pwd)/screenpipe-vision/lib+ run: cargo test test_apple_native_ocrdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 3028af08b..ac7c5021c 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -83,6 +83,8 @@ Before submitting a pull request, run all the tests to ensure nothing has broken```bashcargo test+# on macos you need to set DYLD_LIBRARY_PATH for apple native OCR tests to run+DYLD_LIBRARY_PATH=$(pwd)/screenpipe-vision/lib cargo test```diff --git a/screenpipe-audio/tests/core_tests.rs b/screenpipe-audio/tests/core_tests.rsindex 7dffed8fa..e88a2e8cb 100644--- a/screenpipe-audio/tests/core_tests.rs+++ b/screenpipe-audio/tests/core_tests.rs@@ -2,7 +2,9 @@mod tests {use chrono::Utc;use log::{debug, LevelFilter};- use screenpipe_audio::{default_output_device, list_audio_devices, stt, WhisperModel};+ use screenpipe_audio::{+ default_output_device, list_audio_devices, stt, AudioTranscriptionEngine, WhisperModel,+ };use screenpipe_audio::{parse_audio_device, record_and_transcribe};use std::path::PathBuf;use std::process::Command;@@ -25,10 +27,10 @@ mod tests {}// ! what happen in github action?- #[test]+ #[tokio::test]#[ignore]- fn test_list_audio_devices() {- let devices = list_audio_devices().unwrap();+ async fn test_list_audio_devices() {+ let devices = list_audio_devices().await.unwrap();assert!(!devices.is_empty());}@@ -46,9 +48,13 @@ mod tests {println!("Loading audio file");let start = std::time::Instant::now();let whisper_model = WhisperModel::new().unwrap();- let cloud_audio = true; // Set this based on your test requirements- let text = stt("./test_data/selah.mp4", &whisper_model, cloud_audio).unwrap();+ let text = stt(+ "./test_data/selah.mp4",+ &whisper_model,+ Arc::new(AudioTranscriptionEngine::WhisperTiny),+ )+ .unwrap();let duration = start.elapsed();println!("Speech to text completed in {:?}", duration);@@ -63,7 +69,7 @@ mod tests {setup();// Setup- let device_spec = Arc::new(default_output_device().unwrap());+ let device_spec = Arc::new(default_output_device().await.unwrap());let duration = Duration::from_secs(30); // Record for 3 secondslet time = Utc::now().timestamp_millis();let output_path = PathBuf::from(format!("test_output_{}.mp4", time));@@ -119,7 +125,7 @@ mod tests {setup();// Setup- let device_spec = Arc::new(default_output_device().unwrap());+ let device_spec = Arc::new(default_output_device().await.unwrap());let duration = Duration::from_secs(30);let time = Utc::now().timestamp_millis();let output_path = PathBuf::from(format!("test_output_interrupt_{}.mp4", time));@@ -219,13 +225,14 @@ mod tests {// 3. the test should succeed (takes ~120s for some reason?) ! i think whisper is just slow as hell on cpu?// Setup- let device_spec = Arc::new(default_output_device().unwrap());+ let device_spec = Arc::new(default_output_device().await.unwrap());let output_path =PathBuf::from(format!("test_output_{}.mp4", Utc::now().timestamp_millis()));let output_path_2 = output_path.clone();- let cloud_audio = true; // Set this based on your test requirementslet (whisper_sender, mut whisper_receiver) =- create_whisper_channel(cloud_audio).await.unwrap();+ create_whisper_channel(Arc::new(AudioTranscriptionEngine::WhisperTiny))+ .await+ .unwrap();let is_running = Arc::new(AtomicBool::new(true));// Start recording in a separate threadlet recording_thread = tokio::spawn(async move {diff --git a/screenpipe-server/tests/chunking_test.rs b/screenpipe-server/tests/chunking_test.rsindex 88a1e6f51..81e8f6a0d 100644--- a/screenpipe-server/tests/chunking_test.rs+++ b/screenpipe-server/tests/chunking_test.rs@@ -1,4 +1,3 @@-use anyhow::Result;use screenpipe_server::chunking::text_chunking_simple;#[test]diff --git a/screenpipe-server/tests/db.rs b/screenpipe-server/tests/db.rsindex 1a3f8f3f8..f9df94f9b 100644--- a/screenpipe-server/tests/db.rs+++ b/screenpipe-server/tests/db.rs@@ -14,19 +14,21 @@ mod tests {async fn test_insert_and_search_ocr() {let db = setup_test_db().await;let _ = db.insert_video_chunk("test_video.mp4").await.unwrap();- let frame_id = db.insert_frame("").await.unwrap();+ let frame_id = db.insert_frame().await.unwrap();db.insert_ocr_text(frame_id,"Hello, world!","","",+ "",Arc::new(OcrEngine::Tesseract),+ false,).await.unwrap();let results = db- .search("Hello", ContentType::OCR, 100, 0, None, None, None)+ .search("Hello", ContentType::OCR, 100, 0, None, None, None, None).await.unwrap();assert_eq!(results.len(), 1);@@ -47,7 +49,7 @@ mod tests {.unwrap();let results = db- .search("audio", ContentType::Audio, 100, 0, None, None, None)+ .search("audio", ContentType::Audio, 100, 0, None, None, None, None).await.unwrap();assert_eq!(results.len(), 1);@@ -65,13 +67,15 @@ mod tests {// Insert OCR datalet _ = db.insert_video_chunk("test_video.mp4").await.unwrap();- let frame_id = db.insert_frame("").await.unwrap();+ let frame_id = db.insert_frame().await.unwrap();db.insert_ocr_text(frame_id,"Hello from OCR","","",+ "",Arc::new(OcrEngine::Tesseract),+ false,).await.unwrap();@@ -83,7 +87,7 @@ mod tests {.unwrap();let results = db- .search("Hello", ContentType::All, 100, 0, None, None, None)+ .search("Hello", ContentType::All, 100, 0, None, None, None, None).await.unwrap();assert_eq!(results.len(), 2);@@ -109,13 +113,15 @@ mod tests {// Insert OCR datalet _ = db.insert_video_chunk("test_video.mp4").await.unwrap();- let frame_id1 = db.insert_frame("").await.unwrap();+ let frame_id1 = db.insert_frame().await.unwrap();db.insert_ocr_text(frame_id1,"Hello from OCR 1","","",+ "",Arc::new(OcrEngine::Tesseract),+ false,).await.unwrap();@@ -135,13 +141,15 @@ mod tests {tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;// Insert remaining data- let frame_id2 = db.insert_frame("").await.unwrap();+ let frame_id2 = db.insert_frame().await.unwrap();db.insert_ocr_text(frame_id2,"Hello from OCR 2","","",+ "",Arc::new(OcrEngine::Tesseract),+ false,).await.unwrap();@@ -162,6 +170,7 @@ mod tests {Some(start_time),Some(end_time),None,+ None,).await.unwrap();@@ -178,6 +187,7 @@ mod tests {Some(mid_time),Some(end_time),None,+ None,).await.unwrap();@@ -198,6 +208,7 @@ mod tests {Some(start_time),Some(end_time),None,+ None,).await.unwrap();@@ -213,6 +224,7 @@ mod tests {Some(start_time),Some(end_time),None,+ None,).await.unwrap();@@ -227,13 +239,15 @@ mod tests {// Insert OCR datalet _ = db.insert_video_chunk("test_video.mp4").await.unwrap();- let frame_id1 = db.insert_frame("").await.unwrap();+ let frame_id1 = db.insert_frame().await.unwrap();db.insert_ocr_text(frame_id1,"Hello from OCR 1","","",+ "",Arc::new(OcrEngine::Tesseract),+ false,).await.unwrap();@@ -251,13 +265,15 @@ mod tests {tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;// Insert remaining data- let frame_id2 = db.insert_frame("").await.unwrap();+ let frame_id2 = db.insert_frame().await.unwrap();db.insert_ocr_text(frame_id2,"Hello from OCR 2","","",+ "",Arc::new(OcrEngine::Tesseract),+ false,).await.unwrap();@@ -278,6 +294,7 @@ mod tests {Some(mid_time),Some(end_time),None,+ None,).await.unwrap();@@ -297,6 +314,7 @@ mod tests {Some(start_time),Some(end_time),None,+ None,).await.unwrap();diff --git a/screenpipe-server/tests/endpoint_test.rs b/screenpipe-server/tests/endpoint_test.rsindex 00b9c900e..19da825e0 100644--- a/screenpipe-server/tests/endpoint_test.rs+++ b/screenpipe-server/tests/endpoint_test.rs@@ -98,9 +98,17 @@ mod tests {// Insert some recent datalet _ = db.insert_video_chunk("test_video.mp4").await.unwrap();- let frame_id = db.insert_frame("foo").await.unwrap();+ let frame_id = db.insert_frame().await.unwrap();let _ = db- .insert_ocr_text(frame_id, "Test OCR", "", "", Arc::new(OcrEngine::Tesseract))+ .insert_ocr_text(+ frame_id,+ "Test OCR",+ "",+ "",+ "",+ Arc::new(OcrEngine::Tesseract),+ false,+ ).await.unwrap();let audio_chunk_id = db.insert_audio_chunk("test_audio.wav").await.unwrap();@@ -143,9 +151,17 @@ mod tests {// Insert some stale data (more than 60 seconds old)let stale_time = Utc::now() - Duration::seconds(61);let _ = db.insert_video_chunk("test_video.mp4").await.unwrap();- let frame_id = db.insert_frame("foo").await.unwrap();+ let frame_id = db.insert_frame().await.unwrap();let _ = db- .insert_ocr_text(frame_id, "Test OCR", "", "", Arc::new(OcrEngine::Tesseract))+ .insert_ocr_text(+ frame_id,+ "Test OCR",+ "",+ "",+ "",+ Arc::new(OcrEngine::Tesseract),+ false,+ ).await.unwrap();let audio_chunk_id = db.insert_audio_chunk("test_audio.wav").await.unwrap();diff --git a/screenpipe-vision/tests/apple_vision_test.rs b/screenpipe-vision/tests/apple_vision_test.rsindex a331b10c7..612fecff2 100644--- a/screenpipe-vision/tests/apple_vision_test.rs+++ b/screenpipe-vision/tests/apple_vision_test.rs@@ -29,7 +29,7 @@ mod tests {println!("OCR text: {:?}", result);assert!(- result.contains("ocr_tx.receiver_count"),+ result.contains("receiver_count"),"OCR failed: {:?}",result);diff --git a/screenpipe-vision/tests/integration_test.rs b/screenpipe-vision/tests/integration_test.rsindex 43873e876..ea87f74c2 100644--- a/screenpipe-vision/tests/integration_test.rs+++ b/screenpipe-vision/tests/integration_test.rs@@ -17,17 +17,13 @@ fn test_ocr_output() -> Result<(), Box<dyn std::error::Error>> {// Start timinglet start = Instant::now();- let (text, data_output, json_output) = perform_ocr_tesseract(&image);+ let (text, json_output) = perform_ocr_tesseract(&image);// Stop timinglet duration = start.elapsed();let duration_secs = duration.as_secs_f64();// Calculate average confidence score- let total_conf: f32 = data_output.data.iter().map(|line| line.conf).sum();- let avg_conf = total_conf / data_output.data.len() as f32;-- println!("Average confidence score: {:.2}", avg_conf);// println!("TSV:");// println!("{}", tsv_output);