From b0bef29651ca9f70b24dac7370f080d4bd1bf5ec Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 3 Jun 2026 05:47:57 +0200 Subject: [PATCH] fix(tests): replace #[test] with #[tokio::test] on 13 async fns in terraphim_rolegraph Refs #2040 Async test functions decorated with #[test] compile and appear to pass but the test runner drops the returned Future without polling it -- the async body never executes. This converts all 13 affected functions in crates/terraphim_rolegraph/src/lib.rs to #[tokio::test]. Affected functions: test_split_paragraphs, test_find_matching_node_idss, test_find_matching_node_idss_ac_values, test_terraphim_engineer, test_rolegraph, test_is_all_terms_connected_by_path_true, test_is_all_terms_connected_by_path_false, tfidf_empty_index_returns_empty, tfidf_exact_match_scores_high, tfidf_no_match_scores_zero, tfidf_partial_match, tfidf_threshold_filters, two_pass_aho_corasick_first. Post-fix: 20 tests pass (1 deliberately #[ignore]d), execution time increases from ~0ms to 2.21s confirming async bodies now execute. --- crates/terraphim_rolegraph/src/lib.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/terraphim_rolegraph/src/lib.rs b/crates/terraphim_rolegraph/src/lib.rs index c707b6cd9..9ab8685c3 100644 --- a/crates/terraphim_rolegraph/src/lib.rs +++ b/crates/terraphim_rolegraph/src/lib.rs @@ -1500,7 +1500,7 @@ mod tests { .unwrap() } - #[test] + #[tokio::test] async fn test_split_paragraphs() { let paragraph = "This is the first sentence.\n\n This is the second sentence. This is the second sentence? This is the second sentence| This is the second sentence!\n\nThis is the third sentence. Mr. John Johnson Jr. was born in the U.S.A but earned his Ph.D. in Israel before joining Nike Inc. as an engineer. He also worked at craigslist.org as a business analyst."; let sentences = split_paragraphs(paragraph); @@ -1522,7 +1522,7 @@ mod tests { ); } - #[test] + #[tokio::test] async fn test_find_matching_node_idss() { let query = "I am a text with the word Life cycle concepts and bar and Trained operators and maintainers, project direction, some bingo words Paradigm Map and project planning, then again: some bingo words Paradigm Map and project planning, then repeats: Trained operators and maintainers, project direction"; let role = "system operator".to_string(); @@ -1534,7 +1534,7 @@ mod tests { assert_eq!(matches.len(), 7); } - #[test] + #[tokio::test] async fn test_find_matching_node_idss_ac_values() { let query = "life cycle framework I am a text with the word Life cycle concepts and bar and Trained operators and maintainers, project direction, some bingo words Paradigm Map and project planning, then again: some bingo words Paradigm Map and project planning, then repeats: Trained operators and maintainers, project direction"; let role = "system operator".to_string(); @@ -1554,7 +1554,7 @@ mod tests { ); } - #[test] + #[tokio::test] async fn test_terraphim_engineer() { let role_name = "Terraphim Engineer".to_string(); const DEFAULT_HAYSTACK_PATH: &str = "docs/src/"; @@ -1661,7 +1661,7 @@ mod tests { println!("Edges count {:?}", rolegraph.edges.len()); } - #[test] + #[tokio::test] async fn test_rolegraph() { let role = "system operator".to_string(); let mut rolegraph = RoleGraph::new(role.into(), load_sample_thesaurus().await) @@ -1720,7 +1720,7 @@ mod tests { assert_eq!(results.len(), 4); } - #[test] + #[tokio::test] #[ignore] async fn test_is_all_terms_connected_by_path_true() { let role = "system operator".to_string(); @@ -1731,7 +1731,7 @@ mod tests { assert!(rolegraph.is_all_terms_connected_by_path(text)); } - #[test] + #[tokio::test] async fn test_is_all_terms_connected_by_path_false() { let role = "system operator".to_string(); let rolegraph = RoleGraph::new(role.into(), load_sample_thesaurus().await) @@ -2156,14 +2156,14 @@ mod tests { } // TriggerIndex unit tests - #[test] + #[tokio::test] async fn tfidf_empty_index_returns_empty() { let index = TriggerIndex::new(0.3); let results = index.query("any query"); assert!(results.is_empty()); } - #[test] + #[tokio::test] async fn tfidf_exact_match_scores_high() { let mut index = TriggerIndex::new(0.3); let mut triggers = AHashMap::new(); @@ -2176,7 +2176,7 @@ mod tests { assert!(results[0].1 >= 0.3); // Above threshold } - #[test] + #[tokio::test] async fn tfidf_no_match_scores_zero() { let mut index = TriggerIndex::new(0.3); let mut triggers = AHashMap::new(); @@ -2188,7 +2188,7 @@ mod tests { assert!(results.is_empty() || results.iter().all(|(_, score)| *score < 0.3)); } - #[test] + #[tokio::test] async fn tfidf_partial_match() { let mut index = TriggerIndex::new(0.1); // Lower threshold for partial match let mut triggers = AHashMap::new(); @@ -2201,7 +2201,7 @@ mod tests { assert!(results[0].1 > 0.0 && results[0].1 < 1.0); } - #[test] + #[tokio::test] async fn tfidf_threshold_filters() { let mut index = TriggerIndex::new(0.8); // High threshold let mut triggers = AHashMap::new(); @@ -2217,7 +2217,7 @@ mod tests { } // Integration tests for two-pass search - #[test] + #[tokio::test] async fn two_pass_aho_corasick_first() { // Create a simple scenario where Aho-Corasick finds matches let mut index = TriggerIndex::new(0.3);