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();
 | 
			
		||||
        filename.to_str().unwrap().strip_suffix(".kcl").map(str::to_owned)
 | 
			
		||||
    }) {
 | 
			
		||||
        let mut item = item.clone();
 | 
			
		||||
        item.sig.ident = syn::Ident::new(&format!("{}_{}", item.sig.ident, name), Span::call_site());
 | 
			
		||||
        let stmts = &item.block.stmts;
 | 
			
		||||
        //let name = format!("\"{name}\"");
 | 
			
		||||
        let block = quote! {
 | 
			
		||||
            {
 | 
			
		||||
                const STD_MOD_NAME: &str = #name;
 | 
			
		||||
                #(#stmts)*
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        item.block = Box::new(syn::parse2(block).unwrap());
 | 
			
		||||
        result.extend(Some(item.into_token_stream()));
 | 
			
		||||
        for i in 0..10_usize {
 | 
			
		||||
            let mut item = item.clone();
 | 
			
		||||
            item.sig.ident = syn::Ident::new(&format!("{}_{}_shard_{i}", item.sig.ident, name), Span::call_site());
 | 
			
		||||
            let stmts = &item.block.stmts;
 | 
			
		||||
            let block = quote! {
 | 
			
		||||
                {
 | 
			
		||||
                    const STD_MOD_NAME: &str = #name;
 | 
			
		||||
                    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()));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    result
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
use std::{collections::HashMap, fmt, str::FromStr};
 | 
			
		||||
use std::{fmt, str::FromStr};
 | 
			
		||||
 | 
			
		||||
use indexmap::IndexMap;
 | 
			
		||||
use regex::Regex;
 | 
			
		||||
use tower_lsp::lsp_types::{
 | 
			
		||||
    CompletionItem, CompletionItemKind, CompletionItemLabelDetails, Documentation, InsertTextFormat, MarkupContent,
 | 
			
		||||
@ -449,7 +450,7 @@ pub struct ModData {
 | 
			
		||||
    pub description: Option<String>,
 | 
			
		||||
    pub module_name: String,
 | 
			
		||||
 | 
			
		||||
    pub children: HashMap<String, DocData>,
 | 
			
		||||
    pub children: IndexMap<String, DocData>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl ModData {
 | 
			
		||||
@ -465,7 +466,7 @@ impl ModData {
 | 
			
		||||
            qual_name,
 | 
			
		||||
            summary: None,
 | 
			
		||||
            description: None,
 | 
			
		||||
            children: HashMap::new(),
 | 
			
		||||
            children: IndexMap::new(),
 | 
			
		||||
            module_name,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -1236,23 +1237,21 @@ mod test {
 | 
			
		||||
                .expect_mod()
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        #[allow(clippy::iter_over_hash_type)]
 | 
			
		||||
        let mut count = 0;
 | 
			
		||||
        for d in data.children.values() {
 | 
			
		||||
            if let DocData::Mod(_) = d {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            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 {
 | 
			
		||||
                    Err(crate::errors::ExecError::Kcl(e)) => {
 | 
			
		||||
                        errs.push(
 | 
			
		||||
                            miette::Report::new(crate::errors::Report {
 | 
			
		||||
                                error: e.error,
 | 
			
		||||
                                filename: format!("{}{i}", d.name()),
 | 
			
		||||
                                kcl_source: eg.to_string(),
 | 
			
		||||
                            })
 | 
			
		||||
                            .to_string(),
 | 
			
		||||
                        );
 | 
			
		||||
                        errs.push(format!("Error testing example {}{i}: {}", d.name(), e.error.message()));
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                    Err(other_err) => panic!("{}", other_err),
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user