mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-29 20:27:05 -06:00
Tests: five tests that wait on another thread pass on a loaded machine
On a machine busy with other builds, five tests on main failed now and then and passed when run alone. The canvas test for dragging an object with raster effects gave the render worker 10 s for its frame, which took 0.10 s alone and 5.8 to 9.4 s with four ui-egui test runs at once. The three tests_sysclip_probe tests gave the clipboard probe's thread 2 or 3 s. The control server's persistent-requests test sent each request with writeln!, which sends the JSON to the socket in many small writes, and a pause of more than the test's 120 ms line deadline between two of them closed the connection. The canvas test now waits up to 60 s for the worker, as another test in canvas.rs does. The probe tests wait up to 60 s too. The control server test sends each request line in one write and keeps its 120 ms line deadline. Only test code changes.
This commit is contained in:
@@ -383,7 +383,10 @@ mod tests {
|
||||
});
|
||||
let mut reader = BufReader::new(client.try_clone().unwrap());
|
||||
for id in [1, 2] {
|
||||
writeln!(client, "{}", json!({"id": id, "method": "inspect"})).unwrap();
|
||||
// The client sends each line in one write. `writeln!` on the socket sends the JSON in many
|
||||
// small writes, and when the machine is busy, a pause of more than the 120 ms line deadline
|
||||
// between two of them closes the connection.
|
||||
client.write_all(format!("{}\n", json!({"id": id, "method": "inspect"})).as_bytes()).unwrap();
|
||||
let mut line = String::new();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
assert_eq!(serde_json::from_str::<Value>(&line).unwrap(), json!({"id": id, "ok": true}));
|
||||
|
||||
Reference in New Issue
Block a user