diff options
| -rw-r--r-- | .gitignore | 8 | ||||
| -rw-r--r-- | bench/src/bench.rs | 2 | ||||
| -rw-r--r-- | tests/README.md | 18 | ||||
| -rw-r--r-- | tests/full/ref/coma.png (renamed from tests/ref/full/coma.png) | bin | 27418 -> 27418 bytes | |||
| -rw-r--r-- | tests/full/typ/coma.typ (renamed from tests/typ/full/coma.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/ref/arrays.png (renamed from tests/ref/lang/arrays.png) | bin | 3479 -> 3479 bytes | |||
| -rw-r--r-- | tests/lang/ref/basics.png (renamed from tests/ref/lang/basics.png) | bin | 5051 -> 5051 bytes | |||
| -rw-r--r-- | tests/lang/ref/blocks.png (renamed from tests/ref/lang/blocks.png) | bin | 1363 -> 1363 bytes | |||
| -rw-r--r-- | tests/lang/ref/bracket-call.png (renamed from tests/ref/lang/bracket-call.png) | bin | 22257 -> 22257 bytes | |||
| -rw-r--r-- | tests/lang/ref/comments.png (renamed from tests/ref/lang/comments.png) | bin | 1148 -> 1148 bytes | |||
| -rw-r--r-- | tests/lang/ref/dictionaries.png (renamed from tests/ref/lang/dictionaries.png) | bin | 1769 -> 1769 bytes | |||
| -rw-r--r-- | tests/lang/ref/empty.png (renamed from tests/ref/lang/empty.png) | bin | 94 -> 94 bytes | |||
| -rw-r--r-- | tests/lang/ref/escaping.png (renamed from tests/ref/lang/escaping.png) | bin | 4148 -> 4148 bytes | |||
| -rw-r--r-- | tests/lang/ref/expressions.png (renamed from tests/ref/lang/expressions.png) | bin | 2351 -> 2351 bytes | |||
| -rw-r--r-- | tests/lang/ref/headings.png (renamed from tests/ref/lang/headings.png) | bin | 7850 -> 7850 bytes | |||
| -rw-r--r-- | tests/lang/ref/let.png (renamed from tests/ref/lang/let.png) | bin | 1493 -> 1493 bytes | |||
| -rw-r--r-- | tests/lang/ref/raw.png (renamed from tests/ref/lang/raw.png) | bin | 4212 -> 4212 bytes | |||
| -rw-r--r-- | tests/lang/ref/values.png (renamed from tests/ref/lang/values.png) | bin | 8531 -> 8531 bytes | |||
| -rw-r--r-- | tests/lang/typ/arrays.typ (renamed from tests/typ/lang/arrays.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/basics.typ (renamed from tests/typ/lang/basics.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/blocks.typ (renamed from tests/typ/lang/blocks.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/bracket-call.typ (renamed from tests/typ/lang/bracket-call.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/comments.typ (renamed from tests/typ/lang/comments.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/dictionaries.typ (renamed from tests/typ/lang/dictionaries.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/empty.typ (renamed from tests/typ/lang/empty.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/escaping.typ (renamed from tests/typ/lang/escaping.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/expressions.typ (renamed from tests/typ/lang/expressions.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/headings.typ (renamed from tests/typ/lang/headings.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/let.typ (renamed from tests/typ/lang/let.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/raw.typ (renamed from tests/typ/lang/raw.typ) | 0 | ||||
| -rw-r--r-- | tests/lang/typ/values.typ (renamed from tests/typ/lang/values.typ) | 0 | ||||
| -rw-r--r-- | tests/library/ref/font.png (renamed from tests/ref/library/font.png) | bin | 5386 -> 5386 bytes | |||
| -rw-r--r-- | tests/library/ref/hv.png (renamed from tests/ref/library/hv.png) | bin | 3961 -> 3961 bytes | |||
| -rw-r--r-- | tests/library/ref/image.png (renamed from tests/ref/library/image.png) | bin | 220343 -> 220343 bytes | |||
| -rw-r--r-- | tests/library/ref/page.png (renamed from tests/ref/library/page.png) | bin | 8097 -> 8097 bytes | |||
| -rw-r--r-- | tests/library/ref/pagebreak.png (renamed from tests/ref/library/pagebreak.png) | bin | 821 -> 821 bytes | |||
| -rw-r--r-- | tests/library/ref/rgb.png (renamed from tests/ref/library/rgb.png) | bin | 2688 -> 2688 bytes | |||
| -rw-r--r-- | tests/library/typ/font.typ (renamed from tests/typ/library/font.typ) | 0 | ||||
| -rw-r--r-- | tests/library/typ/hv.typ (renamed from tests/typ/library/hv.typ) | 0 | ||||
| -rw-r--r-- | tests/library/typ/image.typ (renamed from tests/typ/library/image.typ) | 0 | ||||
| -rw-r--r-- | tests/library/typ/page.typ (renamed from tests/typ/library/page.typ) | 0 | ||||
| -rw-r--r-- | tests/library/typ/pagebreak.typ (renamed from tests/typ/library/pagebreak.typ) | 0 | ||||
| -rw-r--r-- | tests/library/typ/rgb.typ (renamed from tests/typ/library/rgb.typ) | 0 | ||||
| -rw-r--r-- | tests/typeset.rs | 17 |
44 files changed, 24 insertions, 21 deletions
@@ -6,10 +6,8 @@ bench/target **/*.rs.bk Cargo.lock -tests/png -tests/pdf -tests/playground.typ -tests/playground.png -tests/playground.pdf +tests/*/png +tests/*/pdf +tests/playground.* tarpaulin-report.html diff --git a/bench/src/bench.rs b/bench/src/bench.rs index e1ae838a..2d3230db 100644 --- a/bench/src/bench.rs +++ b/bench/src/bench.rs @@ -11,7 +11,7 @@ use typst::parse::parse; use typst::typeset; const FONT_DIR: &str = "../fonts"; -const COMA: &str = include_str!("../../tests/typ/full/coma.typ"); +const COMA: &str = include_str!("../../tests/full/typ/coma.typ"); fn benchmarks(c: &mut Criterion) { macro_rules! bench { diff --git a/tests/README.md b/tests/README.md index 91bf8f49..efca6dd6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,23 +1,23 @@ # Tests -Directory structure: +Top level directory structure: +- `full`: Tests of full documents. +- `lang`: Tests for specific language features. +- `library`: Tests for specific library functions. +- `res`: Resource files used by tests. + +Directory structure for each category: - `typ`: Input files. - `ref`: Reference images which the output is compared with to determine whether a test passed or failed. -- `res`: Resource files used by tests. - `png`: PNG files produced by tests. - `pdf`: PDF files produced by tests. -The test files are split into three categories: -- `full`: Tests of full documents. -- `lang`: Tests for specific language features. -- `library`: Tests for specific library functions. - To keep things small, please optimize the reference images: ```bash # One image -oxipng -o max tests/ref/image.png +oxipng -o max path/to/image.png # All images -oxipng -r -o max tests/ref/* +oxipng -r -o max tests/*/ref ``` diff --git a/tests/ref/full/coma.png b/tests/full/ref/coma.png Binary files differindex 0c18b810..0c18b810 100644 --- a/tests/ref/full/coma.png +++ b/tests/full/ref/coma.png diff --git a/tests/typ/full/coma.typ b/tests/full/typ/coma.typ index b7863fce..b7863fce 100644 --- a/tests/typ/full/coma.typ +++ b/tests/full/typ/coma.typ diff --git a/tests/ref/lang/arrays.png b/tests/lang/ref/arrays.png Binary files differindex 2d70a3f6..2d70a3f6 100644 --- a/tests/ref/lang/arrays.png +++ b/tests/lang/ref/arrays.png diff --git a/tests/ref/lang/basics.png b/tests/lang/ref/basics.png Binary files differindex 3c3dd7a0..3c3dd7a0 100644 --- a/tests/ref/lang/basics.png +++ b/tests/lang/ref/basics.png diff --git a/tests/ref/lang/blocks.png b/tests/lang/ref/blocks.png Binary files differindex ca826c1b..ca826c1b 100644 --- a/tests/ref/lang/blocks.png +++ b/tests/lang/ref/blocks.png diff --git a/tests/ref/lang/bracket-call.png b/tests/lang/ref/bracket-call.png Binary files differindex 16afb187..16afb187 100644 --- a/tests/ref/lang/bracket-call.png +++ b/tests/lang/ref/bracket-call.png diff --git a/tests/ref/lang/comments.png b/tests/lang/ref/comments.png Binary files differindex df5e5b9c..df5e5b9c 100644 --- a/tests/ref/lang/comments.png +++ b/tests/lang/ref/comments.png diff --git a/tests/ref/lang/dictionaries.png b/tests/lang/ref/dictionaries.png Binary files differindex aa40549e..aa40549e 100644 --- a/tests/ref/lang/dictionaries.png +++ b/tests/lang/ref/dictionaries.png diff --git a/tests/ref/lang/empty.png b/tests/lang/ref/empty.png Binary files differindex 87c06b0a..87c06b0a 100644 --- a/tests/ref/lang/empty.png +++ b/tests/lang/ref/empty.png diff --git a/tests/ref/lang/escaping.png b/tests/lang/ref/escaping.png Binary files differindex 575a4b2f..575a4b2f 100644 --- a/tests/ref/lang/escaping.png +++ b/tests/lang/ref/escaping.png diff --git a/tests/ref/lang/expressions.png b/tests/lang/ref/expressions.png Binary files differindex 309c32f1..309c32f1 100644 --- a/tests/ref/lang/expressions.png +++ b/tests/lang/ref/expressions.png diff --git a/tests/ref/lang/headings.png b/tests/lang/ref/headings.png Binary files differindex 1f374cce..1f374cce 100644 --- a/tests/ref/lang/headings.png +++ b/tests/lang/ref/headings.png diff --git a/tests/ref/lang/let.png b/tests/lang/ref/let.png Binary files differindex be9d8397..be9d8397 100644 --- a/tests/ref/lang/let.png +++ b/tests/lang/ref/let.png diff --git a/tests/ref/lang/raw.png b/tests/lang/ref/raw.png Binary files differindex f88194c0..f88194c0 100644 --- a/tests/ref/lang/raw.png +++ b/tests/lang/ref/raw.png diff --git a/tests/ref/lang/values.png b/tests/lang/ref/values.png Binary files differindex 762ad64e..762ad64e 100644 --- a/tests/ref/lang/values.png +++ b/tests/lang/ref/values.png diff --git a/tests/typ/lang/arrays.typ b/tests/lang/typ/arrays.typ index 0b8fb866..0b8fb866 100644 --- a/tests/typ/lang/arrays.typ +++ b/tests/lang/typ/arrays.typ diff --git a/tests/typ/lang/basics.typ b/tests/lang/typ/basics.typ index 9220e376..9220e376 100644 --- a/tests/typ/lang/basics.typ +++ b/tests/lang/typ/basics.typ diff --git a/tests/typ/lang/blocks.typ b/tests/lang/typ/blocks.typ index cadd30dd..cadd30dd 100644 --- a/tests/typ/lang/blocks.typ +++ b/tests/lang/typ/blocks.typ diff --git a/tests/typ/lang/bracket-call.typ b/tests/lang/typ/bracket-call.typ index 79667e61..79667e61 100644 --- a/tests/typ/lang/bracket-call.typ +++ b/tests/lang/typ/bracket-call.typ diff --git a/tests/typ/lang/comments.typ b/tests/lang/typ/comments.typ index c5b04967..c5b04967 100644 --- a/tests/typ/lang/comments.typ +++ b/tests/lang/typ/comments.typ diff --git a/tests/typ/lang/dictionaries.typ b/tests/lang/typ/dictionaries.typ index c729b92c..c729b92c 100644 --- a/tests/typ/lang/dictionaries.typ +++ b/tests/lang/typ/dictionaries.typ diff --git a/tests/typ/lang/empty.typ b/tests/lang/typ/empty.typ index e69de29b..e69de29b 100644 --- a/tests/typ/lang/empty.typ +++ b/tests/lang/typ/empty.typ diff --git a/tests/typ/lang/escaping.typ b/tests/lang/typ/escaping.typ index cb663612..cb663612 100644 --- a/tests/typ/lang/escaping.typ +++ b/tests/lang/typ/escaping.typ diff --git a/tests/typ/lang/expressions.typ b/tests/lang/typ/expressions.typ index 01725289..01725289 100644 --- a/tests/typ/lang/expressions.typ +++ b/tests/lang/typ/expressions.typ diff --git a/tests/typ/lang/headings.typ b/tests/lang/typ/headings.typ index f62f6534..f62f6534 100644 --- a/tests/typ/lang/headings.typ +++ b/tests/lang/typ/headings.typ diff --git a/tests/typ/lang/let.typ b/tests/lang/typ/let.typ index c7bba747..c7bba747 100644 --- a/tests/typ/lang/let.typ +++ b/tests/lang/typ/let.typ diff --git a/tests/typ/lang/raw.typ b/tests/lang/typ/raw.typ index 22eda139..22eda139 100644 --- a/tests/typ/lang/raw.typ +++ b/tests/lang/typ/raw.typ diff --git a/tests/typ/lang/values.typ b/tests/lang/typ/values.typ index ce41fc43..ce41fc43 100644 --- a/tests/typ/lang/values.typ +++ b/tests/lang/typ/values.typ diff --git a/tests/ref/library/font.png b/tests/library/ref/font.png Binary files differindex 1e025c6f..1e025c6f 100644 --- a/tests/ref/library/font.png +++ b/tests/library/ref/font.png diff --git a/tests/ref/library/hv.png b/tests/library/ref/hv.png Binary files differindex ee649fb6..ee649fb6 100644 --- a/tests/ref/library/hv.png +++ b/tests/library/ref/hv.png diff --git a/tests/ref/library/image.png b/tests/library/ref/image.png Binary files differindex 70f263e6..70f263e6 100644 --- a/tests/ref/library/image.png +++ b/tests/library/ref/image.png diff --git a/tests/ref/library/page.png b/tests/library/ref/page.png Binary files differindex 97557437..97557437 100644 --- a/tests/ref/library/page.png +++ b/tests/library/ref/page.png diff --git a/tests/ref/library/pagebreak.png b/tests/library/ref/pagebreak.png Binary files differindex 16eae0e4..16eae0e4 100644 --- a/tests/ref/library/pagebreak.png +++ b/tests/library/ref/pagebreak.png diff --git a/tests/ref/library/rgb.png b/tests/library/ref/rgb.png Binary files differindex 3060e42c..3060e42c 100644 --- a/tests/ref/library/rgb.png +++ b/tests/library/ref/rgb.png diff --git a/tests/typ/library/font.typ b/tests/library/typ/font.typ index beaddd4e..beaddd4e 100644 --- a/tests/typ/library/font.typ +++ b/tests/library/typ/font.typ diff --git a/tests/typ/library/hv.typ b/tests/library/typ/hv.typ index 36a6d242..36a6d242 100644 --- a/tests/typ/library/hv.typ +++ b/tests/library/typ/hv.typ diff --git a/tests/typ/library/image.typ b/tests/library/typ/image.typ index 2e7b1eb5..2e7b1eb5 100644 --- a/tests/typ/library/image.typ +++ b/tests/library/typ/image.typ diff --git a/tests/typ/library/page.typ b/tests/library/typ/page.typ index 9eeddc93..9eeddc93 100644 --- a/tests/typ/library/page.typ +++ b/tests/library/typ/page.typ diff --git a/tests/typ/library/pagebreak.typ b/tests/library/typ/pagebreak.typ index 2f539ce0..2f539ce0 100644 --- a/tests/typ/library/pagebreak.typ +++ b/tests/library/typ/pagebreak.typ diff --git a/tests/typ/library/rgb.typ b/tests/library/typ/rgb.typ index 66d63d0d..66d63d0d 100644 --- a/tests/typ/library/rgb.typ +++ b/tests/library/typ/rgb.typ diff --git a/tests/typeset.rs b/tests/typeset.rs index 5777950f..10e6231e 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -38,14 +38,18 @@ fn main() { let filter = TestFilter::new(env::args().skip(1)); let mut filtered = Vec::new(); - for entry in WalkDir::new(TYP_DIR).into_iter() { + for entry in WalkDir::new(".").into_iter() { let entry = entry.unwrap(); + if entry.depth() <= 1 { + continue; + } + let src_path = entry.into_path(); if src_path.extension() != Some(OsStr::new("typ")) { continue; } - if filter.matches(&src_path.to_string_lossy().to_string()) { + if filter.matches(&src_path.to_string_lossy()) { filtered.push(src_path); } } @@ -78,10 +82,11 @@ fn main() { let mut ok = true; for src_path in filtered { - let relative = src_path.strip_prefix(TYP_DIR).unwrap(); - let png_path = Path::new(PNG_DIR).join(&relative).with_extension("png"); - let pdf_path = Path::new(PDF_DIR).join(&relative).with_extension("pdf"); - let ref_path = Path::new(REF_DIR).join(&relative).with_extension("png"); + let category = src_path.parent().unwrap().parent().unwrap(); + let name = src_path.file_stem().unwrap(); + let png_path = category.join(PNG_DIR).join(name).with_extension("png"); + let pdf_path = category.join(PDF_DIR).join(name).with_extension("pdf"); + let ref_path = category.join(REF_DIR).join(name).with_extension("png"); ok &= test(&src_path, &png_path, &pdf_path, Some(&ref_path), &mut env); } |
