Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Feb 3, 2025
1 parent cd9e2ca commit 57a75a5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 64 deletions.
26 changes: 7 additions & 19 deletions fuzzers/incremental/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
use std::path::Path;
use std::sync::Arc;

use reflexo_typst::config::{entry::EntryOpts, CompileOpts};
use reflexo_typst::exporter_builtins::GroupExporter;
use reflexo_typst::vector::{
ir::{Abs, Point, Rect},
stream::BytesModuleStream,
};
use reflexo_typst::TypstDocument;
use reflexo_typst::{
CompileDriver, CompileExporter, PureCompiler, ShadowApiExt, TypstSystemUniverse,
TypstSystemWorld,
};
use reflexo_typst::{CompileDriver, ShadowApiExt, TypstSystemUniverse};
use reflexo_typst2vec::incr::{IncrDocClient, IncrDocServer};
use reflexo_vec2svg::IncrSvgDocClient;
use typst::foundations::Bytes;
use typst_ts_incremental_fuzzer::mutate;

fn get_driver(
workspace_dir: &Path,
entry_file_path: &Path,
exporter: GroupExporter<TypstDocument>,
) -> CompileDriver<CompileExporter<PureCompiler<TypstSystemWorld>>> {
fn get_driver(workspace_dir: &Path, entry_file_path: &Path) -> CompileDriver {
let project_base = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let font_path = project_base.join("assets/fonts");
let world = TypstSystemUniverse::new(CompileOpts {
Expand All @@ -32,15 +25,11 @@ fn get_driver(
.unwrap();

let world = world.with_entry_file(entry_file_path.to_owned());
CompileDriver::new(CompileExporter::default().with_exporter(exporter), world)
CompileDriver::new(Arc::new(|_| Ok(())), world)
}

pub fn test_compiler(
workspace_dir: &Path,
entry_file_path: &Path,
exporter: GroupExporter<TypstDocument>,
) {
let mut driver = get_driver(workspace_dir, entry_file_path, exporter);
pub fn test_compiler(workspace_dir: &Path, entry_file_path: &Path) {
let mut driver = get_driver(workspace_dir, entry_file_path);
let mut content = { std::fs::read_to_string(entry_file_path).expect("Could not read file") };

#[cfg(feature = "generate")]
Expand Down Expand Up @@ -110,6 +99,5 @@ pub fn main() {
#[cfg(not(feature = "generate"))]
let entry_file_path = workspace_dir.join("test.typ");

let noop_exporter = GroupExporter::new(vec![]);
test_compiler(&workspace_dir, &entry_file_path, noop_exporter);
test_compiler(&workspace_dir, &entry_file_path);
}
25 changes: 7 additions & 18 deletions tests/heap-profile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
use std::path::Path;
use std::sync::Arc;

use reflexo_typst::config::{entry::EntryOpts, CompileOpts};
use reflexo_typst::exporter_builtins::GroupExporter;
use reflexo_typst::{
Bytes, CompileDriver, CompileExporter, PureCompiler, ShadowApiExt, TypstDocument,
TypstSystemUniverse, TypstSystemWorld,
};

fn get_driver(
workspace_dir: &Path,
entry_file_path: &Path,
exporter: GroupExporter<TypstDocument>,
) -> CompileDriver<CompileExporter<PureCompiler<TypstSystemWorld>>> {
use reflexo_typst::{Bytes, CompileDriver, ShadowApiExt, TypstSystemUniverse};

fn get_driver(workspace_dir: &Path, entry_file_path: &Path) -> CompileDriver {
let world = TypstSystemUniverse::new(CompileOpts {
entry: EntryOpts::new_workspace(workspace_dir.into()),
no_system_fonts: true,
Expand All @@ -20,15 +13,11 @@ fn get_driver(
.unwrap();

let world = world.with_entry_file(entry_file_path.to_owned());
CompileDriver::new(CompileExporter::default().with_exporter(exporter), world)
CompileDriver::new(Arc::new(|_| Ok(())), world)
}

pub fn test_compiler(
workspace_dir: &Path,
entry_file_path: &Path,
exporter: GroupExporter<TypstDocument>,
) {
let mut driver = get_driver(workspace_dir, entry_file_path, exporter);
pub fn test_compiler(workspace_dir: &Path, entry_file_path: &Path) {
let mut driver = get_driver(workspace_dir, entry_file_path);
let mut content = { std::fs::read_to_string(entry_file_path).expect("Could not read file") };

for i in 0..200 {
Expand Down
9 changes: 1 addition & 8 deletions tests/heap-profile/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use reflexo_typst::exporter_builtins::GroupExporter;

#[cfg(feature = "dhat-heap")]
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;
Expand All @@ -15,12 +13,7 @@ pub fn main() {

match action {
"compile" => {
let noop_exporter = GroupExporter::new(vec![]);
typst_ts_heap_profile_test::test_compiler(
workspace_dir,
entry_file_path,
noop_exporter,
);
typst_ts_heap_profile_test::test_compiler(workspace_dir, entry_file_path);
}
_ => panic!("Unknown action: {}", action),
}
Expand Down
26 changes: 7 additions & 19 deletions tests/incremental/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use std::path::Path;
use std::sync::Arc;

use reflexo_typst::config::{entry::EntryOpts, CompileOpts};
use reflexo_typst::exporter_builtins::GroupExporter;
use reflexo_typst::vector::{
ir::{Abs, Point, Rect},
stream::BytesModuleStream,
};
use reflexo_typst::{
Bytes, CompileDriver, CompileExporter, PureCompiler, ShadowApiExt, TypstDocument,
TypstSystemUniverse, TypstSystemWorld,
};
use reflexo_typst::{Bytes, CompileDriver, ShadowApiExt, TypstDocument, TypstSystemUniverse};
use reflexo_typst2vec::incr::{IncrDocClient, IncrDocServer};
use reflexo_vec2svg::IncrSvgDocClient;

fn get_driver(
workspace_dir: &Path,
entry_file_path: &Path,
exporter: GroupExporter<TypstDocument>,
) -> CompileDriver<CompileExporter<PureCompiler<TypstSystemWorld>>> {
fn get_driver(workspace_dir: &Path, entry_file_path: &Path) -> CompileDriver {
let project_base = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let w = project_base.join("fonts");
let font_path = project_base.join("assets/fonts");
Expand All @@ -30,15 +23,11 @@ fn get_driver(
.unwrap();

let world = world.with_entry_file(entry_file_path.to_owned());
CompileDriver::new(CompileExporter::default().with_exporter(exporter), world)
CompileDriver::new(Arc::new(|_| Ok(())), world)
}

pub fn test_compiler(
workspace_dir: &Path,
entry_file_path: &Path,
exporter: GroupExporter<TypstDocument>,
) {
let mut driver = get_driver(workspace_dir, entry_file_path, exporter);
pub fn test_compiler(workspace_dir: &Path, entry_file_path: &Path) {
let mut driver = get_driver(workspace_dir, entry_file_path);
let mut content = { std::fs::read_to_string(entry_file_path).expect("Could not read file") };

let mut incr_server = IncrDocServer::default();
Expand Down Expand Up @@ -112,7 +101,6 @@ pub fn main() {

for i in 0..10 {
eprintln!("Over Iteration {}", i);
let noop_exporter = GroupExporter::new(vec![]);
test_compiler(&workspace_dir, &entry_file_path, noop_exporter);
test_compiler(&workspace_dir, &entry_file_path);
}
}

0 comments on commit 57a75a5

Please sign in to comment.