From: Alex Crichton Date: Sat, 23 Dec 2017 15:43:08 +0000 (-0800) Subject: Make the `failed_submodule_checkout` test more robust X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~4^2~6^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=dfda6f3b3967affad34b2acc0f144360ea4fa2ea;p=cargo.git Make the `failed_submodule_checkout` test more robust Hopefully should help diagnose deadlocks in rust-lang/rust --- diff --git a/tests/git.rs b/tests/git.rs index 38c72a78c..33ffe8c16 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -5,8 +5,10 @@ extern crate hamcrest; use std::fs::{self, File}; use std::io::prelude::*; -use std::net::TcpListener; +use std::net::{TcpListener, TcpStream}; use std::path::Path; +use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use std::thread; use cargo::util::process; @@ -2198,12 +2200,13 @@ fn failed_submodule_checkout() { let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = listener.local_addr().unwrap(); + let done = Arc::new(AtomicBool::new(false)); + let done2 = done.clone(); let t = thread::spawn(move || { - let a = listener.accept().unwrap(); - drop(a); - let a = listener.accept().unwrap(); - drop(a); + while !done2.load(Ordering::SeqCst) { + drop(listener.accept()); + } }); let repo = git2::Repository::open(&git_project2.root()).unwrap(); @@ -2248,5 +2251,7 @@ fn failed_submodule_checkout() { .with_stderr_contains(" failed to update submodule `src`") .with_stderr_contains(" failed to update submodule `bar`")); + done.store(true, Ordering::SeqCst); + drop(TcpStream::connect(&addr)); t.join().unwrap(); }