Split up example tests into smaller batches and provide info on which example is failing (#6896)
* Give example info for failing std example tests Signed-off-by: Nick Cameron <nrc@ncameron.org> * Shard example tests into 10 Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -100,18 +100,21 @@ fn do_for_each_std_mod(item: proc_macro2::TokenStream) -> proc_macro2::TokenStre
|
|||||||
let filename = e.file_name();
|
let filename = e.file_name();
|
||||||
filename.to_str().unwrap().strip_suffix(".kcl").map(str::to_owned)
|
filename.to_str().unwrap().strip_suffix(".kcl").map(str::to_owned)
|
||||||
}) {
|
}) {
|
||||||
let mut item = item.clone();
|
for i in 0..10_usize {
|
||||||
item.sig.ident = syn::Ident::new(&format!("{}_{}", item.sig.ident, name), Span::call_site());
|
let mut item = item.clone();
|
||||||
let stmts = &item.block.stmts;
|
item.sig.ident = syn::Ident::new(&format!("{}_{}_shard_{i}", item.sig.ident, name), Span::call_site());
|
||||||
//let name = format!("\"{name}\"");
|
let stmts = &item.block.stmts;
|
||||||
let block = quote! {
|
let block = quote! {
|
||||||
{
|
{
|
||||||
const STD_MOD_NAME: &str = #name;
|
const STD_MOD_NAME: &str = #name;
|
||||||
#(#stmts)*
|
const SHARD: usize = #i;
|
||||||
}
|
const SHARD_COUNT: usize = 10;
|
||||||
};
|
#(#stmts)*
|
||||||
item.block = Box::new(syn::parse2(block).unwrap());
|
}
|
||||||
result.extend(Some(item.into_token_stream()));
|
};
|
||||||
|
item.block = Box::new(syn::parse2(block).unwrap());
|
||||||
|
result.extend(Some(item.into_token_stream()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{collections::HashMap, fmt, str::FromStr};
|
use std::{fmt, str::FromStr};
|
||||||
|
|
||||||
|
use indexmap::IndexMap;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use tower_lsp::lsp_types::{
|
use tower_lsp::lsp_types::{
|
||||||
CompletionItem, CompletionItemKind, CompletionItemLabelDetails, Documentation, InsertTextFormat, MarkupContent,
|
CompletionItem, CompletionItemKind, CompletionItemLabelDetails, Documentation, InsertTextFormat, MarkupContent,
|
||||||
@ -449,7 +450,7 @@ pub struct ModData {
|
|||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub module_name: String,
|
pub module_name: String,
|
||||||
|
|
||||||
pub children: HashMap<String, DocData>,
|
pub children: IndexMap<String, DocData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModData {
|
impl ModData {
|
||||||
@ -465,7 +466,7 @@ impl ModData {
|
|||||||
qual_name,
|
qual_name,
|
||||||
summary: None,
|
summary: None,
|
||||||
description: None,
|
description: None,
|
||||||
children: HashMap::new(),
|
children: IndexMap::new(),
|
||||||
module_name,
|
module_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1236,23 +1237,21 @@ mod test {
|
|||||||
.expect_mod()
|
.expect_mod()
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(clippy::iter_over_hash_type)]
|
let mut count = 0;
|
||||||
for d in data.children.values() {
|
for d in data.children.values() {
|
||||||
if let DocData::Mod(_) = d {
|
if let DocData::Mod(_) = d {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, eg) in d.examples().enumerate() {
|
for (i, eg) in d.examples().enumerate() {
|
||||||
|
count += 1;
|
||||||
|
if count % SHARD_COUNT != SHARD {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let result = match crate::test_server::execute_and_snapshot(eg, None).await {
|
let result = match crate::test_server::execute_and_snapshot(eg, None).await {
|
||||||
Err(crate::errors::ExecError::Kcl(e)) => {
|
Err(crate::errors::ExecError::Kcl(e)) => {
|
||||||
errs.push(
|
errs.push(format!("Error testing example {}{i}: {}", d.name(), e.error.message()));
|
||||||
miette::Report::new(crate::errors::Report {
|
|
||||||
error: e.error,
|
|
||||||
filename: format!("{}{i}", d.name()),
|
|
||||||
kcl_source: eg.to_string(),
|
|
||||||
})
|
|
||||||
.to_string(),
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Err(other_err) => panic!("{}", other_err),
|
Err(other_err) => panic!("{}", other_err),
|
||||||
|
Reference in New Issue
Block a user