Skip to content

fix(tests): replace #[test] with #[tokio::test] on 13 async fns Refs #2040#893

Open
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2040-tokio-test-async-fns
Open

fix(tests): replace #[test] with #[tokio::test] on 13 async fns Refs #2040#893
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2040-tokio-test-async-fns

Conversation

@AlexMikhalev
Copy link
Copy Markdown
Contributor

Problem

13 async test functions in crates/terraphim_rolegraph/src/lib.rs were decorated with #[test] instead of #[tokio::test]. These tests compiled and appeared to pass but never executed their async bodies -- the test runner received a Future, dropped it without polling, and recorded a pass since no panic occurred.

Fix

Replace #[test] with #[tokio::test] on all 13 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.

Verification

  • cargo test -p terraphim_rolegraph: 20 passed, 1 deliberately #[ignore]d
  • Execution time 2.21s (was ~0ms) confirming async bodies now execute
  • cargo clippy -p terraphim_rolegraph -- -D warnings: clean
  • cargo fmt -p terraphim_rolegraph -- --check: clean

Note on count

Issue listed 12 functions; inspection found 13 (the #2037 commit added test_is_all_terms_connected_by_path_true which also had #[test] before async fn). All 13 are fixed.

Refs terraphim/terraphim-ai#2040 (Gitea)

🤖 Generated with Terraphim AI

…rraphim_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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant