From 815a382c58ead1bcbe623725969087c6a690f4ec Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Mon, 15 May 2023 19:14:28 -0500 Subject: [PATCH] better testing setup --- .gitignore | 2 +- benches/build_metafile.rs | 3 +-- tests/build_dir.rs | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 28878d6..8450d87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target -files/site/build +files/test_site/build files/bench_site/build diff --git a/benches/build_metafile.rs b/benches/build_metafile.rs index 51844d2..c8051b2 100644 --- a/benches/build_metafile.rs +++ b/benches/build_metafile.rs @@ -20,8 +20,7 @@ pub fn build_file_benchmark(c: &mut Criterion) { let mut file = metaforge::parse_file(string, black_box(&opts)).expect("parse file"); file.path = black_box(source.clone()); let string = metaforge::build_metafile(&file).expect("build file"); - metaforge::write_file(black_box(&source), string, black_box(&opts)) - .expect("write file"); + std::fs::write(file.dest().expect("find dest"), string).expect("write file"); }) }); } diff --git a/tests/build_dir.rs b/tests/build_dir.rs index 570ba1e..505f9c4 100644 --- a/tests/build_dir.rs +++ b/tests/build_dir.rs @@ -2,7 +2,7 @@ use color_eyre::Result; #[test] fn build_test_site() -> Result<()> { - let dir = std::path::PathBuf::from("files/site") + let dir = std::path::PathBuf::from("files/test_site") .canonicalize() .unwrap(); @@ -16,11 +16,20 @@ fn build_test_site() -> Result<()> { metaforge::build_dir(&opts)?; assert!(opts.build.join("benchmark.html").exists()); - assert!(opts.build.join("dir1/sub_dir1/deep1/deep.html").exists()); - assert_eq!( - std::fs::read_to_string(opts.build.join("root.html"))?, - "

TEST

\n" - ); + assert!(opts.build.join("unit_tests").exists()); + assert!(opts + .build + .join("unit_tests/blank/blank_array.html") + .exists()); + assert!(opts + .build + .join("unit_tests/expand/variable_in_source.html") + .exists()); + assert!(opts + .build + .join("unit_tests/override/variable.html") + .exists()); + assert!(opts.build.join("unit_tests/global/pattern.html").exists()); Ok(()) } -- 2.45.2