DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Print color: the print test retries across a second boundary, as its sibling does
aiongg2e0aedbaf649
diff --git a/crates/engine/src/cmd/print.rs b/crates/engine/src/cmd/print.rsindex 826bfd6b8..7e5fd3515 100644--- a/crates/engine/src/cmd/print.rs+++ b/crates/engine/src/cmd/print.rs@@ -96,20 +96,30 @@ mod tests {let mut s = Session::new();s.execute("file.new", &json!({"pages": 4})).unwrap();let params = json!({"printer": "Office (east)", "copies": 2, "pages": "2-3", "marks": true, "bleed": true});- let expected = super::super::export::pdf_export(&s, ¶ms).unwrap().bytes;- let r = print_with(&mut s, ¶ms, |pdf, job| {- // The production export options and full bytes reach the shared spooler boundary.- assert_eq!(pdf, expected);- assert!(pdf.starts_with(b"%PDF-"));- assert_eq!(job.printer.as_deref(), Some("Office (east)"));- assert_eq!(job.copies, 2);- assert_eq!(job.duplex, None);- assert_eq!(job.scaling, craft_print::Scaling::ShrinkToFit);- assert!(!job.title.is_empty());- Ok("request id is Office-1".into())- })- .unwrap();- assert_eq!(r["pages"], 2);+ // The production export options and full bytes reach the shared spooler boundary. The+ // creation date is in whole seconds: an attempt can straddle a second boundary.+ let mut matched = false;+ for _ in 0..3 {+ let expected = super::super::export::pdf_export(&s, ¶ms).unwrap().bytes;+ let mut printed = Vec::new();+ let r = print_with(&mut s, ¶ms, |pdf, job| {+ printed = pdf.to_vec();+ assert!(pdf.starts_with(b"%PDF-"));+ assert_eq!(job.printer.as_deref(), Some("Office (east)"));+ assert_eq!(job.copies, 2);+ assert_eq!(job.duplex, None);+ assert_eq!(job.scaling, craft_print::Scaling::ShrinkToFit);+ assert!(!job.title.is_empty());+ Ok("request id is Office-1".into())+ })+ .unwrap();+ assert_eq!(r["pages"], 2);+ if printed == expected {+ matched = true;+ break;+ }+ }+ assert!(matched, "File › Print spools the selected export's bytes");let refusal = print_with(&mut s, ¶ms, |_, _| Err(craft_print::Error::Spool("printer offline".into()))).unwrap_err();assert!(refusal.to_string().contains("printer offline"));print_with(&mut s, &json!({"dryRun": true}), |_, _| panic!("dry runs must not spool")).unwrap();