feat: deno test --filter (#4570)

This commit is contained in:
Ryan Dahl 2020-04-02 09:26:40 -04:00 committed by GitHub
parent ff0b32f81d
commit c738797944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 325 additions and 289 deletions

View file

@ -61,15 +61,24 @@ pub fn prepare_test_modules_urls(
Ok(prepared)
}
pub fn render_test_file(modules: Vec<Url>, fail_fast: bool) -> String {
pub fn render_test_file(
modules: Vec<Url>,
fail_fast: bool,
filter: Option<String>,
) -> String {
let mut test_file = "".to_string();
for module in modules {
test_file.push_str(&format!("import \"{}\";\n", module.to_string()));
}
let run_tests_cmd =
format!("Deno.runTests({{ failFast: {} }});\n", fail_fast);
let options = if let Some(filter) = filter {
json!({ "failFast": fail_fast, "filter": filter })
} else {
json!({ "failFast": fail_fast })
};
let run_tests_cmd = format!("Deno.runTests({});\n", options);
test_file.push_str(&run_tests_cmd);
test_file