diff --git a/crates/docx/tests/application_name.rs b/crates/docx/tests/application_name.rs deleted file mode 100644 index 1973e63ae..000000000 --- a/crates/docx/tests/application_name.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! An app that embeds the writer names itself in `docProps/app.xml` (its own test binary: the -//! name is set once per process). - -use std::io::Read; - -#[test] -fn the_embedding_app_names_itself_in_app_xml() { - assert_eq!(craft_docx::application_name(), "WordCraft", "the default"); - craft_docx::set_application_name("Example Writer"); - craft_docx::set_application_name("Other"); - assert_eq!(craft_docx::application_name(), "Example Writer", "only the first call counts"); - let mut d = craft_wordmodel::Document::new(); - d.body = vec![craft_wordmodel::para_block(craft_wordmodel::Paragraph::with_text("Text", Default::default()))]; - let bytes = craft_docx::write(&d).unwrap(); - let mut z = zip::ZipArchive::new(std::io::Cursor::new(&bytes)).unwrap(); - let mut app = String::new(); - z.by_name("docProps/app.xml").unwrap().read_to_string(&mut app).unwrap(); - assert!(app.contains("Example Writer"), "{app}"); -} diff --git a/crates/docx/tests/it/application_name.rs b/crates/docx/tests/it/application_name.rs new file mode 100644 index 000000000..ea14f31e7 --- /dev/null +++ b/crates/docx/tests/it/application_name.rs @@ -0,0 +1,31 @@ +//! The embedding app sets its name once per process. Exercise the setter in a fresh copy of the test binary. + +use std::io::Read; + +#[test] +fn the_embedding_app_names_itself_in_app_xml() { + const CHILD: &str = "CRAFT_DOCX_APP_NAME_CHILD"; + if std::env::var_os(CHILD).is_none() { + let output = std::process::Command::new(std::env::current_exe().expect("DOCX test executable")) + .args(["--exact", "application_name::the_embedding_app_names_itself_in_app_xml", "--nocapture"]) + .env(CHILD, "1") + .output() + .expect("run the application name test in a fresh process"); + let stdout = String::from_utf8_lossy(&output.stdout); + let stderr = String::from_utf8_lossy(&output.stderr); + assert!(output.status.success() && stdout.contains("application name verified"), "{stdout}\n{stderr}"); + return; + } + assert_eq!(craft_docx::application_name(), "WordCraft", "the default"); + craft_docx::set_application_name("Example Writer"); + craft_docx::set_application_name("Other"); + assert_eq!(craft_docx::application_name(), "Example Writer", "only the first call counts"); + let mut d = craft_wordmodel::Document::new(); + d.body = vec![craft_wordmodel::para_block(craft_wordmodel::Paragraph::with_text("Text", Default::default()))]; + let bytes = craft_docx::write(&d).unwrap(); + let mut z = zip::ZipArchive::new(std::io::Cursor::new(&bytes)).unwrap(); + let mut app = String::new(); + z.by_name("docProps/app.xml").unwrap().read_to_string(&mut app).unwrap(); + assert!(app.contains("Example Writer"), "{app}"); + println!("application name verified"); +} diff --git a/crates/docx/tests/it/main.rs b/crates/docx/tests/it/main.rs index 2c44700ec..1a18aeaed 100644 --- a/crates/docx/tests/it/main.rs +++ b/crates/docx/tests/it/main.rs @@ -58,3 +58,7 @@ mod vml_shapes; mod word_xml; mod wordml2003_write; mod wps_fallback; + +mod application_name; +mod matrix_save_size; +mod protection; diff --git a/crates/docx/tests/matrix_save_size.rs b/crates/docx/tests/it/matrix_save_size.rs similarity index 100% rename from crates/docx/tests/matrix_save_size.rs rename to crates/docx/tests/it/matrix_save_size.rs diff --git a/crates/docx/tests/protection.rs b/crates/docx/tests/it/protection.rs similarity index 100% rename from crates/docx/tests/protection.rs rename to crates/docx/tests/it/protection.rs diff --git a/crates/pptx/tests/comments.rs b/crates/pptx/tests/it/comments.rs similarity index 99% rename from crates/pptx/tests/comments.rs rename to crates/pptx/tests/it/comments.rs index 224ffec6e..66a44c510 100644 --- a/crates/pptx/tests/comments.rs +++ b/crates/pptx/tests/it/comments.rs @@ -1,7 +1,7 @@ //! Comment threads through PPTX: the modern part keeps replies and resolved state, the legacy //! part stays readable, and a package with both imports every thread once. -mod common; +use super::common; use std::sync::Arc; diff --git a/crates/pptx/tests/it/main.rs b/crates/pptx/tests/it/main.rs new file mode 100644 index 000000000..d128b81dc --- /dev/null +++ b/crates/pptx/tests/it/main.rs @@ -0,0 +1,10 @@ +//! The crate's integration tests, linked into one test binary. + +#[path = "../common/mod.rs"] +mod common; + +mod comments; +mod notes; +mod read; +mod timing; +mod write; diff --git a/crates/pptx/tests/notes.rs b/crates/pptx/tests/it/notes.rs similarity index 99% rename from crates/pptx/tests/notes.rs rename to crates/pptx/tests/it/notes.rs index 6d9500889..67600fba8 100644 --- a/crates/pptx/tests/notes.rs +++ b/crates/pptx/tests/it/notes.rs @@ -1,7 +1,7 @@ //! Speaker notes keep their run and paragraph formatting: a bold heading, indented points with //! custom bullets, plain lines. -mod common; +use super::common; use std::sync::Arc; diff --git a/crates/pptx/tests/read.rs b/crates/pptx/tests/it/read.rs similarity index 100% rename from crates/pptx/tests/read.rs rename to crates/pptx/tests/it/read.rs diff --git a/crates/pptx/tests/timing.rs b/crates/pptx/tests/it/timing.rs similarity index 100% rename from crates/pptx/tests/timing.rs rename to crates/pptx/tests/it/timing.rs diff --git a/crates/pptx/tests/write.rs b/crates/pptx/tests/it/write.rs similarity index 99% rename from crates/pptx/tests/write.rs rename to crates/pptx/tests/it/write.rs index 46f7513e7..46db7041d 100644 --- a/crates/pptx/tests/write.rs +++ b/crates/pptx/tests/it/write.rs @@ -1,6 +1,6 @@ //! The writer, read back with the reader. -mod common; +use super::common; use std::sync::Arc; diff --git a/crates/xls/tests/it/main.rs b/crates/xls/tests/it/main.rs new file mode 100644 index 000000000..02814fe24 --- /dev/null +++ b/crates/xls/tests/it/main.rs @@ -0,0 +1,9 @@ +//! The crate's integration tests, linked into one test binary. + +#[path = "../common/mod.rs"] +mod common; + +mod objects; +mod read; +mod styles; +mod validation; diff --git a/crates/xls/tests/objects.rs b/crates/xls/tests/it/objects.rs similarity index 99% rename from crates/xls/tests/objects.rs rename to crates/xls/tests/it/objects.rs index 2c409b0f3..56f66cdae 100644 --- a/crates/xls/tests/objects.rs +++ b/crates/xls/tests/it/objects.rs @@ -2,7 +2,7 @@ //! from [MS-XLS] and [MS-ODRAW]; no Excel-produced file is used. Ported from //! storytold/gridcraft#3457, with tests for the fixes its review asked for. -mod common; +use super::common; use common::*; use craft_xls::{ClientAnchor, Color, ConditionRule, DxfFill, Operator, Pattern, Range, Workbook}; diff --git a/crates/xls/tests/read.rs b/crates/xls/tests/it/read.rs similarity index 99% rename from crates/xls/tests/read.rs rename to crates/xls/tests/it/read.rs index f4360b5e0..0c5e91eb8 100644 --- a/crates/xls/tests/read.rs +++ b/crates/xls/tests/it/read.rs @@ -1,6 +1,6 @@ //! Reading BIFF8 workbooks: values, formulas, layout, names, limits and hostile input. -mod common; +use super::common; use common::{ at, bof, cat, cell, compound, eof, exp, fmt, formula, ftext, num, ptg_int, ptg_ref, put32, read_limited, read_xls, rec, special, text, u16s, v, diff --git a/crates/xls/tests/styles.rs b/crates/xls/tests/it/styles.rs similarity index 99% rename from crates/xls/tests/styles.rs rename to crates/xls/tests/it/styles.rs index b948fd9c1..6ed43f49f 100644 --- a/crates/xls/tests/styles.rs +++ b/crates/xls/tests/it/styles.rs @@ -1,7 +1,7 @@ //! Cell formatting: Font, XF, Palette and Style records. Every workbook is assembled here from //! the [MS-XLS] structures; no Excel-produced file is used. -mod common; +use super::common; use common::{at, bof, compound, eof, read_xls, rec, u16s, v}; use craft_xls::{BorderLine, BorderStyle, CellFormat, Color, DEFAULT_PALETTE, Fill, HAlign, Pattern, Script, Underline, VAlign, Value, Workbook}; diff --git a/crates/xls/tests/validation.rs b/crates/xls/tests/it/validation.rs similarity index 99% rename from crates/xls/tests/validation.rs rename to crates/xls/tests/it/validation.rs index 5ff4a43e3..ed99c79cf 100644 --- a/crates/xls/tests/validation.rs +++ b/crates/xls/tests/it/validation.rs @@ -2,7 +2,7 @@ //! spec's structures; no Excel-produced file is used. The expected rules are what a //! SpreadsheetML reader gives for the same rule. Ported from storytold/gridcraft#3636. -mod common; +use super::common; use common::*; use craft_xls::{CellRef, DataValidation, ErrorStyle, Operator, Range, ValidationType, Workbook}; diff --git a/crates/xlsx/tests/it/main.rs b/crates/xlsx/tests/it/main.rs new file mode 100644 index 000000000..ca54b2347 --- /dev/null +++ b/crates/xlsx/tests/it/main.rs @@ -0,0 +1,10 @@ +//! The crate's integration tests, linked into one test binary. + +#[path = "../common/mod.rs"] +mod common; + +mod pivot; +mod richdata; +mod write; +mod xlsb; +mod xlsx; diff --git a/crates/xlsx/tests/pivot.rs b/crates/xlsx/tests/it/pivot.rs similarity index 100% rename from crates/xlsx/tests/pivot.rs rename to crates/xlsx/tests/it/pivot.rs diff --git a/crates/xlsx/tests/richdata.rs b/crates/xlsx/tests/it/richdata.rs similarity index 100% rename from crates/xlsx/tests/richdata.rs rename to crates/xlsx/tests/it/richdata.rs diff --git a/crates/xlsx/tests/write.rs b/crates/xlsx/tests/it/write.rs similarity index 100% rename from crates/xlsx/tests/write.rs rename to crates/xlsx/tests/it/write.rs diff --git a/crates/xlsx/tests/xlsb.rs b/crates/xlsx/tests/it/xlsb.rs similarity index 99% rename from crates/xlsx/tests/xlsb.rs rename to crates/xlsx/tests/it/xlsb.rs index ef1464dd4..8e0a25060 100644 --- a/crates/xlsx/tests/xlsb.rs +++ b/crates/xlsx/tests/it/xlsb.rs @@ -1,7 +1,7 @@ //! Binary workbooks: BIFF12 records and packages assembled here from [MS-XLSB]. //! Adapted from GridCraft's `crates/xlsx/src/tests/xlsb_tests.rs`. -mod common; +use super::common; use common::{read, read_with}; use craft_xlsx::testing::zip; diff --git a/crates/xlsx/tests/xlsx.rs b/crates/xlsx/tests/it/xlsx.rs similarity index 99% rename from crates/xlsx/tests/xlsx.rs rename to crates/xlsx/tests/it/xlsx.rs index b5ebdf2c7..6cf5ea2c8 100644 --- a/crates/xlsx/tests/xlsx.rs +++ b/crates/xlsx/tests/it/xlsx.rs @@ -1,6 +1,6 @@ //! SpreadsheetML workbooks through the part layer. -mod common; +use super::common; use common::{read, read_with}; use craft_xlsx::testing::{workbook, zip};