Flip test directory structure 🔃

Move full/lang/library to the top-level as that's more ergonomic to use.
This commit is contained in:
Laurenz 2021-01-16 15:28:03 +01:00
parent 51efb0f4d6
commit cc5f14193c
44 changed files with 26 additions and 23 deletions

8
.gitignore vendored
View File

@ -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

View File

@ -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 {

View File

@ -1,23 +1,23 @@
# Tests
Directory structure:
- `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:
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.
- `png`: PNG files produced by tests.
- `pdf`: PDF files produced by tests.
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
```

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 94 B

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 215 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 821 B

After

Width:  |  Height:  |  Size: 821 B

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -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);
}