Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

The runner's test of a long wait counts its lines against how long the wait really took. CI #253 failed on main (36c73096) with fourteen "still waiting" lines where 2 to 4 were expected: the work sleeps 180 ms and a line is written every 50 ms, but on a busy machine the sleep took about 700 ms, and a line per 50 ms of that is what the log should say. The test now times the wait and asks for at least two lines and no more than one per 50 ms it took. Nothing in the runner changed. Checked: cargo test -p g1t-runner (249 passing).

G1t-Session:
ses_01m4y12gdde2r9q832m7xk87kd
syntaqxcommitted Parent36c7309Browse files
1 file+5−10/1 viewed
+5−1
565565 #[test]
566566 fn a_long_wait_says_so_in_the_log_as_it_goes() {
567567 let mut log = log(&[]);
568+ let started = Instant::now();
568569 let answer = log.waiting(Duration::from_millis(50), |_| {
569570 std::thread::sleep(Duration::from_millis(180));
570571 42
571572 }, |seconds| format!("still waiting ({seconds}s)"));
573+ // A busy machine sleeps longer than asked: one line per 50 ms the
574+ // wait really took, never more.
575+ let took = started.elapsed().as_millis() as usize;
572576 assert_eq!(answer, 42);
573577 let lines = log.buffered();
574578 let told = lines.lines().filter(|line| line.starts_with("still waiting (")).count();
575− assert!((2..=4).contains(&told), "a line each time the wait goes on: {lines:?}");
579+ assert!(told >= 2 && told <= took / 50, "a line each time the wait goes on ({took} ms): {lines:?}");
576580 // A wait that ends at once writes nothing.
577581 let mut quick = super::tests::log(&[]);
578582 assert_eq!(quick.waiting(Duration::from_secs(5), |api| api.job, |_| "never".into()), "job_1");

Comments

Sign in to comment.