Skip to content

Commit

Permalink
test: add incremental compilation fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Sep 24, 2023
1 parent 956c83f commit 676be45
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 29 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ members = [

"tests/common",
"tests/heap-profile",
"tests/incremental",
"tests/integration",
"tests/std",
]
Expand Down
23 changes: 10 additions & 13 deletions exporter/svg/src/frontend/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,17 @@ impl<Feat: ExportFeature> SvgTask<Feat> {
}
}

println!("reusable: {:?}", reusable);
println!("unused_prev: {:?}", unused_prev);

for (
idx,
Page {
content: entry,
size,
},
) in ctx.next.iter().enumerate()
// println!("reusable: {:?}", reusable);
// println!("unused_prev: {:?}", unused_prev);

for Page {
content: entry,
size,
} in ctx.next.iter()
{
let size = Self::page_size(*size);
if reusable.contains(entry) {
println!("reuse page: {} {:?}", idx, entry);
// println!("reuse page: {} {:?}", idx, entry);
svg_body.push(SvgText::Content(Arc::new(SvgTextNode {
attributes: vec![
("class", "typst-page".into()),
Expand All @@ -104,13 +101,13 @@ impl<Feat: ExportFeature> SvgTask<Feat> {

// todo: evaluate simlarity
let item = if let Some(prev_entry) = unused_prev.pop_first().map(|(_, v)| v) {
println!("diff page: {} {:?} {:?}", idx, entry, prev_entry);
// println!("diff page: {} {:?} {:?}", idx, entry, prev_entry);
attributes.push(("data-reuse-from", prev_entry.as_svg_id("p")));

render_task.render_diff_item(entry, &prev_entry)
} else {
// todo: find a box
println!("rebuild page: {} {:?}", idx, entry);
// println!("rebuild page: {} {:?}", idx, entry);
render_task.render_flat_item(entry)
};

Expand Down
34 changes: 18 additions & 16 deletions fuzzers/corpora/viewers/preview-incr_01.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#set page(
paper: "a4",
header: align(right)[
Multi-purpose Combat Chassis [FALKEN]
Multi-purpose Combat Chassis
],
numbering: "1",
margin: (x:20mm, y:12.7mm)
Expand Down Expand Up @@ -46,30 +46,32 @@

#let img = "/assets/files/tiger.jpg"

= #lorem(4)
= Seed

#outline(title:none, indent:auto, )

#booktab()

#lorem(5000)
Seed2 Seed4

Seed3 Seed4

#pagebreak()
== #lorem(3)

#emp_block()[
#lorem(100)
Seed4 Seed4 Seed4 Seed4
]
#booktab()

#lorem(5000)
Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4 Seed4

#pagebreak()
== 隼的轻武器

#booktab()

#lorem(5000)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#let images_rkg3=("tiger.jpg","tiger.jpg")

Expand All @@ -80,7 +82,7 @@
)
]

#lorem(300)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#let images_pistol=("tiger.jpg","tiger.jpg")
#let cell = rect.with(
Expand All @@ -96,37 +98,37 @@
..images_pistol.map(n=>align(center)[#image(img, width:20%)])
)

#lorem(450)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#figure(
image(img, width: 50%)
)

#lorem(450)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#figure(
image(img, width: 50%)
)

#lorem(300)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

=== 电磁枪

#lorem(450)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#pagebreak()
== 武器舱和背部重武器

#booktab()

#lorem(300)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#figure(
image(img, width: 60%),
caption: [30mm Rapid Railgun with Extended Barrel, also retrofitted as 2nd stage rail on Arclight]
)

#lorem(5000)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#figure(
image(img, width: 60%),
Expand All @@ -140,18 +142,18 @@
caption: [炮管展开60°的状态]
)

#lorem(300)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#figure(
image(img, width: 80%),
caption: [4Sure Ballistics Man-Portable ASAT Missile]
)

#lorem(500)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed

#pagebreak()
== 辅助机 —— "FRAMER"

#booktab()

#lorem(500)
Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed Seed
30 changes: 30 additions & 0 deletions tests/incremental/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "typst-ts-incremental-test"
authors.workspace = true
version.workspace = true
license.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

[dependencies]
typst.workspace = true
typst-syntax.workspace = true
comemo.workspace = true

sha2.workspace = true
anyhow.workspace = true
tokio.workspace = true

rand = "0.8.5"
rand_xoshiro = "0.6.0"

typst-ts-dev-server.workspace = true
typst-ts-test-common.workspace = true
typst-ts-core.workspace = true
hex.workspace = true
typst-ts-compiler.workspace = true
typst-ts-svg-exporter.workspace = true

[features]
generate = []
Loading

0 comments on commit 676be45

Please sign in to comment.