1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Shared helpers for the integration tests that start a server.
//!
//! `wait_for_bind` lived as a copy-pasted function in six test files and in
//! none of the others, which is why three of them still raced a fixed sleep
//! against a server bind long after the fix existed (#805). A helper that can
//! only be adopted by copying does not get adopted by files written later.
//!
//! `tests/common/mod.rs` rather than `tests/common.rs`: the directory form is
//! not compiled as its own test binary, so this does not appear as an empty
//! test target.
use ;
use thread;
use ;
/// Poll-connect to `port` until the listener accepts a TCP connection or the
/// deadline expires.
///
/// Replaces a fixed sleep so a test passes whether bind takes 5 ms (plain
/// HTTP) or 500 ms (TLS with a cold cert load) without slowing the fast path.
/// A fixed 200 ms budget is least reliable exactly where it matters most — a
/// shared CI runner under `--test-threads=1` — and when it runs out the panic
/// lands on the `connect`, not on anything the test is about, so an unrelated
/// change looks guilty.
///
/// Panics with the port and the budget when the deadline passes, so a genuine
/// "the server never started" failure is still legible.