pub async fn run_and_collect_results(
    suite: fidl_fuchsia_test::SuiteProxy,
    mut sender: mpsc::Sender<TestEvent>,
    test_url: String,
) -> Result<(), anyhow::Error> {
    fx_vlog!(1, "enumerating tests");
    let (case_iterator, server_end) = fidl::endpoints::create_proxy()?;
    suite.get_tests(server_end).map_err(|e| format_err!("Error getting test steps: {}", e))?;

    let mut invocations = Vec::<Invocation>::new();
    loop {
        let cases = case_iterator.get_next().await?;
        if cases.is_empty() {
            break;
        }
        for case in cases {
            invocations.push(Invocation { name: Some(case.name.unwrap()), tag: None });
        }
    }
    fx_vlog!(1, "invocations: {:#?}", invocations);

    fx_vlog!(1, "running tests");
    let mut successful_completion = true; // will remain true, if there are no tests to run.
    let mut invocations_iter = invocations.into_iter();
    loop {
        const INVOCATIONS_CHUNK: usize = 50;
        let chunk = invocations_iter.by_ref().take(INVOCATIONS_CHUNK).collect::<Vec<_>>();
        if chunk.is_empty() {
            break;
        }
        successful_completion &= run_invocations(&suite, chunk, &mut sender)
            .map_err(|e| format_err!("Error running tests in '{}': {}", test_url, e))
            .await?;
    }
    if successful_completion {
        sender
            .send(TestEvent::Finish)
            .map_err(|e| format_err!("Error while sending TestFinished event: {}", e))
            .await?;
    }
    Ok(())
}
/// Runs the test component using `suite` and collects logs and results.
Runs the test component using `suite` and collects logs and results.
Runs the test component using ` suite ` and collects logs and results .
pub async fn run_and_collect_results(
    suite: fidl_fuchsia_test::SuiteProxy,
    mut sender: mpsc::Sender<TestEvent>,
    test_url: String,
) -> Result<(), anyhow::Error> {
    fx_vlog!(1, "enumerating tests");
    let (case_iterator, server_end) = fidl::endpoints::create_proxy()?;
    suite.get_tests(server_end).map_err(|e| format_err!("Error getting test steps: {}", e))?;
    let mut invocations = Vec::<Invocation>::new();
    loop {
        let cases = case_iterator.get_next().await?;
        if cases.is_empty() {
            break;
        }
        for case in cases {
            invocations.push(Invocation { name: Some(case.name.unwrap()), tag: None });
        }
    }
    fx_vlog!(1, "invocations: {:#?}", invocations);
    fx_vlog!(1, "running tests");
    let mut successful_completion = true; // will remain true, if there are no tests to run.
    let mut invocations_iter = invocations.into_iter();
    loop {
        const INVOCATIONS_CHUNK: usize = 50;
        let chunk = invocations_iter.by_ref().take(INVOCATIONS_CHUNK).collect::<Vec<_>>();
        if chunk.is_empty() {
            break;
        }
        successful_completion &= run_invocations(&suite, chunk, &mut sender)
            .map_err(|e| format_err!("Error running tests in '{}': {}", test_url, e))
            .await?;
    }
    if successful_completion {
        sender
            .send(TestEvent::Finish)
            .map_err(|e| format_err!("Error while sending TestFinished event: {}", e))
            .await?;
    }
    Ok(())
}
pub async fn run_and_collect_results ( suite : fidl_fuchsia_test :: SuiteProxy , mut sender : mpsc :: Sender < TestEvent > , test_url : String , ) -> Result < ( ) , anyhow :: Error > { fx_vlog ! ( 1 " " ) ; let ( case_iterator , server_end ) = fidl :: endpoints :: create_proxy ( ) ? ; suite . get_tests ( server_end ) . map_err ( | e | format_err ! ( " " e ) ) ? ; let mut invocations = Vec :: < Invocation > :: new ( ) ; loop { let cases = case_iterator . get_next ( ) . await ? ; if cases . is_empty ( ) { break ; } for case in cases { invocations . push ( Invocation { name : Some ( case . name . unwrap ( ) ) , tag : None } ) ; } } fx_vlog ! ( 1 " " invocations ) ; fx_vlog ! ( 1 " " ) ; let mut successful_completion = true ; // will remain true, if there are no tests to run. let mut invocations_iter = invocations . into_iter ( ) ; loop { const INVOCATIONS_CHUNK : usize = 50 ; let chunk = invocations_iter . by_ref ( ) . take ( INVOCATIONS_CHUNK ) . collect :: < Vec < _ > > ( ) ; if chunk . is_empty ( ) { break ; } successful_completion &= run_invocations ( & suite , chunk , & mut sender ) . map_err ( | e | format_err ! ( " " test_url e ) ) . await ? ; } if successful_completion { sender . send ( TestEvent :: Finish ) . map_err ( | e | format_err ! ( " " e ) ) . await ? ; } Ok ( ( ) ) }
Runs the test component using `suite` and collects logs and results.
Runs the test component using ` suite ` and collects logs and results .
suite
fidl_fuchsia_test::SuiteProxy
sender
mpsc::Sender<TestEvent>
test_url
String
suite
fidl_fuchsia_test::SuiteProxy
sender
mpsc::Sender<TestEvent>
test_url
String