fn run_check(core: tokio_core::reactor::Handle, c: WebClient, exit_value: Arc<Mutex<i32>>) {
            let core_handle = core.clone();
            let f = c.execute("var res = [window.runtimeExited, window.EXITSTATUS, window.TEST_LOGS]; window.TEST_LOGS=[]; return res;", Vec::new())
                .then(move |res| {
                    let mut json_vals = match res {
                        Ok(Json::Array(a)) => a.into_iter(),
                        _ => panic!("failed to get web server status"),
                    };
                    let runtime_exited = json_vals.next().expect("no runtime exit status found");
                    let exit_status = json_vals.next().expect("no exit status found");
                    let logs = json_vals
                        .next().expect("no test log stream found")
                        .into_array().expect("test log stream is not array");
                    for log in logs {
                        if let Json::String(line) = log {
                            eprintln!("{}", line);
                        }
                    }
                    if let Json::Boolean(true) = runtime_exited {
                        drop(c);
                        let stat = exit_status.as_i64().expect("failed to get exit status") as i32;
                        print_prefix();
                        eprintln!("tests finished with status: {}", stat);
                        let mut exit_value = exit_value.lock().expect("failed to get exit value");
                        *exit_value = stat;
                    } else {
                        run_check(core_handle, c, exit_value);
                    }
                    Ok(())
                });
            core.spawn(f);
        }
// we want to have a reference to c so we can use it in the and_thens below
we want to have a reference to c so we can use it in the and_thens below
we want to have a reference to c so we can use it in the and_thens below
fn run_check(core: tokio_core::reactor::Handle, c: WebClient, exit_value: Arc<Mutex<i32>>) {
            let core_handle = core.clone();
            let f = c.execute("var res = [window.runtimeExited, window.EXITSTATUS, window.TEST_LOGS]; window.TEST_LOGS=[]; return res;", Vec::new())
                .then(move |res| {
                    let mut json_vals = match res {
                        Ok(Json::Array(a)) => a.into_iter(),
                        _ => panic!("failed to get web server status"),
                    };
                    let runtime_exited = json_vals.next().expect("no runtime exit status found");
                    let exit_status = json_vals.next().expect("no exit status found");
                    let logs = json_vals
                        .next().expect("no test log stream found")
                        .into_array().expect("test log stream is not array");
                    for log in logs {
                        if let Json::String(line) = log {
                            eprintln!("{}", line);
                        }
                    }
                    if let Json::Boolean(true) = runtime_exited {
                        drop(c);
                        let stat = exit_status.as_i64().expect("failed to get exit status") as i32;
                        print_prefix();
                        eprintln!("tests finished with status: {}", stat);
                        let mut exit_value = exit_value.lock().expect("failed to get exit value");
                        *exit_value = stat;
                    } else {
                        run_check(core_handle, c, exit_value);
                    }
                    Ok(())
                });
            core.spawn(f);
        }
fn run_check ( core : tokio_core :: reactor :: Handle , c : WebClient , exit_value : Arc < Mutex < i32 > > ) { let core_handle = core . clone ( ) ; let f = c . execute ( " " , Vec :: new ( ) ) . then ( move | res | { let mut json_vals = match res { Ok ( Json :: Array ( a ) ) => a . into_iter ( ) , _ => panic ! ( " " ) , } ; let runtime_exited = json_vals . next ( ) . expect ( " " ) ; let exit_status = json_vals . next ( ) . expect ( " " ) ; let logs = json_vals . next ( ) . expect ( " " ) . into_array ( ) . expect ( " " ) ; for log in logs { if let Json :: String ( line ) = log { eprintln ! ( " " line ) ; } } if let Json :: Boolean ( true ) = runtime_exited { drop ( c ) ; let stat = exit_status . as_i64 ( ) . expect ( " " ) as i32 ; print_prefix ( ) ; eprintln ! ( " " stat ) ; let mut exit_value = exit_value . lock ( ) . expect ( " " ) ; * exit_value = stat ; } else { run_check ( core_handle , c , exit_value ) ; } Ok ( ( ) ) } ) ; core . spawn ( f ) ; }
we want to have a reference to c so we can use it in the and_thens below
we want to have a reference to c so we can use it in the and_thens below
core
tokio_core::reactor::Handle
c
WebClient
exit_value
Arc<Mutex<i32>>
core
tokio_core::reactor::Handle
c
WebClient
exit_value
Arc<Mutex<i32>>