1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-07 06:46:59 -05:00

fix(lsp/testing): don't queue modules without tests (#20277)

Fixes https://github.com/denoland/vscode_deno/issues/890.
This commit is contained in:
Nayeem Rahman 2023-08-25 10:12:11 +01:00 committed by Bartek Iwańczuk
parent a42ac7f686
commit 5f69cda3d9
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 26 additions and 11 deletions

View file

@ -158,4 +158,8 @@ impl TestDefinitions {
.iter()
.find(|td| td.id.as_str() == id.as_ref())
}
pub fn is_empty(&self) -> bool {
self.discovered.is_empty() && self.injected.is_empty()
}
}

View file

@ -71,11 +71,7 @@ fn as_queue_and_filters(
}
}
}
}
// if we didn't have any specific include filters, we assume that all modules
// will be tested
if queue.is_empty() {
} else {
queue.extend(tests.keys().cloned());
}
@ -97,6 +93,8 @@ fn as_queue_and_filters(
}
}
queue.retain(|s| !tests.get(s).unwrap().is_empty());
(queue, filters)
}
@ -816,16 +814,28 @@ mod tests {
#[test]
fn test_as_queue_and_filters() {
let specifier = ModuleSpecifier::parse("file:///a/file.ts").unwrap();
// Regression test for https://github.com/denoland/vscode_deno/issues/890.
let non_test_specifier =
ModuleSpecifier::parse("file:///a/no_tests.ts").unwrap();
let params = lsp_custom::TestRunRequestParams {
id: 1,
kind: lsp_custom::TestRunKind::Run,
include: Some(vec![lsp_custom::TestIdentifier {
text_document: lsp::TextDocumentIdentifier {
uri: specifier.clone(),
include: Some(vec![
lsp_custom::TestIdentifier {
text_document: lsp::TextDocumentIdentifier {
uri: specifier.clone(),
},
id: None,
step_id: None,
},
id: None,
step_id: None,
}]),
lsp_custom::TestIdentifier {
text_document: lsp::TextDocumentIdentifier {
uri: non_test_specifier.clone(),
},
id: None,
step_id: None,
},
]),
exclude: vec![lsp_custom::TestIdentifier {
text_document: lsp::TextDocumentIdentifier {
uri: specifier.clone(),
@ -860,6 +870,7 @@ mod tests {
script_version: "1".to_string(),
};
tests.insert(specifier.clone(), test_definitions.clone());
tests.insert(non_test_specifier, Default::default());
let (queue, filters) = as_queue_and_filters(&params, &tests);
assert_eq!(json!(queue), json!([specifier]));
let mut exclude = HashMap::new();